Treat drop_in_place as nounwind with -Z panic-in-drop=abort
The AbortUnwindCalls MIR pass will eliminate any unnecessary cleanups and will prevent any unwinds from leaking out by forcing an abort.
This commit is contained in:
parent
c1bcf5c548
commit
8c7a05a23f
2 changed files with 14 additions and 5 deletions
|
@ -5,6 +5,7 @@ use rustc_middle::mir::*;
|
|||
use rustc_middle::ty::layout;
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_target::spec::abi::Abi;
|
||||
use rustc_target::spec::PanicStrategy;
|
||||
|
||||
/// A pass that runs which is targeted at ensuring that codegen guarantees about
|
||||
/// unwinding are upheld for compilations of panic=abort programs.
|
||||
|
@ -82,10 +83,11 @@ impl<'tcx> MirPass<'tcx> for AbortUnwindingCalls {
|
|||
};
|
||||
layout::fn_can_unwind(tcx, flags, sig.abi())
|
||||
}
|
||||
TerminatorKind::Drop { .. }
|
||||
| TerminatorKind::DropAndReplace { .. }
|
||||
| TerminatorKind::Assert { .. }
|
||||
| TerminatorKind::FalseUnwind { .. } => {
|
||||
TerminatorKind::Drop { .. } | TerminatorKind::DropAndReplace { .. } => {
|
||||
tcx.sess.opts.debugging_opts.panic_in_drop == PanicStrategy::Unwind
|
||||
&& layout::fn_can_unwind(tcx, CodegenFnAttrFlags::empty(), Abi::Rust)
|
||||
}
|
||||
TerminatorKind::Assert { .. } | TerminatorKind::FalseUnwind { .. } => {
|
||||
layout::fn_can_unwind(tcx, CodegenFnAttrFlags::empty(), Abi::Rust)
|
||||
}
|
||||
_ => continue,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue