Skip to content

Commit 0168dfe

Browse files
committed
Use predefined helper instead of a new one
1 parent 30bc5a9 commit 0168dfe

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

compiler/rustc_mir/src/transform/abort_unwinding_calls.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -125,28 +125,17 @@ impl<'tcx> MirPass<'tcx> for AbortUnwindingCalls {
125125
let abort_bb = body.basic_blocks_mut().push(bb);
126126

127127
for bb in calls_to_terminate {
128-
let cleanup = get_cleanup(body.basic_blocks_mut()[bb].terminator_mut());
128+
let cleanup = body.basic_blocks_mut()[bb].terminator_mut().unwind_mut().unwrap();
129129
*cleanup = Some(abort_bb);
130130
}
131131
}
132132

133133
for id in cleanups_to_remove {
134-
let cleanup = get_cleanup(body.basic_blocks_mut()[id].terminator_mut());
134+
let cleanup = body.basic_blocks_mut()[id].terminator_mut().unwind_mut().unwrap();
135135
*cleanup = None;
136136
}
137137

138138
// We may have invalidated some `cleanup` blocks so clean those up now.
139139
super::simplify::remove_dead_blocks(tcx, body);
140140
}
141141
}
142-
143-
fn get_cleanup<'a>(t: &'a mut Terminator<'_>) -> &'a mut Option<BasicBlock> {
144-
match &mut t.kind {
145-
TerminatorKind::Call { cleanup, .. }
146-
| TerminatorKind::Drop { unwind: cleanup, .. }
147-
| TerminatorKind::DropAndReplace { unwind: cleanup, .. }
148-
| TerminatorKind::Assert { cleanup, .. }
149-
| TerminatorKind::FalseUnwind { unwind: cleanup, .. } => cleanup,
150-
_ => unreachable!(),
151-
}
152-
}

0 commit comments

Comments
 (0)