Repository: rust-lang/rust
File: compiler/rustc_target/src/spec/mod.rs (Rust)

Code before:
        match self.arch {
            Arch::RiscV32 => {
                check_matches!(
                    &*self.llvm_abiname,
                    "ilp32" | "ilp32f" | "ilp32d" | "ilp32e",
                    "invalid RISC-V ABI name: {}",
                    self.llvm_abiname,
                );
            }
            Arch::RiscV64 => {
                // Note that the `lp64e` is still unstable as it's not (yet) part of the ELF psABI.
                check_matches!(
                    &*self.llvm_abiname,
                    "lp64" | "lp64f" | "lp64d" | "lp64e",
                    "invalid RISC-V ABI name: {}",
                    self.llvm_abiname,
                );
            }
            Arch::Arm => {
                check!(
                    self.llvm_floatabi.is_some(),
                    "ARM targets must set `llvm-floatabi` to `hard` or `soft`",
                )
            }
            // PowerPC64 targets that are not AIX must set their ABI to either ELFv1 or ELFv2
            Arch::PowerPC64 if self.os != Os::Aix => {
                if self.endian == Endian::Big {
                    check_matches!(
                        &*self.llvm_abiname,
                        "elfv1" | "elfv2",
                        "invalid PowerPC64 ABI name: {}",
                        self.llvm_abiname,
                    );
                } else {
                    check!(
                        self.llvm_abiname == "elfv2",
                        "little-endian PowerPC64 targets only support the `elfv2` ABI",
                    );
                }
            }
            _ => {}
        }

        // Check consistency of Rust ABI declaration.
        if let Some(rust_abi) = self.rustc_abi {
            match rust_abi {
                RustcAbi::X86Sse2 => check_matches!(
                    self.arch,
                    Arch::X86,
                    "`x86-sse2` ABI is only valid for x86-32 targets"
                ),

Review comment (bug):
AFAIK specifying AIX's ABI as ELF is also incorrect, so rather than skipping the check for AIX here, it might be better to check that nothing is set for AIX.

Code after:
        match self.arch {
            Arch::RiscV32 => {
                check_matches!(
                    &*self.llvm_abiname,
                    "ilp32" | "ilp32f" | "ilp32d" | "ilp32e",
                    "invalid RISC-V ABI name: {}",
                    self.llvm_abiname,
                );
            }
            Arch::RiscV64 => {
                // Note that the `lp64e` is still unstable as it's not (yet) part of the ELF psABI.
                check_matches!(
                    &*self.llvm_abiname,
                    "lp64" | "lp64f" | "lp64d" | "lp64e",
                    "invalid RISC-V ABI name: {}",
                    self.llvm_abiname,
                );
            }
            Arch::Arm => {
                check!(
                    self.llvm_floatabi.is_some(),
                    "ARM targets must set `llvm-floatabi` to `hard` or `soft`",
                )
            }
            // PowerPC64 targets that are not AIX must set their ABI to either ELFv1 or ELFv2
            Arch::PowerPC64 => {
                if self.os == Os::Aix {
                    check!(
                        self.llvm_abiname.is_empty(),
                        "AIX targets always use the AIX ABI and `llvm_abiname` should be left empty",
                    );
                } else if self.endian == Endian::Big {
                    check_matches!(
                        &*self.llvm_abiname,
                        "elfv1" | "elfv2",
                        "invalid PowerPC64 ABI name: {}",
                        self.llvm_abiname,
                    );
                } else {
                    check!(
                        self.llvm_abiname == "elfv2",
                        "little-endian PowerPC64 targets only support the `elfv2` ABI",
                    );
                }
            }
            _ => {}
        }

        // Check consistency of Rust ABI declaration.
        if let Some(rust_abi) = self.rustc_abi {
            match rust_abi {