@@ -1441,20 +1441,20 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
14411441 return ;
14421442 }
14431443
1444- let match_pairs = mem :: take ( & mut first_candidate. match_pairs ) ;
1445- let ( first_match_pair , remaining_match_pairs ) = match_pairs . split_first ( ) . unwrap ( ) ;
1446- let TestCase :: Or { ref pats } = & first_match_pair. test_case else { unreachable ! ( ) } ;
1444+ let first_match_pair = first_candidate. match_pairs . remove ( 0 ) ;
1445+ let or_span = first_match_pair . pattern . span ;
1446+ let TestCase :: Or { pats } = first_match_pair. test_case else { unreachable ! ( ) } ;
14471447
14481448 let remainder_start = self . cfg . start_new_block ( ) ;
1449- let or_span = first_match_pair. pattern . span ;
14501449 // Test the alternatives of this or-pattern.
14511450 self . test_or_pattern ( first_candidate, start_block, remainder_start, pats, or_span) ;
14521451
1453- if !remaining_match_pairs . is_empty ( ) {
1452+ if !first_candidate . match_pairs . is_empty ( ) {
14541453 // If more match pairs remain, test them after each subcandidate.
14551454 // We could add them to the or-candidates before the call to `test_or_pattern` but this
14561455 // would make it impossible to detect simplifiable or-patterns. That would guarantee
14571456 // exponentially large CFGs for cases like `(1 | 2, 3 | 4, ...)`.
1457+ let remaining_match_pairs = mem:: take ( & mut first_candidate. match_pairs ) ;
14581458 first_candidate. visit_leaves ( |leaf_candidate| {
14591459 assert ! ( leaf_candidate. match_pairs. is_empty( ) ) ;
14601460 leaf_candidate. match_pairs . extend ( remaining_match_pairs. iter ( ) . cloned ( ) ) ;
@@ -1492,13 +1492,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
14921492 candidate : & mut Candidate < ' pat , ' tcx > ,
14931493 start_block : BasicBlock ,
14941494 otherwise_block : BasicBlock ,
1495- pats : & [ FlatPat < ' pat , ' tcx > ] ,
1495+ pats : Box < [ FlatPat < ' pat , ' tcx > ] > ,
14961496 or_span : Span ,
14971497 ) {
14981498 debug ! ( "candidate={:#?}\n pats={:#?}" , candidate, pats) ;
14991499 let mut or_candidates: Vec < _ > = pats
1500- . iter ( )
1501- . cloned ( )
1500+ . into_vec ( )
1501+ . into_iter ( )
15021502 . map ( |flat_pat| Candidate :: from_flat_pat ( flat_pat, candidate. has_guard ) )
15031503 . collect ( ) ;
15041504 let mut or_candidate_refs: Vec < _ > = or_candidates. iter_mut ( ) . collect ( ) ;
0 commit comments