@@ -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 ) {
@@ -1436,7 +1436,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
14361436 span,
14371437 scrutinee_span,
14381438 candidates,
1439- block ,
1439+ start_block ,
14401440 otherwise_block,
14411441 fake_borrows,
14421442 ) ;
@@ -1445,7 +1445,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
14451445 }
14461446
14471447 let match_pairs = mem:: take ( & mut first_candidate. match_pairs ) ;
1448- first_candidate. pre_binding_block = Some ( block) ;
14491448
14501449 let remainder_start = self . cfg . start_new_block ( ) ;
14511450 for match_pair in match_pairs {
@@ -1455,9 +1454,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
14551454 let or_span = match_pair. pattern . span ;
14561455
14571456 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) ;
14581459 self . test_or_pattern (
14591460 leaf_candidate,
1460- remainder_start,
1461+ or_start,
1462+ or_otherwise,
14611463 pats,
14621464 or_span,
14631465 & match_pair. place ,
@@ -1477,13 +1479,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
14771479 }
14781480
14791481 #[ 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) ,
14811483 level = "debug"
14821484 ) ]
14831485 fn test_or_pattern < ' pat > (
14841486 & mut self ,
14851487 candidate : & mut Candidate < ' pat , ' tcx > ,
1486- otherwise : BasicBlock ,
1488+ start_block : BasicBlock ,
1489+ otherwise_block : BasicBlock ,
14871490 pats : & ' pat [ Box < Pat < ' tcx > > ] ,
14881491 or_span : Span ,
14891492 place : & PlaceBuilder < ' tcx > ,
@@ -1495,16 +1498,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
14951498 . map ( |pat| Candidate :: new ( place. clone ( ) , pat, candidate. has_guard , self ) )
14961499 . collect ( ) ;
14971500 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- } ;
15031501 self . match_candidates (
15041502 or_span,
15051503 or_span,
1506- candidate . pre_binding_block . unwrap ( ) ,
1507- otherwise ,
1504+ start_block ,
1505+ otherwise_block ,
15081506 & mut or_candidate_refs,
15091507 fake_borrows,
15101508 ) ;
0 commit comments