Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e245570

Browse files
Add rust-invalid ABI
1 parent 36b2163 commit e245570

File tree

10 files changed

+37
-2
lines changed

10 files changed

+37
-2
lines changed

‎compiler/rustc_abi/src/extern_abi.rs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ pub enum ExternAbi {
3636
/// Stronger than just `#[cold]` because `fn` pointers might be incompatible.
3737
RustCold,
3838

39+
/// An always-invalid ABI that's used to test "this ABI is not supported by this platform"
40+
/// in a platform-agnostic way.
41+
RustInvalid,
42+
3943
/// Unstable impl detail that directly uses Rust types to describe the ABI to LLVM.
4044
/// Even normally-compatible Rust types can become ABI-incompatible with this ABI!
4145
Unadjusted,
@@ -157,6 +161,7 @@ abi_impls! {
157161
RiscvInterruptS =><= "riscv-interrupt-s",
158162
RustCall =><= "rust-call",
159163
RustCold =><= "rust-cold",
164+
RustInvalid =><= "rust-invalid",
160165
Stdcall { unwind: false } =><= "stdcall",
161166
Stdcall { unwind: true } =><= "stdcall-unwind",
162167
System { unwind: false } =><= "system",

‎compiler/rustc_ast_lowering/src/stability.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ pub fn extern_abi_stability(abi: ExternAbi) -> Result<(), UnstableAbi> {
9696
ExternAbi::RustCold => {
9797
Err(UnstableAbi { abi, feature: sym::rust_cold_cc, explain: GateReason::Experimental })
9898
}
99+
ExternAbi::RustInvalid => {
100+
Err(UnstableAbi { abi, feature: sym::rustc_attrs, explain: GateReason::ImplDetail })
101+
}
99102
ExternAbi::GpuKernel => Err(UnstableAbi {
100103
abi,
101104
feature: sym::abi_gpu_kernel,

‎compiler/rustc_middle/src/ty/layout.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,8 @@ pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option<DefId>, abi: ExternAbi)
12531253
| CCmseNonSecureCall
12541254
| CCmseNonSecureEntry
12551255
| Custom
1256-
| Unadjusted => false,
1256+
| Unadjusted
1257+
| RustInvalid => false,
12571258
Rust | RustCall | RustCold => tcx.sess.panic_strategy() == PanicStrategy::Unwind,
12581259
}
12591260
}

‎compiler/rustc_smir/src/rustc_internal/internal.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ impl RustcInternal for Abi {
494494
Abi::RustCall => rustc_abi::ExternAbi::RustCall,
495495
Abi::Unadjusted => rustc_abi::ExternAbi::Unadjusted,
496496
Abi::RustCold => rustc_abi::ExternAbi::RustCold,
497+
Abi::RustInvalid => rustc_abi::ExternAbi::RustInvalid,
497498
Abi::RiscvInterruptM => rustc_abi::ExternAbi::RiscvInterruptM,
498499
Abi::RiscvInterruptS => rustc_abi::ExternAbi::RiscvInterruptS,
499500
Abi::Custom => rustc_abi::ExternAbi::Custom,

‎compiler/rustc_smir/src/rustc_smir/convert/ty.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,7 @@ impl<'tcx> Stable<'tcx> for rustc_abi::ExternAbi {
877877
ExternAbi::RustCall => Abi::RustCall,
878878
ExternAbi::Unadjusted => Abi::Unadjusted,
879879
ExternAbi::RustCold => Abi::RustCold,
880+
ExternAbi::RustInvalid => Abi::RustInvalid,
880881
ExternAbi::RiscvInterruptM => Abi::RiscvInterruptM,
881882
ExternAbi::RiscvInterruptS => Abi::RiscvInterruptS,
882883
ExternAbi::Custom => Abi::Custom,

‎compiler/rustc_smir/src/stable_mir/ty.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,7 @@ pub enum Abi {
11261126
RustCold,
11271127
RiscvInterruptM,
11281128
RiscvInterruptS,
1129+
RustInvalid,
11291130
Custom,
11301131
}
11311132

‎compiler/rustc_target/src/spec/abi_map.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ impl AbiMap {
156156
| ExternAbi::Msp430Interrupt
157157
| ExternAbi::RiscvInterruptM
158158
| ExternAbi::RiscvInterruptS
159-
| ExternAbi::X86Interrupt,
159+
| ExternAbi::X86Interrupt
160+
| ExternAbi::RustInvalid,
160161
_,
161162
) => return AbiMapping::Invalid,
162163
};

‎tests/ui/abi/invalid-call-abi.rs‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Tests the `"rustc-invalid"` ABI, which is never canonizable.
2+
3+
#![feature(rustc_attrs)]
4+
5+
const extern "rust-invalid" fn foo() {
6+
//~^ ERROR "rust-invalid" is not a supported ABI for the current target
7+
panic!()
8+
}
9+
10+
fn main() {
11+
foo();
12+
}

‎tests/ui/abi/invalid-call-abi.stderr‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0570]: "rust-invalid" is not a supported ABI for the current target
2+
--> $DIR/invalid-call-abi.rs:5:14
3+
|
4+
LL | const extern "rust-invalid" fn foo() {
5+
| ^^^^^^^^^^^^^^
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0570`.

‎tests/ui/print-calling-conventions.stdout‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ riscv-interrupt-m
2020
riscv-interrupt-s
2121
rust-call
2222
rust-cold
23+
rust-invalid
2324
stdcall
2425
stdcall-unwind
2526
system

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /