File tree 4 files changed +10
-15
lines changed
4 files changed +10
-15
lines changed Original file line number Diff line number Diff line change @@ -15,15 +15,15 @@ type SetAbortMessageType = unsafe extern "C" fn(*const libc::c_char) -> ();
15
15
//
16
16
// Weakly resolve the symbol for android_set_abort_message. This function is only available
17
17
// for API >= 21.
18
- pub ( crate ) unsafe fn android_set_abort_message ( payload : * mut & mut dyn BoxMeUp ) {
18
+ pub ( crate ) unsafe fn android_set_abort_message ( payload : & mut dyn BoxMeUp ) {
19
19
let func_addr =
20
20
libc:: dlsym ( libc:: RTLD_DEFAULT , ANDROID_SET_ABORT_MESSAGE . as_ptr ( ) as * const libc:: c_char )
21
21
as usize ;
22
22
if func_addr == 0 {
23
23
return ;
24
24
}
25
25
26
- let payload = ( * payload) . get ( ) ;
26
+ let payload = payload. get ( ) ;
27
27
let msg = match payload. downcast_ref :: < & ' static str > ( ) {
28
28
Some ( msg) => msg. as_bytes ( ) ,
29
29
None => match payload. downcast_ref :: < String > ( ) {
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ pub unsafe extern "C" fn __rust_panic_cleanup(_: *mut u8) -> *mut (dyn Any + Sen
29
29
30
30
// "Leak" the payload and shim to the relevant abort on the platform in question.
31
31
#[ rustc_std_internal_symbol]
32
- pub unsafe fn __rust_start_panic ( _payload : * mut & mut dyn BoxMeUp ) -> u32 {
32
+ pub unsafe fn __rust_start_panic ( _payload : & mut dyn BoxMeUp ) -> u32 {
33
33
// Android has the ability to attach a message as part of the abort.
34
34
#[ cfg( target_os = "android" ) ]
35
35
android:: android_set_abort_message ( _payload) ;
Original file line number Diff line number Diff line change @@ -99,8 +99,8 @@ pub unsafe extern "C" fn __rust_panic_cleanup(payload: *mut u8) -> *mut (dyn Any
99
99
// Entry point for raising an exception, just delegates to the platform-specific
100
100
// implementation.
101
101
#[ rustc_std_internal_symbol]
102
- pub unsafe fn __rust_start_panic ( payload : * mut & mut dyn BoxMeUp ) -> u32 {
103
- let payload = Box :: from_raw ( ( * payload) . take_box ( ) ) ;
102
+ pub unsafe fn __rust_start_panic ( payload : & mut dyn BoxMeUp ) -> u32 {
103
+ let payload = Box :: from_raw ( payload. take_box ( ) ) ;
104
104
105
105
imp:: panic ( payload)
106
106
}
Original file line number Diff line number Diff line change @@ -46,12 +46,10 @@ extern "C" {
46
46
fn __rust_panic_cleanup ( payload : * mut u8 ) -> * mut ( dyn Any + Send + ' static ) ;
47
47
}
48
48
49
- #[ allow( improper_ctypes) ]
50
49
extern "Rust" {
51
- /// `payload` is passed through another layer of raw pointers as `&mut dyn Trait` is not
52
- /// FFI-safe. `BoxMeUp` lazily performs allocation only when needed (this avoids allocations
53
- /// when using the "abort" panic runtime).
54
- fn __rust_start_panic ( payload : * mut & mut dyn BoxMeUp ) -> u32 ;
50
+ /// `BoxMeUp` lazily performs allocation only when needed (this avoids
51
+ /// allocations when using the "abort" panic runtime).
52
+ fn __rust_start_panic ( payload : & mut dyn BoxMeUp ) -> u32 ;
55
53
}
56
54
57
55
/// This function is called by the panic runtime if FFI code catches a Rust
@@ -738,10 +736,7 @@ pub fn rust_panic_without_hook(payload: Box<dyn Any + Send>) -> ! {
738
736
/// yer breakpoints.
739
737
#[ inline( never) ]
740
738
#[ cfg_attr( not( test) , rustc_std_internal_symbol) ]
741
- fn rust_panic ( mut msg : & mut dyn BoxMeUp ) -> ! {
742
- let code = unsafe {
743
- let obj = & mut msg as * mut & mut dyn BoxMeUp ;
744
- __rust_start_panic ( obj)
745
- } ;
739
+ fn rust_panic ( msg : & mut dyn BoxMeUp ) -> ! {
740
+ let code = unsafe { __rust_start_panic ( msg) } ;
746
741
rtabort ! ( "failed to initiate panic, error {code}" )
747
742
}
You can’t perform that action at this time.
0 commit comments