Skip to content

Commit f45f826

Browse files
committed
Update MIR passes that assumed inline can never unwind.
1 parent c1cfdd1 commit f45f826

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

compiler/rustc_mir_transform/src/abort_unwinding_calls.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::MirPass;
2+
use rustc_ast::InlineAsmOptions;
23
use rustc_hir::def::DefKind;
34
use rustc_middle::mir::*;
45
use rustc_middle::ty::layout;
@@ -85,6 +86,12 @@ impl<'tcx> MirPass<'tcx> for AbortUnwindingCalls {
8586
TerminatorKind::Assert { .. } | TerminatorKind::FalseUnwind { .. } => {
8687
layout::fn_can_unwind(tcx, None, Abi::Rust)
8788
}
89+
TerminatorKind::InlineAsm { options, .. } => {
90+
options.contains(InlineAsmOptions::MAY_UNWIND)
91+
}
92+
_ if terminator.unwind().is_some() => {
93+
span_bug!(span, "unexpected terminator that may unwind {:?}", terminator)
94+
}
8895
_ => continue,
8996
};
9097

compiler/rustc_mir_transform/src/generator.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1042,8 +1042,7 @@ fn can_unwind<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) -> bool {
10421042
| TerminatorKind::Unreachable
10431043
| TerminatorKind::GeneratorDrop
10441044
| TerminatorKind::FalseEdge { .. }
1045-
| TerminatorKind::FalseUnwind { .. }
1046-
| TerminatorKind::InlineAsm { .. } => {}
1045+
| TerminatorKind::FalseUnwind { .. } => {}
10471046

10481047
// Resume will *continue* unwinding, but if there's no other unwinding terminator it
10491048
// will never be reached.
@@ -1057,6 +1056,7 @@ fn can_unwind<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) -> bool {
10571056
TerminatorKind::Drop { .. }
10581057
| TerminatorKind::DropAndReplace { .. }
10591058
| TerminatorKind::Call { .. }
1059+
| TerminatorKind::InlineAsm { .. }
10601060
| TerminatorKind::Assert { .. } => return true,
10611061
}
10621062
}

0 commit comments

Comments
 (0)