mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 07:22:42 +00:00
address pr review comments
### Add debug assertion to check `AbiDatas` ordering This makes a small alteration to `Abi::index`, so that we include a debug assertion to check that the index we are returning corresponds with the same abi in our data array. This will help prevent ordering bugs in the future, which can manifest in rather strange errors. ### Using exhaustive ABI matches This slightly modifies the changes from our previous commits, favoring exhaustive matches in place of `_ => ...` fall-through arms. This should help with maintenance in the future, when additional ABI's are added, or when existing ABI's are modified. ### List all `-unwind` ABI's in unstable book This updates the `c-unwind` page in the unstable book to list _all_ of the other ABI strings that are introduced by this feature gate. Now, all of the ABI's specified by RFC 2945 are shown. Co-authored-by: Amanieu d'Antras <amanieu@gmail.com> Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
This commit is contained in:
parent
baf227ea0c
commit
05bf037fec
@ -2595,7 +2595,25 @@ fn fn_can_unwind(
|
||||
C { unwind } | Stdcall { unwind } | System { unwind } | Thiscall { unwind } => {
|
||||
unwind
|
||||
}
|
||||
_ => false,
|
||||
Cdecl
|
||||
| Fastcall
|
||||
| Vectorcall
|
||||
| Aapcs
|
||||
| Win64
|
||||
| SysV64
|
||||
| PtxKernel
|
||||
| Msp430Interrupt
|
||||
| X86Interrupt
|
||||
| AmdGpuKernel
|
||||
| EfiApi
|
||||
| AvrInterrupt
|
||||
| AvrNonBlockingInterrupt
|
||||
| CCmseNonSecureCall
|
||||
| RustIntrinsic
|
||||
| PlatformIntrinsic
|
||||
| Unadjusted => false,
|
||||
// In the `if` above, we checked for functions with the Rust calling convention.
|
||||
Rust | RustCall => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -575,7 +575,23 @@ fn should_abort_on_panic(tcx: TyCtxt<'_>, fn_def_id: LocalDefId, abi: Abi) -> bo
|
||||
// Rust and `rust-call` functions are allowed to unwind, and should not abort.
|
||||
Rust | RustCall => false,
|
||||
// Other ABI's should abort.
|
||||
_ => true,
|
||||
Cdecl
|
||||
| Fastcall
|
||||
| Vectorcall
|
||||
| Aapcs
|
||||
| Win64
|
||||
| SysV64
|
||||
| PtxKernel
|
||||
| Msp430Interrupt
|
||||
| X86Interrupt
|
||||
| AmdGpuKernel
|
||||
| EfiApi
|
||||
| AvrInterrupt
|
||||
| AvrNonBlockingInterrupt
|
||||
| CCmseNonSecureCall
|
||||
| RustIntrinsic
|
||||
| PlatformIntrinsic
|
||||
| Unadjusted => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ impl Abi {
|
||||
// N.B., this ordering MUST match the AbiDatas array above.
|
||||
// (This is ensured by the test indices_are_correct().)
|
||||
use Abi::*;
|
||||
match self {
|
||||
let i = match self {
|
||||
// Cross-platform ABIs
|
||||
Rust => 0,
|
||||
C { unwind: false } => 1,
|
||||
@ -138,7 +138,18 @@ impl Abi {
|
||||
RustCall => 24,
|
||||
PlatformIntrinsic => 25,
|
||||
Unadjusted => 26,
|
||||
}
|
||||
};
|
||||
debug_assert!(
|
||||
AbiDatas
|
||||
.iter()
|
||||
.enumerate()
|
||||
.find(|(_, AbiData { abi, .. })| *abi == self)
|
||||
.map(|(index, _)| index)
|
||||
.expect("abi variant has associated data")
|
||||
== i,
|
||||
"Abi index did not match `AbiDatas` ordering"
|
||||
);
|
||||
i
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -6,7 +6,8 @@ The tracking issue for this feature is: [#74990]
|
||||
|
||||
------------------------
|
||||
|
||||
Introduces a new ABI string, "C-unwind", to enable unwinding from other
|
||||
Introduces four new ABI strings: "C-unwind", "stdcall-unwind",
|
||||
"thiscall-unwind", and "system-unwind". These enable unwinding from other
|
||||
languages (such as C++) into Rust frames and from Rust into other languages.
|
||||
|
||||
See [RFC 2945] for more information.
|
||||
|
Loading…
Reference in New Issue
Block a user