1 //! This pass removes the unwind branch of all the terminators when the no-landing-pads option is
6 use rustc::mir::visit::MutVisitor;
7 use crate::transform::{MirPass, MirSource};
9 pub struct NoLandingPads;
11 impl MirPass for NoLandingPads {
12 fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx, 'tcx>, _: MirSource<'tcx>, body: &mut Body<'tcx>) {
13 no_landing_pads(tcx, body)
17 pub fn no_landing_pads<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, body: &mut Body<'tcx>) {
18 if tcx.sess.no_landing_pads() {
19 NoLandingPads.visit_body(body);
23 impl<'tcx> MutVisitor<'tcx> for NoLandingPads {
24 fn visit_terminator_kind(&mut self,
25 kind: &mut TerminatorKind<'tcx>,
27 if let Some(unwind) = kind.unwind_mut() {
30 self.super_terminator_kind(kind, location);