@@ -1408,7 +1408,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1408
1408
span : Span ,
1409
1409
scrutinee_span : Span ,
1410
1410
candidates : & mut [ & mut Candidate < ' _ , ' tcx > ] ,
1411
- block : BasicBlock ,
1411
+ start_block : BasicBlock ,
1412
1412
otherwise_block : BasicBlock ,
1413
1413
fake_borrows : & mut Option < FxIndexSet < Place < ' tcx > > > ,
1414
1414
) {
@@ -1423,7 +1423,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1423
1423
span,
1424
1424
scrutinee_span,
1425
1425
candidates,
1426
- block ,
1426
+ start_block ,
1427
1427
otherwise_block,
1428
1428
fake_borrows,
1429
1429
) ;
@@ -1432,7 +1432,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1432
1432
}
1433
1433
1434
1434
let match_pairs = mem:: take ( & mut first_candidate. match_pairs ) ;
1435
- first_candidate. pre_binding_block = Some ( block) ;
1436
1435
1437
1436
let remainder_start = self . cfg . start_new_block ( ) ;
1438
1437
for match_pair in match_pairs {
@@ -1442,9 +1441,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1442
1441
let or_span = match_pair. pattern . span ;
1443
1442
1444
1443
first_candidate. visit_leaves ( |leaf_candidate| {
1444
+ let or_start = leaf_candidate. pre_binding_block . unwrap_or ( start_block) ;
1445
+ let or_otherwise = leaf_candidate. otherwise_block . unwrap_or ( remainder_start) ;
1445
1446
self . test_or_pattern (
1446
1447
leaf_candidate,
1447
- remainder_start,
1448
+ or_start,
1449
+ or_otherwise,
1448
1450
pats,
1449
1451
or_span,
1450
1452
& match_pair. place ,
@@ -1464,13 +1466,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1464
1466
}
1465
1467
1466
1468
#[ instrument(
1467
- skip( self , otherwise , or_span, place, fake_borrows, candidate, pats) ,
1469
+ skip( self , start_block , otherwise_block , or_span, place, fake_borrows, candidate, pats) ,
1468
1470
level = "debug"
1469
1471
) ]
1470
1472
fn test_or_pattern < ' pat > (
1471
1473
& mut self ,
1472
1474
candidate : & mut Candidate < ' pat , ' tcx > ,
1473
- otherwise : BasicBlock ,
1475
+ start_block : BasicBlock ,
1476
+ otherwise_block : BasicBlock ,
1474
1477
pats : & ' pat [ Box < Pat < ' tcx > > ] ,
1475
1478
or_span : Span ,
1476
1479
place : & PlaceBuilder < ' tcx > ,
@@ -1482,16 +1485,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1482
1485
. map ( |pat| Candidate :: new ( place. clone ( ) , pat, candidate. has_guard , self ) )
1483
1486
. collect ( ) ;
1484
1487
let mut or_candidate_refs: Vec < _ > = or_candidates. iter_mut ( ) . collect ( ) ;
1485
- let otherwise = if let Some ( otherwise_block) = candidate. otherwise_block {
1486
- otherwise_block
1487
- } else {
1488
- otherwise
1489
- } ;
1490
1488
self . match_candidates (
1491
1489
or_span,
1492
1490
or_span,
1493
- candidate . pre_binding_block . unwrap ( ) ,
1494
- otherwise ,
1491
+ start_block ,
1492
+ otherwise_block ,
1495
1493
& mut or_candidate_refs,
1496
1494
fake_borrows,
1497
1495
) ;
0 commit comments