File tree Expand file tree Collapse file tree 7 files changed +16
-8
lines changed Expand file tree Collapse file tree 7 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -152,7 +152,8 @@ pub(super) fn install() {
152
152
libc:: sigaltstack ( & alt_stack, ptr:: null_mut ( ) ) ;
153
153
154
154
let mut sa: libc:: sigaction = mem:: zeroed ( ) ;
155
- sa. sa_sigaction = print_stack_trace as libc:: sighandler_t ;
155
+ sa. sa_sigaction =
156
+ print_stack_trace as unsafe extern "C" fn ( libc:: c_int ) as libc:: sighandler_t ;
156
157
sa. sa_flags = libc:: SA_NODEFER | libc:: SA_RESETHAND | libc:: SA_ONSTACK ;
157
158
libc:: sigemptyset ( & mut sa. sa_mask ) ;
158
159
for ( signum, _signame) in KILL_SIGNALS {
Original file line number Diff line number Diff line change @@ -152,7 +152,10 @@ fn current_dll_path() -> Result<PathBuf, String> {
152
152
unsafe {
153
153
GetModuleHandleExW (
154
154
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS ,
155
- PCWSTR ( current_dll_path as * mut u16 ) ,
155
+ PCWSTR (
156
+ current_dll_path as fn ( ) -> Result < std:: path:: PathBuf , std:: string:: String >
157
+ as * mut u16 ,
158
+ ) ,
156
159
& mut module,
157
160
)
158
161
}
Original file line number Diff line number Diff line change @@ -1429,7 +1429,7 @@ pub const fn forget<T: ?Sized>(_: T);
1429
1429
/// // Crucially, we `as`-cast to a raw pointer before `transmute`ing to a function pointer.
1430
1430
/// // This avoids an integer-to-pointer `transmute`, which can be problematic.
1431
1431
/// // Transmuting between raw pointers and function pointers (i.e., two pointer types) is fine.
1432
- /// let pointer = foo as *const ();
1432
+ /// let pointer = foo as fn() -> i32 as *const ();
1433
1433
/// let function = unsafe {
1434
1434
/// std::mem::transmute::<*const (), fn() -> i32>(pointer)
1435
1435
/// };
Original file line number Diff line number Diff line change @@ -325,6 +325,7 @@ pub(crate) unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
325
325
// In any case, we basically need to do something like this until we can
326
326
// express more operations in statics (and we may never be able to).
327
327
unsafe {
328
+ #[ allow( function_casts_as_integer) ]
328
329
atomic_store_seqcst (
329
330
( & raw mut THROW_INFO . pmfnUnwind ) . cast ( ) ,
330
331
ptr_t:: new ( exception_cleanup as * mut u8 ) . raw ( ) ,
@@ -341,6 +342,7 @@ pub(crate) unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
341
342
( & raw mut CATCHABLE_TYPE . pType ) . cast ( ) ,
342
343
ptr_t:: new ( ( & raw mut TYPE_DESCRIPTOR ) . cast ( ) ) . raw ( ) ,
343
344
) ;
345
+ #[ allow( function_casts_as_integer) ]
344
346
atomic_store_seqcst (
345
347
( & raw mut CATCHABLE_TYPE . copyFunction ) . cast ( ) ,
346
348
ptr_t:: new ( exception_copy as * mut u8 ) . raw ( ) ,
Original file line number Diff line number Diff line change @@ -293,7 +293,7 @@ impl Backtrace {
293
293
if !Backtrace :: enabled ( ) {
294
294
return Backtrace { inner : Inner :: Disabled } ;
295
295
}
296
- Backtrace :: create ( Backtrace :: capture as usize )
296
+ Backtrace :: create ( Backtrace :: capture as fn ( ) -> Backtrace as usize )
297
297
}
298
298
299
299
/// Forcibly captures a full backtrace, regardless of environment variable
@@ -309,7 +309,7 @@ impl Backtrace {
309
309
#[ stable( feature = "backtrace" , since = "1.65.0" ) ]
310
310
#[ inline( never) ] // want to make sure there's a frame here to remove
311
311
pub fn force_capture ( ) -> Backtrace {
312
- Backtrace :: create ( Backtrace :: force_capture as usize )
312
+ Backtrace :: create ( Backtrace :: force_capture as fn ( ) -> Backtrace as usize )
313
313
}
314
314
315
315
/// Forcibly captures a disabled backtrace, regardless of environment
Original file line number Diff line number Diff line change @@ -169,7 +169,9 @@ mod imp {
169
169
}
170
170
171
171
action. sa_flags = SA_SIGINFO | SA_ONSTACK ;
172
- action. sa_sigaction = signal_handler as sighandler_t ;
172
+ action. sa_sigaction = signal_handler
173
+ as unsafe extern "C" fn ( i32 , * mut libc:: siginfo_t , * mut libc:: c_void )
174
+ as sighandler_t ;
173
175
// SAFETY: only overriding signals if the default is set
174
176
unsafe { sigaction ( signal, & action, ptr:: null_mut ( ) ) } ;
175
177
}
Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ macro_rules! compat_fn_with_fallback {
155
155
/// When that is called it attempts to load the requested symbol.
156
156
/// If it succeeds, `PTR` is set to the address of that symbol.
157
157
/// If it fails, then `PTR` is set to `fallback`.
158
- static PTR : Atomic <* mut c_void> = AtomicPtr :: new( load as * mut _) ;
158
+ static PTR : Atomic <* mut c_void> = AtomicPtr :: new( load as unsafe extern "system" fn ( $ ( $argname : $argtype ) , * ) -> $rettype as * mut _) ;
159
159
160
160
unsafe extern "system" fn load( $( $argname: $argtype) ,* ) -> $rettype {
161
161
unsafe {
@@ -171,7 +171,7 @@ macro_rules! compat_fn_with_fallback {
171
171
PTR . store( f. as_ptr( ) , Ordering :: Relaxed ) ;
172
172
mem:: transmute( f)
173
173
} else {
174
- PTR . store( fallback as * mut _, Ordering :: Relaxed ) ;
174
+ PTR . store( fallback as unsafe extern "system" fn ( $ ( $argname : $argtype ) , * ) -> $rettype as * mut _, Ordering :: Relaxed ) ;
175
175
fallback
176
176
}
177
177
}
You can’t perform that action at this time.
0 commit comments