diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index b04c4889be23..c4e44007b7f1 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -3218,6 +3218,27 @@ macro_rules! check_matches { ); } + // Ensure built-in targets don't use the `Other` variants. + if kind == TargetKind::Builtin { + check!( + !matches!(self.arch, Arch::Other(_)), + "`Arch::Other` is only meant for JSON targets" + ); + check!(!matches!(self.os, Os::Other(_)), "`Os::Other` is only meant for JSON targets"); + check!( + !matches!(self.env, Env::Other(_)), + "`Env::Other` is only meant for JSON targets" + ); + check!( + !matches!(self.cfg_abi, CfgAbi::Other(_)), + "`CfgAbi::Other` is only meant for JSON targets" + ); + check!( + !matches!(self.llvm_abiname, LlvmAbi::Other(_)), + "`LlvmAbi::Other` is only meant for JSON targets" + ); + } + // Check ABI flag consistency, for the architectures where we have proper ABI treatment. // To ensure targets are trated consistently, please consult with the team before allowing // new cases.