Skip to content

Commit a6960c8

Browse files
committed
Use try block
1 parent 4f5226a commit a6960c8

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

compiler/rustc_mir/src/transform/const_goto.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl<'tcx> MirPass<'tcx> for ConstGoto {
5252

5353
impl<'a, 'tcx> Visitor<'tcx> for ConstGotoOptimizationFinder<'a, 'tcx> {
5454
fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) {
55-
let mut bailer = || {
55+
let _:Option<_> = try {
5656
match terminator.kind {
5757
TerminatorKind::Goto { target } => {
5858
// We only apply this optimization if the last statement is a const assignment
@@ -66,7 +66,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ConstGotoOptimizationFinder<'a, 'tcx> {
6666
// Now check that the target of this Goto switches on this place.
6767
let target_bb = &self.body.basic_blocks()[target];
6868
if !target_bb.statements.is_empty() {
69-
return None;
69+
None?
7070
}
7171

7272
let target_bb_terminator = target_bb.terminator();
@@ -108,9 +108,8 @@ impl<'a, 'tcx> Visitor<'tcx> for ConstGotoOptimizationFinder<'a, 'tcx> {
108108
}
109109
_ => {}
110110
}
111-
return Some(());
111+
Some(())
112112
};
113-
let _ = bailer();
114113

115114
self.super_terminator(terminator, location);
116115
}

0 commit comments

Comments
 (0)