@@ -60,13 +60,24 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
60
60
let mut simplified_match_pairs = Vec :: new ( ) ;
61
61
// Repeatedly simplify match pairs until we're left with only unsimplifiable ones.
62
62
loop {
63
- for match_pair in mem:: take ( match_pairs) {
64
- if let Err ( match_pair) = self . simplify_match_pair (
65
- match_pair,
66
- candidate_bindings,
67
- candidate_ascriptions,
68
- match_pairs,
69
- ) {
63
+ for mut match_pair in mem:: take ( match_pairs) {
64
+ if let TestCase :: Irrefutable { binding, ascription } = match_pair. test_case {
65
+ if let Some ( binding) = binding {
66
+ candidate_bindings. push ( binding) ;
67
+ }
68
+ if let Some ( ascription) = ascription {
69
+ candidate_ascriptions. push ( ascription) ;
70
+ }
71
+ // Simplifiable pattern; we replace it with its subpairs and simplify further.
72
+ match_pairs. append ( & mut match_pair. subpairs ) ;
73
+ } else {
74
+ // Unsimplifiable pattern; we recursively simplify its subpairs and don't
75
+ // process it further.
76
+ self . simplify_match_pairs (
77
+ & mut match_pair. subpairs ,
78
+ candidate_bindings,
79
+ candidate_ascriptions,
80
+ ) ;
70
81
simplified_match_pairs. push ( match_pair) ;
71
82
}
72
83
}
@@ -115,31 +126,4 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
115
126
} )
116
127
. collect ( )
117
128
}
118
-
119
- /// Tries to simplify `match_pair`, returning `Ok(())` if successful. If successful, new match
120
- /// pairs and bindings will have been pushed into the respective `Vec`s. If no simplification is
121
- /// possible, `Err` is returned.
122
- fn simplify_match_pair < ' pat > (
123
- & mut self ,
124
- mut match_pair : MatchPair < ' pat , ' tcx > ,
125
- bindings : & mut Vec < Binding < ' tcx > > ,
126
- ascriptions : & mut Vec < Ascription < ' tcx > > ,
127
- match_pairs : & mut Vec < MatchPair < ' pat , ' tcx > > ,
128
- ) -> Result < ( ) , MatchPair < ' pat , ' tcx > > {
129
- if let TestCase :: Irrefutable { binding, ascription } = match_pair. test_case {
130
- if let Some ( binding) = binding {
131
- bindings. push ( binding) ;
132
- }
133
- if let Some ( ascription) = ascription {
134
- ascriptions. push ( ascription) ;
135
- }
136
- // Simplifiable pattern; we replace it with its subpairs.
137
- match_pairs. append ( & mut match_pair. subpairs ) ;
138
- Ok ( ( ) )
139
- } else {
140
- // Unsimplifiable pattern; we recursively simplify its subpairs.
141
- self . simplify_match_pairs ( & mut match_pair. subpairs , bindings, ascriptions) ;
142
- Err ( match_pair)
143
- }
144
- }
145
129
}
0 commit comments