Skip to content

Commit a010652

Browse files
committed
fix #[unwind(abort)] for Rust ABIs
1 parent 152527f commit a010652

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/librustc_mir/build/mod.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -502,24 +502,21 @@ macro_rules! unpack {
502502
};
503503
}
504504

505-
fn should_abort_on_panic(tcx: TyCtxt<'_>, fn_def_id: DefId, abi: Abi) -> bool {
506-
// Not callable from C, so we can safely unwind through these
507-
if abi == Abi::Rust || abi == Abi::RustCall { return false; }
508-
509-
// Validate `#[unwind]` syntax regardless of platform-specific panic strategy
505+
fn should_abort_on_panic(tcx: TyCtxt<'_>, fn_def_id: DefId, _abi: Abi) -> bool {
506+
// Validate `#[unwind]` syntax regardless of platform-specific panic strategy.
510507
let attrs = &tcx.get_attrs(fn_def_id);
511508
let unwind_attr = attr::find_unwind_attr(Some(tcx.sess.diagnostic()), attrs);
512509

513-
// We never unwind, so it's not relevant to stop an unwind
510+
// We never unwind, so it's not relevant to stop an unwind.
514511
if tcx.sess.panic_strategy() != PanicStrategy::Unwind { return false; }
515512

516-
// We cannot add landing pads, so don't add one
513+
// We cannot add landing pads, so don't add one.
517514
if tcx.sess.no_landing_pads() { return false; }
518515

519516
// This is a special case: some functions have a C abi but are meant to
520517
// unwind anyway. Don't stop them.
521518
match unwind_attr {
522-
None => false, // FIXME(#58794)
519+
None => false, // FIXME(#58794); should be `!(abi == Abi::Rust || abi == Abi::RustCall)`
523520
Some(UnwindAttr::Allowed) => false,
524521
Some(UnwindAttr::Aborts) => true,
525522
}

0 commit comments

Comments
 (0)