@@ -1441,20 +1441,20 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1441
1441
return ;
1442
1442
}
1443
1443
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 ! ( ) } ;
1447
1447
1448
1448
let remainder_start = self . cfg . start_new_block ( ) ;
1449
- let or_span = first_match_pair. pattern . span ;
1450
1449
// Test the alternatives of this or-pattern.
1451
1450
self . test_or_pattern ( first_candidate, start_block, remainder_start, pats, or_span) ;
1452
1451
1453
- if !remaining_match_pairs . is_empty ( ) {
1452
+ if !first_candidate . match_pairs . is_empty ( ) {
1454
1453
// If more match pairs remain, test them after each subcandidate.
1455
1454
// We could add them to the or-candidates before the call to `test_or_pattern` but this
1456
1455
// would make it impossible to detect simplifiable or-patterns. That would guarantee
1457
1456
// exponentially large CFGs for cases like `(1 | 2, 3 | 4, ...)`.
1457
+ let remaining_match_pairs = mem:: take ( & mut first_candidate. match_pairs ) ;
1458
1458
first_candidate. visit_leaves ( |leaf_candidate| {
1459
1459
assert ! ( leaf_candidate. match_pairs. is_empty( ) ) ;
1460
1460
leaf_candidate. match_pairs . extend ( remaining_match_pairs. iter ( ) . cloned ( ) ) ;
@@ -1492,13 +1492,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1492
1492
candidate : & mut Candidate < ' pat , ' tcx > ,
1493
1493
start_block : BasicBlock ,
1494
1494
otherwise_block : BasicBlock ,
1495
- pats : & [ FlatPat < ' pat , ' tcx > ] ,
1495
+ pats : Box < [ FlatPat < ' pat , ' tcx > ] > ,
1496
1496
or_span : Span ,
1497
1497
) {
1498
1498
debug ! ( "candidate={:#?}\n pats={:#?}" , candidate, pats) ;
1499
1499
let mut or_candidates: Vec < _ > = pats
1500
- . iter ( )
1501
- . cloned ( )
1500
+ . into_vec ( )
1501
+ . into_iter ( )
1502
1502
. map ( |flat_pat| Candidate :: from_flat_pat ( flat_pat, candidate. has_guard ) )
1503
1503
. collect ( ) ;
1504
1504
let mut or_candidate_refs: Vec < _ > = or_candidates. iter_mut ( ) . collect ( ) ;
0 commit comments