1 //! This pass removes the unwind branch of all the terminators when the no-landing-pads option is
4 use crate::transform::MirPass;
5 use rustc_middle::mir::*;
6 use rustc_middle::ty::TyCtxt;
7 use rustc_target::spec::PanicStrategy;
9 pub struct NoLandingPads;
11 impl<'tcx> MirPass<'tcx> for NoLandingPads {
12 fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
13 no_landing_pads(tcx, body)
17 pub fn no_landing_pads<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
18 if tcx.sess.panic_strategy() != PanicStrategy::Abort {
22 for block in body.basic_blocks_mut() {
23 let terminator = block.terminator_mut();
24 if let Some(unwind) = terminator.kind.unwind_mut() {