File tree 1 file changed +14
-6
lines changed
1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -76,12 +76,20 @@ pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
76
76
}
77
77
ptr:: write ( exception, Exception { data : Some ( data) } ) ;
78
78
__cxa_throw ( exception as * mut _ , & EXCEPTION_TYPE_INFO , exception_cleanup) ;
79
+ }
79
80
80
- extern "C" fn exception_cleanup ( ptr : * mut libc:: c_void ) {
81
- unsafe {
82
- ptr:: drop_in_place ( ptr as * mut Exception ) ;
83
- super :: __rust_drop_panic ( ) ;
84
- }
81
+ // On WASM and ARM, the destructor returns the pointer to the object.
82
+ cfg_if:: cfg_if! {
83
+ if #[ cfg( any( target_arch = "arm" , target_arch = "wasm32" ) ) ] {
84
+ type DestructorRet = * mut libc:: c_void;
85
+ } else {
86
+ type DestructorRet = ( ) ;
87
+ }
88
+ }
89
+ extern "C" fn exception_cleanup ( ptr : * mut libc:: c_void ) -> DestructorRet {
90
+ unsafe {
91
+ ptr:: drop_in_place ( ptr as * mut Exception ) ;
92
+ super :: __rust_drop_panic ( ) ;
85
93
}
86
94
}
87
95
@@ -104,7 +112,7 @@ extern "C" {
104
112
fn __cxa_throw (
105
113
thrown_exception : * mut libc:: c_void ,
106
114
tinfo : * const TypeInfo ,
107
- dest : extern "C" fn ( * mut libc:: c_void ) ,
115
+ dest : extern "C" fn ( * mut libc:: c_void ) -> DestructorRet ,
108
116
) -> !;
109
117
fn __gxx_personality_v0 (
110
118
version : c_int ,
You can’t perform that action at this time.
0 commit comments