Skip to content

Commit 4a0b264

Browse files
committed
ensure Other variants are only used by JSON targets
1 parent 6b14876 commit 4a0b264

File tree

1 file changed

+21
-0
lines changed
  • compiler/rustc_target/src/spec

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3218,6 +3218,27 @@ impl Target {
32183218
);
32193219
}
32203220

3221+
// Ensure built-in targets don't use the `Other` variants.
3222+
if kind == TargetKind::Builtin {
3223+
check!(
3224+
!matches!(self.arch, Arch::Other(_)),
3225+
"`Arch::Other` is only meant for JSON targets"
3226+
);
3227+
check!(!matches!(self.os, Os::Other(_)), "`Os::Other` is only meant for JSON targets");
3228+
check!(
3229+
!matches!(self.env, Env::Other(_)),
3230+
"`Env::Other` is only meant for JSON targets"
3231+
);
3232+
check!(
3233+
!matches!(self.cfg_abi, CfgAbi::Other(_)),
3234+
"`CfgAbi::Other` is only meant for JSON targets"
3235+
);
3236+
check!(
3237+
!matches!(self.llvm_abiname, LlvmAbi::Other(_)),
3238+
"`LlvmAbi::Other` is only meant for JSON targets"
3239+
);
3240+
}
3241+
32213242
// Check ABI flag consistency, for the architectures where we have proper ABI treatment.
32223243
// To ensure targets are trated consistently, please consult with the team before allowing
32233244
// new cases.

0 commit comments

Comments
 (0)