Use predefined helper instead of a new one
This commit is contained in:
parent
30bc5a936b
commit
0168dfec6d
1 changed files with 2 additions and 13 deletions
|
@ -125,13 +125,13 @@ impl<'tcx> MirPass<'tcx> for AbortUnwindingCalls {
|
|||
let abort_bb = body.basic_blocks_mut().push(bb);
|
||||
|
||||
for bb in calls_to_terminate {
|
||||
let cleanup = get_cleanup(body.basic_blocks_mut()[bb].terminator_mut());
|
||||
let cleanup = body.basic_blocks_mut()[bb].terminator_mut().unwind_mut().unwrap();
|
||||
*cleanup = Some(abort_bb);
|
||||
}
|
||||
}
|
||||
|
||||
for id in cleanups_to_remove {
|
||||
let cleanup = get_cleanup(body.basic_blocks_mut()[id].terminator_mut());
|
||||
let cleanup = body.basic_blocks_mut()[id].terminator_mut().unwind_mut().unwrap();
|
||||
*cleanup = None;
|
||||
}
|
||||
|
||||
|
@ -139,14 +139,3 @@ impl<'tcx> MirPass<'tcx> for AbortUnwindingCalls {
|
|||
super::simplify::remove_dead_blocks(tcx, body);
|
||||
}
|
||||
}
|
||||
|
||||
fn get_cleanup<'a>(t: &'a mut Terminator<'_>) -> &'a mut Option<BasicBlock> {
|
||||
match &mut t.kind {
|
||||
TerminatorKind::Call { cleanup, .. }
|
||||
| TerminatorKind::Drop { unwind: cleanup, .. }
|
||||
| TerminatorKind::DropAndReplace { unwind: cleanup, .. }
|
||||
| TerminatorKind::Assert { cleanup, .. }
|
||||
| TerminatorKind::FalseUnwind { unwind: cleanup, .. } => cleanup,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue