@@ -268,9 +268,11 @@ static mut TYPE_DESCRIPTOR: _TypeDescriptor = _TypeDescriptor {
268
268
macro_rules! define_cleanup {
269
269
( $abi: tt $abi2: tt) => {
270
270
unsafe extern $abi fn exception_cleanup( e: * mut Exception ) {
271
- if let Exception { data: Some ( b) , .. } = e. read( ) {
272
- drop( b) ;
273
- super :: __rust_drop_panic( ) ;
271
+ unsafe {
272
+ if let Exception { data: Some ( b) , .. } = e. read( ) {
273
+ drop( b) ;
274
+ super :: __rust_drop_panic( ) ;
275
+ }
274
276
}
275
277
}
276
278
unsafe extern $abi2 fn exception_copy(
@@ -322,45 +324,51 @@ pub(crate) unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
322
324
//
323
325
// In any case, we basically need to do something like this until we can
324
326
// express more operations in statics (and we may never be able to).
325
- atomic_store_seqcst (
326
- ( & raw mut THROW_INFO . pmfnUnwind ) . cast ( ) ,
327
- ptr_t:: new ( exception_cleanup as * mut u8 ) . raw ( ) ,
328
- ) ;
329
- atomic_store_seqcst (
330
- ( & raw mut THROW_INFO . pCatchableTypeArray ) . cast ( ) ,
331
- ptr_t:: new ( ( & raw mut CATCHABLE_TYPE_ARRAY ) . cast ( ) ) . raw ( ) ,
332
- ) ;
333
- atomic_store_seqcst (
334
- ( & raw mut CATCHABLE_TYPE_ARRAY . arrayOfCatchableTypes [ 0 ] ) . cast ( ) ,
335
- ptr_t:: new ( ( & raw mut CATCHABLE_TYPE ) . cast ( ) ) . raw ( ) ,
336
- ) ;
337
- atomic_store_seqcst (
338
- ( & raw mut CATCHABLE_TYPE . pType ) . cast ( ) ,
339
- ptr_t:: new ( ( & raw mut TYPE_DESCRIPTOR ) . cast ( ) ) . raw ( ) ,
340
- ) ;
341
- atomic_store_seqcst (
342
- ( & raw mut CATCHABLE_TYPE . copyFunction ) . cast ( ) ,
343
- ptr_t:: new ( exception_copy as * mut u8 ) . raw ( ) ,
344
- ) ;
327
+ unsafe {
328
+ atomic_store_seqcst (
329
+ ( & raw mut THROW_INFO . pmfnUnwind ) . cast ( ) ,
330
+ ptr_t:: new ( exception_cleanup as * mut u8 ) . raw ( ) ,
331
+ ) ;
332
+ atomic_store_seqcst (
333
+ ( & raw mut THROW_INFO . pCatchableTypeArray ) . cast ( ) ,
334
+ ptr_t:: new ( ( & raw mut CATCHABLE_TYPE_ARRAY ) . cast ( ) ) . raw ( ) ,
335
+ ) ;
336
+ atomic_store_seqcst (
337
+ ( & raw mut CATCHABLE_TYPE_ARRAY . arrayOfCatchableTypes [ 0 ] ) . cast ( ) ,
338
+ ptr_t:: new ( ( & raw mut CATCHABLE_TYPE ) . cast ( ) ) . raw ( ) ,
339
+ ) ;
340
+ atomic_store_seqcst (
341
+ ( & raw mut CATCHABLE_TYPE . pType ) . cast ( ) ,
342
+ ptr_t:: new ( ( & raw mut TYPE_DESCRIPTOR ) . cast ( ) ) . raw ( ) ,
343
+ ) ;
344
+ atomic_store_seqcst (
345
+ ( & raw mut CATCHABLE_TYPE . copyFunction ) . cast ( ) ,
346
+ ptr_t:: new ( exception_copy as * mut u8 ) . raw ( ) ,
347
+ ) ;
348
+ }
345
349
346
350
unsafe extern "system-unwind" {
347
351
fn _CxxThrowException ( pExceptionObject : * mut c_void , pThrowInfo : * mut u8 ) -> !;
348
352
}
349
353
350
- _CxxThrowException ( throw_ptr, ( & raw mut THROW_INFO ) as * mut _ ) ;
354
+ unsafe {
355
+ _CxxThrowException ( throw_ptr, ( & raw mut THROW_INFO ) as * mut _ ) ;
356
+ }
351
357
}
352
358
353
359
pub ( crate ) unsafe fn cleanup ( payload : * mut u8 ) -> Box < dyn Any + Send > {
354
- // A null payload here means that we got here from the catch (...) of
355
- // __rust_try. This happens when a non-Rust foreign exception is caught.
356
- if payload. is_null ( ) {
357
- super :: __rust_foreign_exception ( ) ;
358
- }
359
- let exception = payload as * mut Exception ;
360
- let canary = ( & raw const ( * exception) . canary ) . read ( ) ;
361
- if !core:: ptr:: eq ( canary, & raw const TYPE_DESCRIPTOR ) {
362
- // A foreign Rust exception.
363
- super :: __rust_foreign_exception ( ) ;
360
+ unsafe {
361
+ // A null payload here means that we got here from the catch (...) of
362
+ // __rust_try. This happens when a non-Rust foreign exception is caught.
363
+ if payload. is_null ( ) {
364
+ super :: __rust_foreign_exception ( ) ;
365
+ }
366
+ let exception = payload as * mut Exception ;
367
+ let canary = ( & raw const ( * exception) . canary ) . read ( ) ;
368
+ if !core:: ptr:: eq ( canary, & raw const TYPE_DESCRIPTOR ) {
369
+ // A foreign Rust exception.
370
+ super :: __rust_foreign_exception ( ) ;
371
+ }
372
+ ( * exception) . data . take ( ) . unwrap ( )
364
373
}
365
- ( * exception) . data . take ( ) . unwrap ( )
366
374
}
0 commit comments