@@ -11,11 +11,9 @@ use rustc::middle::region;
11
11
use rustc:: mir:: * ;
12
12
use rustc:: ty:: { self , Ty , TyCtxt } ;
13
13
use rustc:: util:: nodemap:: HirIdMap ;
14
- use rustc_target:: spec:: PanicStrategy ;
15
14
use rustc_data_structures:: indexed_vec:: { IndexVec , Idx } ;
16
15
use std:: u32;
17
16
use rustc_target:: spec:: abi:: Abi ;
18
- use syntax:: attr:: { self , UnwindAttr } ;
19
17
use syntax:: symbol:: kw;
20
18
use syntax_pos:: Span ;
21
19
@@ -485,29 +483,6 @@ macro_rules! unpack {
485
483
} ;
486
484
}
487
485
488
- fn should_abort_on_panic ( tcx : TyCtxt < ' _ > , fn_def_id : DefId , abi : Abi ) -> bool {
489
- // Not callable from C, so we can safely unwind through these
490
- if abi == Abi :: Rust || abi == Abi :: RustCall { return false ; }
491
-
492
- // Validate `#[unwind]` syntax regardless of platform-specific panic strategy
493
- let attrs = & tcx. get_attrs ( fn_def_id) ;
494
- let unwind_attr = attr:: find_unwind_attr ( Some ( tcx. sess . diagnostic ( ) ) , attrs) ;
495
-
496
- // We never unwind, so it's not relevant to stop an unwind
497
- if tcx. sess . panic_strategy ( ) != PanicStrategy :: Unwind { return false ; }
498
-
499
- // We cannot add landing pads, so don't add one
500
- if tcx. sess . no_landing_pads ( ) { return false ; }
501
-
502
- // This is a special case: some functions have a C abi but are meant to
503
- // unwind anyway. Don't stop them.
504
- match unwind_attr {
505
- None => false , // FIXME(#58794)
506
- Some ( UnwindAttr :: Allowed ) => false ,
507
- Some ( UnwindAttr :: Aborts ) => true ,
508
- }
509
- }
510
-
511
486
///////////////////////////////////////////////////////////////////////////
512
487
/// the main entry point for building MIR for a function
513
488
@@ -599,7 +574,7 @@ where
599
574
let source_info = builder. source_info ( span) ;
600
575
let call_site_s = ( call_site_scope, source_info) ;
601
576
unpack ! ( block = builder. in_scope( call_site_s, LintLevel :: Inherited , |builder| {
602
- if should_abort_on_panic ( tcx, fn_def_id, abi) {
577
+ if tcx. abort_on_panic_shim ( fn_def_id, abi) {
603
578
builder. schedule_abort( ) ;
604
579
}
605
580
0 commit comments