ensure Other variants are only used by JSON targets

This commit is contained in:
Ralf Jung
2026-03-22 10:38:25 +01:00
parent 6b1487698c
commit 4a0b26453d
+21
View File
@@ -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.