1 use rustc_middle::mir::{Body, TerminatorKind};
2 use rustc_middle::ty::TyCtxt;
6 /// Removes `FalseEdge` and `FalseUnwind` terminators from the MIR.
8 /// These are only needed for borrow checking, and can be removed afterwards.
10 /// FIXME: This should probably have its own MIR phase.
11 pub struct RemoveFalseEdges;
13 impl<'tcx> MirPass<'tcx> for RemoveFalseEdges {
14 fn run_pass(&self, _: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
15 for block in body.basic_blocks_mut() {
16 let terminator = block.terminator_mut();
17 terminator.kind = match terminator.kind {
18 TerminatorKind::FalseEdge { real_target, .. } => {
19 TerminatorKind::Goto { target: real_target }
21 TerminatorKind::FalseUnwind { real_target, .. } => {
22 TerminatorKind::Goto { target: real_target }