about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-02-27 09:36:49 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-02-27 09:37:06 +0300
commitdc00a8adee77f04a450e2f02be97b4e308af863e (patch)
tree33eb0233ca3caefb06868531c7d4523bbc27027e
parentb11502fbc0cfc251c1b96743562761c9a451d84a (diff)
downloadrust-dc00a8adee77f04a450e2f02be97b4e308af863e.tar.gz
rust-dc00a8adee77f04a450e2f02be97b4e308af863e.zip
Validate `#[unwind]` syntax regardless of platform-specific panic strategy
-rw-r--r--src/librustc_mir/build/mod.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs
index 19507c900da..39c84b95f8f 100644
--- a/src/librustc_mir/build/mod.rs
+++ b/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,