@@ -1421,7 +1421,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1421
1421
span : Span ,
1422
1422
scrutinee_span : Span ,
1423
1423
candidates : & mut [ & mut Candidate < ' _ , ' tcx > ] ,
1424
- block : BasicBlock ,
1424
+ start_block : BasicBlock ,
1425
1425
otherwise_block : BasicBlock ,
1426
1426
fake_borrows : & mut Option < FxIndexSet < Place < ' tcx > > > ,
1427
1427
) {
@@ -1436,7 +1436,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1436
1436
span,
1437
1437
scrutinee_span,
1438
1438
candidates,
1439
- block ,
1439
+ start_block ,
1440
1440
otherwise_block,
1441
1441
fake_borrows,
1442
1442
) ;
@@ -1445,7 +1445,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1445
1445
}
1446
1446
1447
1447
let match_pairs = mem:: take ( & mut first_candidate. match_pairs ) ;
1448
- first_candidate. pre_binding_block = Some ( block) ;
1449
1448
1450
1449
let remainder_start = self . cfg . start_new_block ( ) ;
1451
1450
for match_pair in match_pairs {
@@ -1455,9 +1454,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1455
1454
let or_span = match_pair. pattern . span ;
1456
1455
1457
1456
first_candidate. visit_leaves ( |leaf_candidate| {
1457
+ let or_start = leaf_candidate. pre_binding_block . unwrap_or ( start_block) ;
1458
+ let or_otherwise = leaf_candidate. otherwise_block . unwrap_or ( remainder_start) ;
1458
1459
self . test_or_pattern (
1459
1460
leaf_candidate,
1460
- remainder_start,
1461
+ or_start,
1462
+ or_otherwise,
1461
1463
pats,
1462
1464
or_span,
1463
1465
& match_pair. place ,
@@ -1477,13 +1479,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1477
1479
}
1478
1480
1479
1481
#[ instrument(
1480
- skip( self , otherwise , or_span, place, fake_borrows, candidate, pats) ,
1482
+ skip( self , start_block , otherwise_block , or_span, place, fake_borrows, candidate, pats) ,
1481
1483
level = "debug"
1482
1484
) ]
1483
1485
fn test_or_pattern < ' pat > (
1484
1486
& mut self ,
1485
1487
candidate : & mut Candidate < ' pat , ' tcx > ,
1486
- otherwise : BasicBlock ,
1488
+ start_block : BasicBlock ,
1489
+ otherwise_block : BasicBlock ,
1487
1490
pats : & ' pat [ Box < Pat < ' tcx > > ] ,
1488
1491
or_span : Span ,
1489
1492
place : & PlaceBuilder < ' tcx > ,
@@ -1495,16 +1498,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1495
1498
. map ( |pat| Candidate :: new ( place. clone ( ) , pat, candidate. has_guard , self ) )
1496
1499
. collect ( ) ;
1497
1500
let mut or_candidate_refs: Vec < _ > = or_candidates. iter_mut ( ) . collect ( ) ;
1498
- let otherwise = if let Some ( otherwise_block) = candidate. otherwise_block {
1499
- otherwise_block
1500
- } else {
1501
- otherwise
1502
- } ;
1503
1501
self . match_candidates (
1504
1502
or_span,
1505
1503
or_span,
1506
- candidate . pre_binding_block . unwrap ( ) ,
1507
- otherwise ,
1504
+ start_block ,
1505
+ otherwise_block ,
1508
1506
& mut or_candidate_refs,
1509
1507
fake_borrows,
1510
1508
) ;
0 commit comments