@@ -59,22 +59,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
5959 //
6060 // final bindings: [6, 7, 4, 5, 1, 2, 3]
6161 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.
6364 loop {
64- let mut changed = false ;
6565 for match_pair in mem:: take ( match_pairs) {
66- match self . simplify_match_pair (
66+ if let Err ( match_pair ) = self . simplify_match_pair (
6767 match_pair,
6868 candidate_bindings,
6969 candidate_ascriptions,
7070 match_pairs,
7171 ) {
72- Ok ( ( ) ) => {
73- changed = true ;
74- }
75- Err ( match_pair) => {
76- match_pairs. push ( match_pair) ;
77- }
72+ simplified_match_pairs. push ( match_pair) ;
7873 }
7974 }
8075
@@ -83,14 +78,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
8378 mem:: swap ( candidate_bindings, & mut accumulated_bindings) ;
8479 candidate_bindings. clear ( ) ;
8580
86- if !changed {
87- // If we were not able to simplify anymore, done.
81+ if match_pairs. is_empty ( ) {
8882 break ;
8983 }
9084 }
9185
9286 // Store computed bindings back in `candidate_bindings`.
9387 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) ;
9490
9591 // Move or-patterns to the end, because they can result in us
9692 // creating additional candidates, so we want to test them as
0 commit comments