Skip to content

Commit 1cb6357

Browse files
committed
Auto merge of #106075 - nbdd0121:ffi-unwind, r=joshtriplett
Partial stabilisation of `c_unwind` The stabilisation report is at #74990 (comment) cc `@rust-lang/wg-ffi-unwind`
2 parents d6ddee6 + c9a0be2 commit 1cb6357

File tree

32 files changed

+53
-280
lines changed

32 files changed

+53
-280
lines changed

compiler/rustc_feature/src/active.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ declare_features! (
311311
(active, async_closure, "1.37.0", Some(62290), None),
312312
/// Allows async functions to be declared, implemented, and used in traits.
313313
(incomplete, async_fn_in_trait, "1.66.0", Some(91611), None),
314-
/// Allows `extern "C-unwind" fn` to enable unwinding across ABI boundaries.
314+
/// Treat `extern "C"` function as nounwind.
315315
(active, c_unwind, "1.52.0", Some(74990), None),
316316
/// Allows using C-variadics.
317317
(active, c_variadic, "1.34.0", Some(44930), None),

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4014,7 +4014,6 @@ declare_lint! {
40144014
/// ### Example
40154015
///
40164016
/// ```rust
4017-
/// #![feature(c_unwind)]
40184017
/// #![warn(ffi_unwind_calls)]
40194018
///
40204019
/// extern "C-unwind" {
@@ -4037,8 +4036,7 @@ declare_lint! {
40374036
/// that desire this ability it is therefore necessary to avoid such calls.
40384037
pub FFI_UNWIND_CALLS,
40394038
Allow,
4040-
"call to foreign functions or function pointers with FFI-unwind ABI",
4041-
@feature_gate = sym::c_unwind;
4039+
"call to foreign functions or function pointers with FFI-unwind ABI"
40424040
}
40434041

40444042
declare_lint! {

compiler/rustc_target/src/spec/abi.rs

Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,9 @@ pub fn is_enabled(
148148
pub fn is_stable(name: &str) -> Result<(), AbiDisabled> {
149149
match name {
150150
// Stable
151-
"Rust" | "C" | "cdecl" | "stdcall" | "fastcall" | "aapcs" | "win64" | "sysv64"
152-
| "system" | "efiapi" => Ok(()),
151+
"Rust" | "C" | "C-unwind" | "cdecl" | "cdecl-unwind" | "stdcall" | "stdcall-unwind"
152+
| "fastcall" | "fastcall-unwind" | "aapcs" | "aapcs-unwind" | "win64" | "win64-unwind"
153+
| "sysv64" | "sysv64-unwind" | "system" | "system-unwind" | "efiapi" => Ok(()),
153154
"rust-intrinsic" => Err(AbiDisabled::Unstable {
154155
feature: sym::intrinsics,
155156
explain: "intrinsics are subject to change",
@@ -162,10 +163,18 @@ pub fn is_stable(name: &str) -> Result<(), AbiDisabled> {
162163
feature: sym::abi_vectorcall,
163164
explain: "vectorcall is experimental and subject to change",
164165
}),
166+
"vectorcall-unwind" => Err(AbiDisabled::Unstable {
167+
feature: sym::abi_vectorcall,
168+
explain: "vectorcall-unwind ABI is experimental and subject to change",
169+
}),
165170
"thiscall" => Err(AbiDisabled::Unstable {
166171
feature: sym::abi_thiscall,
167172
explain: "thiscall is experimental and subject to change",
168173
}),
174+
"thiscall-unwind" => Err(AbiDisabled::Unstable {
175+
feature: sym::abi_thiscall,
176+
explain: "thiscall-unwind ABI is experimental and subject to change",
177+
}),
169178
"rust-call" => Err(AbiDisabled::Unstable {
170179
feature: sym::unboxed_closures,
171180
explain: "rust-call ABI is subject to change",
@@ -202,46 +211,6 @@ pub fn is_stable(name: &str) -> Result<(), AbiDisabled> {
202211
feature: sym::abi_c_cmse_nonsecure_call,
203212
explain: "C-cmse-nonsecure-call ABI is experimental and subject to change",
204213
}),
205-
"C-unwind" => Err(AbiDisabled::Unstable {
206-
feature: sym::c_unwind,
207-
explain: "C-unwind ABI is experimental and subject to change",
208-
}),
209-
"stdcall-unwind" => Err(AbiDisabled::Unstable {
210-
feature: sym::c_unwind,
211-
explain: "stdcall-unwind ABI is experimental and subject to change",
212-
}),
213-
"system-unwind" => Err(AbiDisabled::Unstable {
214-
feature: sym::c_unwind,
215-
explain: "system-unwind ABI is experimental and subject to change",
216-
}),
217-
"thiscall-unwind" => Err(AbiDisabled::Unstable {
218-
feature: sym::c_unwind,
219-
explain: "thiscall-unwind ABI is experimental and subject to change",
220-
}),
221-
"cdecl-unwind" => Err(AbiDisabled::Unstable {
222-
feature: sym::c_unwind,
223-
explain: "cdecl-unwind ABI is experimental and subject to change",
224-
}),
225-
"fastcall-unwind" => Err(AbiDisabled::Unstable {
226-
feature: sym::c_unwind,
227-
explain: "fastcall-unwind ABI is experimental and subject to change",
228-
}),
229-
"vectorcall-unwind" => Err(AbiDisabled::Unstable {
230-
feature: sym::c_unwind,
231-
explain: "vectorcall-unwind ABI is experimental and subject to change",
232-
}),
233-
"aapcs-unwind" => Err(AbiDisabled::Unstable {
234-
feature: sym::c_unwind,
235-
explain: "aapcs-unwind ABI is experimental and subject to change",
236-
}),
237-
"win64-unwind" => Err(AbiDisabled::Unstable {
238-
feature: sym::c_unwind,
239-
explain: "win64-unwind ABI is experimental and subject to change",
240-
}),
241-
"sysv64-unwind" => Err(AbiDisabled::Unstable {
242-
feature: sym::c_unwind,
243-
explain: "sysv64-unwind ABI is experimental and subject to change",
244-
}),
245214
"wasm" => Err(AbiDisabled::Unstable {
246215
feature: sym::wasm_abi,
247216
explain: "wasm ABI is experimental and subject to change",

library/panic_unwind/src/emcc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static EXCEPTION_TYPE_INFO: TypeInfo = TypeInfo {
4747
name: b"rust_panic\0".as_ptr(),
4848
};
4949

50-
// NOTE(nbdd0121): The `canary` field will be part of stable ABI after `c_unwind` stabilization.
50+
// NOTE(nbdd0121): The `canary` field is part of stable ABI.
5151
#[repr(C)]
5252
struct Exception {
5353
// See `gcc.rs` on why this is present. We already have a static here so just use it.

library/panic_unwind/src/gcc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ use unwind as uw;
4848
static CANARY: u8 = 0;
4949

5050
// NOTE(nbdd0121)
51-
// Once `c_unwind` feature is stabilized, there will be ABI stability requirement
52-
// on this struct. The first two field must be `_Unwind_Exception` and `canary`,
51+
// There is an ABI stability requirement on this struct.
52+
// The first two field must be `_Unwind_Exception` and `canary`,
5353
// as it may be accessed by a different version of the std with a different compiler.
5454
#[repr(C)]
5555
struct Exception {

library/panic_unwind/src/seh.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ use core::mem::{self, ManuallyDrop};
5252
use core::ptr;
5353
use libc::{c_int, c_uint, c_void};
5454

55-
// NOTE(nbdd0121): The `canary` field will be part of stable ABI after `c_unwind` stabilization.
55+
// NOTE(nbdd0121): The `canary` field is part of stable ABI.
5656
#[repr(C)]
5757
struct Exception {
5858
// See `gcc.rs` on why this is present. We already have a static here so just use it.

tests/run-make/c-unwind-abi-catch-lib-panic/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//!
33
//! This test triggers a panic in a Rust library that our foreign function invokes. This shows
44
//! that we can unwind through the C code in that library, and catch the underlying panic.
5-
#![feature(c_unwind)]
65
76
use std::panic::{catch_unwind, AssertUnwindSafe};
87

tests/run-make/c-unwind-abi-catch-lib-panic/panic.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![crate_type = "staticlib"]
2-
#![feature(c_unwind)]
32

43
/// This function will panic if `x` is greater than 10.
54
///

tests/run-make/c-unwind-abi-catch-panic/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! A test for calling `C-unwind` functions across foreign function boundaries.
22
//!
33
//! This test triggers a panic when calling a foreign function that calls *back* into Rust.
4-
#![feature(c_unwind)]
54
65
use std::panic::{catch_unwind, AssertUnwindSafe};
76

tests/run-make/foreign-double-unwind/foo.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Tests that C++ double unwinding through Rust code will be properly guarded
22
// against instead of exhibiting undefined behaviour.
33

4-
#![feature(c_unwind)]
5-
64
extern "C-unwind" {
75
fn throw_cxx_exception();
86
fn cxx_catch_callback(cb: extern "C-unwind" fn());

0 commit comments

Comments
 (0)