Skip to content
Permalink
Browse files

Validate `#[unwind]` syntax regardless of platform-specific panic str…

…ategy
  • Loading branch information...
petrochenkov committed Feb 27, 2019
1 parent b11502f commit dc00a8adee77f04a450e2f02be97b4e308af863e
Showing with 5 additions and 2 deletions.
  1. +5 −2 src/librustc_mir/build/mod.rs
@@ -581,6 +581,10 @@ fn should_abort_on_panic<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
// Not callable from C, so we can safely unwind through these
if abi == Abi::Rust || abi == Abi::RustCall { return false; }

// Validate `#[unwind]` syntax regardless of platform-specific panic strategy
let attrs = &tcx.get_attrs(fn_def_id);
let unwind_attr = attr::find_unwind_attr(Some(tcx.sess.diagnostic()), attrs);

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

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

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

0 comments on commit dc00a8a

Please sign in to comment.
You can’t perform that action at this time.