Skip to content

Commit dc00a8a

Browse files
committed
Validate #[unwind] syntax regardless of platform-specific panic strategy
1 parent b11502f commit dc00a8a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Diff for: src/librustc_mir/build/mod.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,10 @@ fn should_abort_on_panic<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
581581
// Not callable from C, so we can safely unwind through these
582582
if abi == Abi::Rust || abi == Abi::RustCall { return false; }
583583

584+
// Validate `#[unwind]` syntax regardless of platform-specific panic strategy
585+
let attrs = &tcx.get_attrs(fn_def_id);
586+
let unwind_attr = attr::find_unwind_attr(Some(tcx.sess.diagnostic()), attrs);
587+
584588
// We never unwind, so it's not relevant to stop an unwind
585589
if tcx.sess.panic_strategy() != PanicStrategy::Unwind { return false; }
586590

@@ -589,8 +593,7 @@ fn should_abort_on_panic<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
589593

590594
// This is a special case: some functions have a C abi but are meant to
591595
// unwind anyway. Don't stop them.
592-
let attrs = &tcx.get_attrs(fn_def_id);
593-
match attr::find_unwind_attr(Some(tcx.sess.diagnostic()), attrs) {
596+
match unwind_attr {
594597
None => true,
595598
Some(UnwindAttr::Allowed) => false,
596599
Some(UnwindAttr::Aborts) => true,

0 commit comments

Comments
 (0)