diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-08-31 13:40:34 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-31 13:40:34 +0200 |
| commit | 0e28b4201ac8f12cfafe5383f442c7b00f8bdcc6 (patch) | |
| tree | 4bd07360ed13d7e7ab0f8e3c89259bf831e5a3aa /compiler/rustc_target/src | |
| parent | 64a99db105f45ea3304732ffb51066c3b5193bc7 (diff) | |
| parent | 2d8cb59784711f503170011461c23385042a974d (diff) | |
| download | rust-0e28b4201ac8f12cfafe5383f442c7b00f8bdcc6.tar.gz rust-0e28b4201ac8f12cfafe5383f442c7b00f8bdcc6.zip | |
Rollup merge of #144443 - WaffleLapkin:integer-target-pointer-width, r=Noratrieb
Make target pointer width in target json an integer r? Noratrieb cc `@RalfJung` (https://github.com/rust-lang/rust/pull/142352/files#r2230380120) try-job: x86_64-rust-for-linux
Diffstat (limited to 'compiler/rustc_target/src')
| -rw-r--r-- | compiler/rustc_target/src/spec/json.rs | 25 | ||||
| -rw-r--r-- | compiler/rustc_target/src/spec/mod.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_target/src/tests.rs | 2 |
3 files changed, 12 insertions, 17 deletions
diff --git a/compiler/rustc_target/src/spec/json.rs b/compiler/rustc_target/src/spec/json.rs index f56a65d9c0c..e9ae5734d5b 100644 --- a/compiler/rustc_target/src/spec/json.rs +++ b/compiler/rustc_target/src/spec/json.rs @@ -25,10 +25,7 @@ impl Target { let mut base = Target { llvm_target: json.llvm_target, metadata: Default::default(), - pointer_width: json - .target_pointer_width - .parse() - .map_err(|err| format!("invalid target-pointer-width: {err}"))?, + pointer_width: json.target_pointer_width, data_layout: json.data_layout, arch: json.arch, options: Default::default(), @@ -245,19 +242,17 @@ impl ToJson for Target { target.update_to_cli(); macro_rules! target_val { - ($attr:ident) => {{ - let name = (stringify!($attr)).replace("_", "-"); - d.insert(name, target.$attr.to_json()); + ($attr:ident) => { + target_val!($attr, (stringify!($attr)).replace("_", "-")) + }; + ($attr:ident, $json_name:expr) => {{ + let name = $json_name; + d.insert(name.into(), target.$attr.to_json()); }}; } macro_rules! target_option_val { - ($attr:ident) => {{ - let name = (stringify!($attr)).replace("_", "-"); - if default.$attr != target.$attr { - d.insert(name, target.$attr.to_json()); - } - }}; + ($attr:ident) => {{ target_option_val!($attr, (stringify!($attr)).replace("_", "-")) }}; ($attr:ident, $json_name:expr) => {{ let name = $json_name; if default.$attr != target.$attr { @@ -290,7 +285,7 @@ impl ToJson for Target { target_val!(llvm_target); target_val!(metadata); - d.insert("target-pointer-width".to_string(), self.pointer_width.to_string().to_json()); + target_val!(pointer_width, "target-pointer-width"); target_val!(arch); target_val!(data_layout); @@ -463,7 +458,7 @@ struct TargetSpecJsonMetadata { #[serde(deny_unknown_fields)] struct TargetSpecJson { llvm_target: StaticCow<str>, - target_pointer_width: String, + target_pointer_width: u16, data_layout: StaticCow<str>, arch: StaticCow<str>, diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index e97a9b9c776..4d9f06c568b 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -2331,7 +2331,7 @@ pub struct Target { /// Used for generating target documentation. pub metadata: TargetMetadata, /// Number of bits in a pointer. Influences the `target_pointer_width` `cfg` variable. - pub pointer_width: u32, + pub pointer_width: u16, /// Architecture to use for ABI considerations. Valid options include: "x86", /// "x86_64", "arm", "aarch64", "mips", "powerpc", "powerpc64", and others. pub arch: StaticCow<str>, diff --git a/compiler/rustc_target/src/tests.rs b/compiler/rustc_target/src/tests.rs index ee847a84007..a2692ea6be5 100644 --- a/compiler/rustc_target/src/tests.rs +++ b/compiler/rustc_target/src/tests.rs @@ -7,7 +7,7 @@ fn report_unused_fields() { "arch": "powerpc64", "data-layout": "e-m:e-i64:64-n32:64", "llvm-target": "powerpc64le-elf", - "target-pointer-width": "64", + "target-pointer-width": 64, "code-mode": "foo" } "#; |
