mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Add rust-invalid ABI
This commit is contained in:
@@ -36,6 +36,10 @@ pub enum ExternAbi {
|
||||
/// Stronger than just `#[cold]` because `fn` pointers might be incompatible.
|
||||
RustCold,
|
||||
|
||||
/// An always-invalid ABI that's used to test "this ABI is not supported by this platform"
|
||||
/// in a platform-agnostic way.
|
||||
RustInvalid,
|
||||
|
||||
/// Unstable impl detail that directly uses Rust types to describe the ABI to LLVM.
|
||||
/// Even normally-compatible Rust types can become ABI-incompatible with this ABI!
|
||||
Unadjusted,
|
||||
@@ -157,6 +161,7 @@ fn from_str(s: &str) -> Result<$e_name, Self::Err> {
|
||||
RiscvInterruptS =><= "riscv-interrupt-s",
|
||||
RustCall =><= "rust-call",
|
||||
RustCold =><= "rust-cold",
|
||||
RustInvalid =><= "rust-invalid",
|
||||
Stdcall { unwind: false } =><= "stdcall",
|
||||
Stdcall { unwind: true } =><= "stdcall-unwind",
|
||||
System { unwind: false } =><= "system",
|
||||
|
||||
@@ -96,6 +96,9 @@ pub fn extern_abi_stability(abi: ExternAbi) -> Result<(), UnstableAbi> {
|
||||
ExternAbi::RustCold => {
|
||||
Err(UnstableAbi { abi, feature: sym::rust_cold_cc, explain: GateReason::Experimental })
|
||||
}
|
||||
ExternAbi::RustInvalid => {
|
||||
Err(UnstableAbi { abi, feature: sym::rustc_attrs, explain: GateReason::ImplDetail })
|
||||
}
|
||||
ExternAbi::GpuKernel => Err(UnstableAbi {
|
||||
abi,
|
||||
feature: sym::abi_gpu_kernel,
|
||||
|
||||
@@ -1253,7 +1253,8 @@ pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option<DefId>, abi: ExternAbi)
|
||||
| CCmseNonSecureCall
|
||||
| CCmseNonSecureEntry
|
||||
| Custom
|
||||
| Unadjusted => false,
|
||||
| Unadjusted
|
||||
| RustInvalid => false,
|
||||
Rust | RustCall | RustCold => tcx.sess.panic_strategy() == PanicStrategy::Unwind,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -494,6 +494,7 @@ fn internal<'tcx>(&self, _tables: &mut Tables<'_>, _tcx: TyCtxt<'tcx>) -> Self::
|
||||
Abi::RustCall => rustc_abi::ExternAbi::RustCall,
|
||||
Abi::Unadjusted => rustc_abi::ExternAbi::Unadjusted,
|
||||
Abi::RustCold => rustc_abi::ExternAbi::RustCold,
|
||||
Abi::RustInvalid => rustc_abi::ExternAbi::RustInvalid,
|
||||
Abi::RiscvInterruptM => rustc_abi::ExternAbi::RiscvInterruptM,
|
||||
Abi::RiscvInterruptS => rustc_abi::ExternAbi::RiscvInterruptS,
|
||||
Abi::Custom => rustc_abi::ExternAbi::Custom,
|
||||
|
||||
@@ -877,6 +877,7 @@ fn stable(&self, _: &mut Tables<'_>) -> Self::T {
|
||||
ExternAbi::RustCall => Abi::RustCall,
|
||||
ExternAbi::Unadjusted => Abi::Unadjusted,
|
||||
ExternAbi::RustCold => Abi::RustCold,
|
||||
ExternAbi::RustInvalid => Abi::RustInvalid,
|
||||
ExternAbi::RiscvInterruptM => Abi::RiscvInterruptM,
|
||||
ExternAbi::RiscvInterruptS => Abi::RiscvInterruptS,
|
||||
ExternAbi::Custom => Abi::Custom,
|
||||
|
||||
@@ -1126,6 +1126,7 @@ pub enum Abi {
|
||||
RustCold,
|
||||
RiscvInterruptM,
|
||||
RiscvInterruptS,
|
||||
RustInvalid,
|
||||
Custom,
|
||||
}
|
||||
|
||||
|
||||
@@ -156,7 +156,8 @@ pub fn canonize_abi(&self, extern_abi: ExternAbi, has_c_varargs: bool) -> AbiMap
|
||||
| ExternAbi::Msp430Interrupt
|
||||
| ExternAbi::RiscvInterruptM
|
||||
| ExternAbi::RiscvInterruptS
|
||||
| ExternAbi::X86Interrupt,
|
||||
| ExternAbi::X86Interrupt
|
||||
| ExternAbi::RustInvalid,
|
||||
_,
|
||||
) => return AbiMapping::Invalid,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// Tests the `"rustc-invalid"` ABI, which is never canonizable.
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
const extern "rust-invalid" fn foo() {
|
||||
//~^ ERROR "rust-invalid" is not a supported ABI for the current target
|
||||
panic!()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
foo();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
error[E0570]: "rust-invalid" is not a supported ABI for the current target
|
||||
--> $DIR/invalid-call-abi.rs:5:14
|
||||
|
|
||||
LL | const extern "rust-invalid" fn foo() {
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0570`.
|
||||
@@ -20,6 +20,7 @@ riscv-interrupt-m
|
||||
riscv-interrupt-s
|
||||
rust-call
|
||||
rust-cold
|
||||
rust-invalid
|
||||
stdcall
|
||||
stdcall-unwind
|
||||
system
|
||||
|
||||
Reference in New Issue
Block a user