@@ -16,7 +16,7 @@ use rustc_macros::{HashStable, TyDecodable, TyEncodable, extension};
16
16
use rustc_session:: config:: OptLevel ;
17
17
use rustc_span:: { DUMMY_SP , ErrorGuaranteed , Span , Symbol , sym} ;
18
18
use rustc_target:: callconv:: FnAbi ;
19
- use rustc_target:: spec:: { HasTargetSpec , HasX86AbiOpt , PanicStrategy , Target , X86Abi } ;
19
+ use rustc_target:: spec:: { HasTargetSpec , HasX86AbiOpt , Target , X86Abi } ;
20
20
use tracing:: debug;
21
21
use { rustc_abi as abi, rustc_hir as hir} ;
22
22
@@ -1193,20 +1193,16 @@ pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option<DefId>, abi: ExternAbi)
1193
1193
//
1194
1194
// Note that this is true regardless ABI specified on the function -- a `extern "C-unwind"`
1195
1195
// function defined in Rust is also required to abort.
1196
- if matches ! ( tcx. sess. panic_strategy( ) , PanicStrategy :: Abort | PanicStrategy :: ImmediateAbort )
1197
- && !tcx. is_foreign_item ( did)
1198
- {
1196
+ if !tcx. sess . panic_strategy ( ) . unwinds ( ) && !tcx. is_foreign_item ( did) {
1199
1197
return false ;
1200
1198
}
1201
1199
1202
1200
// With -Z panic-in-drop=abort, drop_in_place never unwinds.
1203
1201
//
1204
1202
// This is not part of `codegen_fn_attrs` as it can differ between crates
1205
1203
// and therefore cannot be computed in core.
1206
- if matches ! (
1207
- tcx. sess. opts. unstable_opts. panic_in_drop,
1208
- PanicStrategy :: Abort | PanicStrategy :: ImmediateAbort
1209
- ) && tcx. is_lang_item ( did, LangItem :: DropInPlace )
1204
+ if !tcx. sess . opts . unstable_opts . panic_in_drop . unwinds ( )
1205
+ && tcx. is_lang_item ( did, LangItem :: DropInPlace )
1210
1206
{
1211
1207
return false ;
1212
1208
}
@@ -1244,7 +1240,7 @@ pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option<DefId>, abi: ExternAbi)
1244
1240
| RiscvInterruptS
1245
1241
| RustInvalid
1246
1242
| Unadjusted => false ,
1247
- Rust | RustCall | RustCold => tcx. sess . panic_strategy ( ) == PanicStrategy :: Unwind ,
1243
+ Rust | RustCall | RustCold => tcx. sess . panic_strategy ( ) . unwinds ( ) ,
1248
1244
}
1249
1245
}
1250
1246
0 commit comments