Skip to content

Commit 18d0007

Browse files
committed
Update more use sites of PanicStrategy::Abort
1 parent ccb0ff5 commit 18d0007

File tree

7 files changed

+16
-9
lines changed

7 files changed

+16
-9
lines changed

compiler/rustc_codegen_gcc/src/intrinsic/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,7 @@ fn try_intrinsic<'a, 'b, 'gcc, 'tcx>(
13391339
_catch_func: RValue<'gcc>,
13401340
dest: PlaceRef<'tcx, RValue<'gcc>>,
13411341
) {
1342-
if bx.sess().panic_strategy() == PanicStrategy::Abort {
1342+
if matches!(bx.sess().panic_strategy(), PanicStrategy::Abort | PanicStrategy::ImmediateAbort) {
13431343
bx.call(bx.type_void(), None, None, try_func, &[data], None, None);
13441344
// Return 0 unconditionally from the intrinsic call;
13451345
// we can never unwind.

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ fn catch_unwind_intrinsic<'ll, 'tcx>(
674674
catch_func: &'ll Value,
675675
dest: PlaceRef<'tcx, &'ll Value>,
676676
) {
677-
if bx.sess().panic_strategy() == PanicStrategy::Abort {
677+
if matches!(bx.sess().panic_strategy(), PanicStrategy::Abort | PanicStrategy::ImmediateAbort) {
678678
let try_func_ty = bx.type_func(&[bx.type_ptr()], bx.type_void());
679679
bx.call(try_func_ty, None, None, try_func, &[data], None, None);
680680
// Return 0 unconditionally from the intrinsic call;

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2512,7 +2512,10 @@ fn add_order_independent_options(
25122512
if sess.target.os == "emscripten" {
25132513
cmd.cc_arg(if sess.opts.unstable_opts.emscripten_wasm_eh {
25142514
"-fwasm-exceptions"
2515-
} else if sess.panic_strategy() == PanicStrategy::Abort {
2515+
} else if matches!(
2516+
sess.panic_strategy(),
2517+
PanicStrategy::Abort | PanicStrategy::ImmediateAbort
2518+
) {
25162519
"-sDISABLE_EXCEPTION_CATCHING=1"
25172520
} else {
25182521
"-sDISABLE_EXCEPTION_CATCHING=0"

compiler/rustc_interface/src/passes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ fn configure_and_expand(
272272
feature_err(sess, sym::export_stable, DUMMY_SP, "`sdylib` crate type is unstable").emit();
273273
}
274274

275-
if is_proc_macro_crate && sess.panic_strategy() == PanicStrategy::Abort {
275+
if is_proc_macro_crate && sess.panic_strategy() != PanicStrategy::Unwind {
276276
sess.dcx().emit_warn(errors::ProcMacroCratePanicAbort);
277277
}
278278

compiler/rustc_middle/src/ty/layout.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,16 +1193,20 @@ pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option<DefId>, abi: ExternAbi)
11931193
//
11941194
// Note that this is true regardless ABI specified on the function -- a `extern "C-unwind"`
11951195
// function defined in Rust is also required to abort.
1196-
if tcx.sess.panic_strategy() == PanicStrategy::Abort && !tcx.is_foreign_item(did) {
1196+
if matches!(tcx.sess.panic_strategy(), PanicStrategy::Abort | PanicStrategy::ImmediateAbort)
1197+
&& !tcx.is_foreign_item(did)
1198+
{
11971199
return false;
11981200
}
11991201

12001202
// With -Z panic-in-drop=abort, drop_in_place never unwinds.
12011203
//
12021204
// This is not part of `codegen_fn_attrs` as it can differ between crates
12031205
// and therefore cannot be computed in core.
1204-
if tcx.sess.opts.unstable_opts.panic_in_drop == PanicStrategy::Abort
1205-
&& tcx.is_lang_item(did, LangItem::DropInPlace)
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)
12061210
{
12071211
return false;
12081212
}

compiler/rustc_mir_transform/src/coroutine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ fn can_return<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, typing_env: ty::Typing
11491149

11501150
fn can_unwind<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) -> bool {
11511151
// Nothing can unwind when landing pads are off.
1152-
if tcx.sess.panic_strategy() == PanicStrategy::Abort {
1152+
if matches!(tcx.sess.panic_strategy(), PanicStrategy::Abort | PanicStrategy::ImmediateAbort) {
11531153
return false;
11541154
}
11551155

compiler/rustc_mir_transform/src/remove_noop_landing_pads.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub(super) struct RemoveNoopLandingPads;
1313

1414
impl<'tcx> crate::MirPass<'tcx> for RemoveNoopLandingPads {
1515
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
16-
sess.panic_strategy() != PanicStrategy::Abort
16+
!matches!(sess.panic_strategy(), PanicStrategy::Abort | PanicStrategy::ImmediateAbort)
1717
}
1818

1919
fn run_pass(&self, _tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {

0 commit comments

Comments
 (0)