Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d84d4dc

Browse files
allow using target_val! with a rename
1 parent b56aaec commit d84d4dc

File tree

1 file changed

+8
-10
lines changed
  • compiler/rustc_target/src/spec

1 file changed

+8
-10
lines changed

‎compiler/rustc_target/src/spec/json.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -245,19 +245,17 @@ impl ToJson for Target {
245245
target.update_to_cli();
246246

247247
macro_rules! target_val {
248-
($attr:ident) => {{
249-
let name = (stringify!($attr)).replace("_", "-");
250-
d.insert(name, target.$attr.to_json());
248+
($attr:ident) => {
249+
target_val!($attr, (stringify!($attr)).replace("_", "-"))
250+
};
251+
($attr:ident, $json_name:expr) => {{
252+
let name = $json_name;
253+
d.insert(name.into(), target.$attr.to_json());
251254
}};
252255
}
253256

254257
macro_rules! target_option_val {
255-
($attr:ident) => {{
256-
let name = (stringify!($attr)).replace("_", "-");
257-
if default.$attr != target.$attr {
258-
d.insert(name, target.$attr.to_json());
259-
}
260-
}};
258+
($attr:ident) => {{ target_option_val!($attr, (stringify!($attr)).replace("_", "-")) }};
261259
($attr:ident, $json_name:expr) => {{
262260
let name = $json_name;
263261
if default.$attr != target.$attr {
@@ -290,7 +288,7 @@ impl ToJson for Target {
290288

291289
target_val!(llvm_target);
292290
target_val!(metadata);
293-
d.insert("target-pointer-width".to_string(),self.pointer_width.to_string().to_json());
291+
target_val!(pointer_width,"target-pointer-width");
294292
target_val!(arch);
295293
target_val!(data_layout);
296294

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /