Skip to content

Commit a6cec84

Browse files
committed
Add default trait implementations for "c-unwind" ABI function pointers
Following up on #92964, only add default trait implementations for the `c-unwind` family of function pointers. The previous attempt in #92964 added trait implementations for many more ABIs and ran into concerns regarding the increase in size of the libcore rlib. An attempt to abstract away function pointer types behind a unified trait to reduce the duplication of trait impls is being discussed in #99531 but this change looks to be blocked on a lang MCP. Following @RalfJung's suggestion in rust-lang/rust#99531 (comment), this commit is another cut at #92964 but it _only_ adds the impls for `extern "C-unwind" fn` and `unsafe extern "C-unwind" fn`. I am interested in landing this patch to unblock the stabilization of the `c_unwind` feature. RFC: rust-lang/rfcs#2945 Tracking Issue: rust-lang/rust#74990
1 parent 84a0e80 commit a6cec84

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

core/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@
174174
#![feature(allow_internal_unstable)]
175175
#![feature(associated_type_bounds)]
176176
#![feature(auto_traits)]
177+
#![feature(c_unwind)]
177178
#![feature(cfg_sanitize)]
178179
#![feature(cfg_target_has_atomic)]
179180
#![feature(cfg_target_has_atomic_equal_alignment)]

core/src/ptr/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1938,16 +1938,22 @@ macro_rules! fnptr_impls_args {
19381938
fnptr_impls_safety_abi! { extern "Rust" fn($($Arg),+) -> Ret, $($Arg),+ }
19391939
fnptr_impls_safety_abi! { extern "C" fn($($Arg),+) -> Ret, $($Arg),+ }
19401940
fnptr_impls_safety_abi! { extern "C" fn($($Arg),+ , ...) -> Ret, $($Arg),+ }
1941+
fnptr_impls_safety_abi! { extern "C-unwind" fn($($Arg),+) -> Ret, $($Arg),+ }
1942+
fnptr_impls_safety_abi! { extern "C-unwind" fn($($Arg),+ , ...) -> Ret, $($Arg),+ }
19411943
fnptr_impls_safety_abi! { unsafe extern "Rust" fn($($Arg),+) -> Ret, $($Arg),+ }
19421944
fnptr_impls_safety_abi! { unsafe extern "C" fn($($Arg),+) -> Ret, $($Arg),+ }
19431945
fnptr_impls_safety_abi! { unsafe extern "C" fn($($Arg),+ , ...) -> Ret, $($Arg),+ }
1946+
fnptr_impls_safety_abi! { unsafe extern "C-unwind" fn($($Arg),+) -> Ret, $($Arg),+ }
1947+
fnptr_impls_safety_abi! { unsafe extern "C-unwind" fn($($Arg),+ , ...) -> Ret, $($Arg),+ }
19441948
};
19451949
() => {
19461950
// No variadic functions with 0 parameters
19471951
fnptr_impls_safety_abi! { extern "Rust" fn() -> Ret, }
19481952
fnptr_impls_safety_abi! { extern "C" fn() -> Ret, }
1953+
fnptr_impls_safety_abi! { extern "C-unwind" fn() -> Ret, }
19491954
fnptr_impls_safety_abi! { unsafe extern "Rust" fn() -> Ret, }
19501955
fnptr_impls_safety_abi! { unsafe extern "C" fn() -> Ret, }
1956+
fnptr_impls_safety_abi! { unsafe extern "C-unwind" fn() -> Ret, }
19511957
};
19521958
}
19531959

0 commit comments

Comments
 (0)