Skip to content

Commit 6d0e867

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

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

  • compiler/rustc_target/src/spec

compiler/rustc_target/src/spec/mod.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3218,6 +3218,30 @@ 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+
"`Other` variants are only meant for JSON targets"
3226+
);
3227+
check!(
3228+
!matches!(self.os, Os::Other(_)),
3229+
"`Other` variants are only meant for JSON targets"
3230+
);
3231+
check!(
3232+
!matches!(self.env, Env::Other(_)),
3233+
"`Other` variants are only meant for JSON targets"
3234+
);
3235+
check!(
3236+
!matches!(self.cfg_abi, CfgAbi::Other(_)),
3237+
"`Other` variants are only meant for JSON targets"
3238+
);
3239+
check!(
3240+
!matches!(self.llvm_abiname, LlvmAbi::Other(_)),
3241+
"`Other` variants are only meant for JSON targets"
3242+
);
3243+
}
3244+
32213245
// Check ABI flag consistency, for the architectures where we have proper ABI treatment.
32223246
// To ensure targets are trated consistently, please consult with the team before allowing
32233247
// new cases.

0 commit comments

Comments
 (0)