Skip to content

Commit 105bdf7

Browse files
committed
Reuse next_prebinding
The moment we get a candidate without guard, the return block becomes a fresh block linked to nothing. So we can keep assigning a fresh block every iteration to reuse the `next_prebinding` logic.
1 parent a11abc6 commit 105bdf7

File tree

1 file changed

+3
-8
lines changed
  • compiler/rustc_mir_build/src/build/matches

1 file changed

+3
-8
lines changed

compiler/rustc_mir_build/src/build/matches/mod.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,29 +1315,24 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
13151315

13161316
let mut next_prebinding = start_block;
13171317
let mut reachable = true;
1318-
let mut return_block = None;
13191318

13201319
for candidate in matched_candidates.iter_mut() {
13211320
assert!(candidate.otherwise_block.is_none());
13221321
assert!(candidate.pre_binding_block.is_none());
1322+
candidate.pre_binding_block = Some(next_prebinding);
1323+
next_prebinding = self.cfg.start_new_block();
13231324
if reachable {
1324-
candidate.pre_binding_block = Some(next_prebinding);
13251325
if candidate.has_guard {
13261326
// Create the otherwise block for this candidate, which is the
13271327
// pre-binding block for the next candidate.
1328-
next_prebinding = self.cfg.start_new_block();
13291328
candidate.otherwise_block = Some(next_prebinding);
1330-
return_block = Some(next_prebinding);
13311329
} else {
13321330
reachable = false;
1333-
return_block = Some(self.cfg.start_new_block());
13341331
}
1335-
} else {
1336-
candidate.pre_binding_block = Some(self.cfg.start_new_block());
13371332
}
13381333
}
13391334

1340-
return_block.unwrap()
1335+
next_prebinding
13411336
}
13421337

13431338
/// Tests a candidate where there are only or-patterns left to test, or

0 commit comments

Comments
 (0)