@@ -59,22 +59,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
59
59
//
60
60
// final bindings: [6, 7, 4, 5, 1, 2, 3]
61
61
let mut accumulated_bindings = mem:: take ( candidate_bindings) ;
62
- // Repeatedly simplify match pairs until fixed point is reached
62
+ let mut simplified_match_pairs = Vec :: new ( ) ;
63
+ // Repeatedly simplify match pairs until we're left with only unsimplifiable ones.
63
64
loop {
64
- let mut changed = false ;
65
65
for match_pair in mem:: take ( match_pairs) {
66
- match self . simplify_match_pair (
66
+ if let Err ( match_pair ) = self . simplify_match_pair (
67
67
match_pair,
68
68
candidate_bindings,
69
69
candidate_ascriptions,
70
70
match_pairs,
71
71
) {
72
- Ok ( ( ) ) => {
73
- changed = true ;
74
- }
75
- Err ( match_pair) => {
76
- match_pairs. push ( match_pair) ;
77
- }
72
+ simplified_match_pairs. push ( match_pair) ;
78
73
}
79
74
}
80
75
@@ -83,14 +78,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
83
78
mem:: swap ( candidate_bindings, & mut accumulated_bindings) ;
84
79
candidate_bindings. clear ( ) ;
85
80
86
- if !changed {
87
- // If we were not able to simplify anymore, done.
81
+ if match_pairs. is_empty ( ) {
88
82
break ;
89
83
}
90
84
}
91
85
92
86
// Store computed bindings back in `candidate_bindings`.
93
87
mem:: swap ( candidate_bindings, & mut accumulated_bindings) ;
88
+ // Store simplified match pairs back in `match_pairs`.
89
+ mem:: swap ( match_pairs, & mut simplified_match_pairs) ;
94
90
95
91
// Move or-patterns to the end, because they can result in us
96
92
// creating additional candidates, so we want to test them as
0 commit comments