Skip to content

Commit 575327b

Browse files
committed
Tweak block management
1 parent 374b3d8 commit 575327b

File tree

1 file changed

+6
-4
lines changed
  • compiler/rustc_mir_build/src/build/matches

1 file changed

+6
-4
lines changed

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

+6-4
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
14211421
span: Span,
14221422
scrutinee_span: Span,
14231423
candidates: &mut [&mut Candidate<'_, 'tcx>],
1424-
block: BasicBlock,
1424+
start_block: BasicBlock,
14251425
otherwise_block: BasicBlock,
14261426
fake_borrows: &mut Option<FxIndexSet<Place<'tcx>>>,
14271427
) {
@@ -1431,7 +1431,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
14311431
span,
14321432
scrutinee_span,
14331433
candidates,
1434-
block,
1434+
start_block,
14351435
otherwise_block,
14361436
fake_borrows,
14371437
);
@@ -1442,12 +1442,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
14421442
let (first_match_pair, remaining_match_pairs) = match_pairs.split_first().unwrap();
14431443
let PatKind::Or { ref pats } = &first_match_pair.pattern.kind else { unreachable!() };
14441444

1445-
first_candidate.pre_binding_block = Some(block);
14461445
let remainder_start = self.cfg.start_new_block();
14471446
let or_span = first_match_pair.pattern.span;
14481447
// Test the alternatives of this or-pattern.
14491448
self.test_or_pattern(
14501449
first_candidate,
1450+
start_block,
14511451
remainder_start,
14521452
pats,
14531453
or_span,
@@ -1493,6 +1493,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
14931493
fn test_or_pattern<'pat>(
14941494
&mut self,
14951495
candidate: &mut Candidate<'pat, 'tcx>,
1496+
start_block: BasicBlock,
14961497
otherwise: BasicBlock,
14971498
pats: &'pat [Box<Pat<'tcx>>],
14981499
or_span: Span,
@@ -1513,11 +1514,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
15131514
self.match_candidates(
15141515
or_span,
15151516
or_span,
1516-
candidate.pre_binding_block.unwrap(),
1517+
start_block,
15171518
otherwise,
15181519
&mut or_candidate_refs,
15191520
fake_borrows,
15201521
);
1522+
candidate.pre_binding_block = Some(start_block);
15211523
candidate.subcandidates = or_candidates;
15221524
self.merge_trivial_subcandidates(candidate, self.source_info(or_span));
15231525
}

0 commit comments

Comments
 (0)