diff options
| author | Luqman Aden <me@luqman.ca> | 2022-05-16 21:46:20 -0700 |
|---|---|---|
| committer | Luqman Aden <me@luqman.ca> | 2022-05-18 13:42:23 -0700 |
| commit | f45f8262078bde0435560a1e17fb749d0f46dc30 (patch) | |
| tree | 81baba0e6226a36aebcb7fa3983c0f0b9bb601cc /compiler/rustc_mir_transform/src | |
| parent | c1cfdd1fb225d64e78b8d8cbab83564ac2dd5ec2 (diff) | |
| download | rust-f45f8262078bde0435560a1e17fb749d0f46dc30.tar.gz rust-f45f8262078bde0435560a1e17fb749d0f46dc30.zip | |
Update MIR passes that assumed inline can never unwind.
Diffstat (limited to 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/abort_unwinding_calls.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_mir_transform/src/generator.rs | 4 |
2 files changed, 9 insertions, 2 deletions
diff --git a/compiler/rustc_mir_transform/src/abort_unwinding_calls.rs b/compiler/rustc_mir_transform/src/abort_unwinding_calls.rs index ade6555f4d2..11980382ffd 100644 --- a/compiler/rustc_mir_transform/src/abort_unwinding_calls.rs +++ b/compiler/rustc_mir_transform/src/abort_unwinding_calls.rs @@ -1,4 +1,5 @@ use crate::MirPass; +use rustc_ast::InlineAsmOptions; use rustc_hir::def::DefKind; use rustc_middle::mir::*; use rustc_middle::ty::layout; @@ -85,6 +86,12 @@ impl<'tcx> MirPass<'tcx> for AbortUnwindingCalls { TerminatorKind::Assert { .. } | TerminatorKind::FalseUnwind { .. } => { layout::fn_can_unwind(tcx, None, Abi::Rust) } + TerminatorKind::InlineAsm { options, .. } => { + options.contains(InlineAsmOptions::MAY_UNWIND) + } + _ if terminator.unwind().is_some() => { + span_bug!(span, "unexpected terminator that may unwind {:?}", terminator) + } _ => continue, }; diff --git a/compiler/rustc_mir_transform/src/generator.rs b/compiler/rustc_mir_transform/src/generator.rs index b7dec57b757..9e7bf5c7929 100644 --- a/compiler/rustc_mir_transform/src/generator.rs +++ b/compiler/rustc_mir_transform/src/generator.rs @@ -1042,8 +1042,7 @@ fn can_unwind<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) -> bool { | TerminatorKind::Unreachable | TerminatorKind::GeneratorDrop | TerminatorKind::FalseEdge { .. } - | TerminatorKind::FalseUnwind { .. } - | TerminatorKind::InlineAsm { .. } => {} + | TerminatorKind::FalseUnwind { .. } => {} // Resume will *continue* unwinding, but if there's no other unwinding terminator it // will never be reached. @@ -1057,6 +1056,7 @@ fn can_unwind<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) -> bool { TerminatorKind::Drop { .. } | TerminatorKind::DropAndReplace { .. } | TerminatorKind::Call { .. } + | TerminatorKind::InlineAsm { .. } | TerminatorKind::Assert { .. } => return true, } } |
