@@ -95,35 +95,36 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
9595
9696impl < ' pat , ' tcx > MatchPair < ' pat , ' tcx > {
9797 pub ( in crate :: build) fn new (
98- mut place : PlaceBuilder < ' tcx > ,
98+ mut place_builder : PlaceBuilder < ' tcx > ,
9999 pattern : & ' pat Pat < ' tcx > ,
100100 cx : & mut Builder < ' _ , ' tcx > ,
101101 ) -> MatchPair < ' pat , ' tcx > {
102102 // Force the place type to the pattern's type.
103103 // FIXME(oli-obk): can we use this to simplify slice/array pattern hacks?
104- if let Some ( resolved) = place . resolve_upvar ( cx) {
105- place = resolved;
104+ if let Some ( resolved) = place_builder . resolve_upvar ( cx) {
105+ place_builder = resolved;
106106 }
107107
108108 // Only add the OpaqueCast projection if the given place is an opaque type and the
109109 // expected type from the pattern is not.
110- let may_need_cast = match place . base ( ) {
110+ let may_need_cast = match place_builder . base ( ) {
111111 PlaceBase :: Local ( local) => {
112- let ty = Place :: ty_from ( local, place. projection ( ) , & cx. local_decls , cx. tcx ) . ty ;
112+ let ty =
113+ Place :: ty_from ( local, place_builder. projection ( ) , & cx. local_decls , cx. tcx ) . ty ;
113114 ty != pattern. ty && ty. has_opaque_types ( )
114115 }
115116 _ => true ,
116117 } ;
117118 if may_need_cast {
118- place = place . project ( ProjectionElem :: OpaqueCast ( pattern. ty ) ) ;
119+ place_builder = place_builder . project ( ProjectionElem :: OpaqueCast ( pattern. ty ) ) ;
119120 }
120121
121122 let default_irrefutable = || TestCase :: Irrefutable { binding : None , ascription : None } ;
122123 let mut subpairs = Vec :: new ( ) ;
123124 let test_case = match pattern. kind {
124125 PatKind :: Never | PatKind :: Wild | PatKind :: Error ( _) => default_irrefutable ( ) ,
125126 PatKind :: Or { ref pats } => TestCase :: Or {
126- pats : pats. iter ( ) . map ( |pat| FlatPat :: new ( place . clone ( ) , pat, cx) ) . collect ( ) ,
127+ pats : pats. iter ( ) . map ( |pat| FlatPat :: new ( place_builder . clone ( ) , pat, cx) ) . collect ( ) ,
127128 } ,
128129
129130 PatKind :: Range ( ref range) => {
@@ -142,13 +143,13 @@ impl<'pat, 'tcx> MatchPair<'pat, 'tcx> {
142143 ..
143144 } => {
144145 // Apply the type ascription to the value at `match_pair.place`
145- let ascription = place . try_to_place ( cx) . map ( |source| super :: Ascription {
146+ let ascription = place_builder . try_to_place ( cx) . map ( |source| super :: Ascription {
146147 annotation : annotation. clone ( ) ,
147148 source,
148149 variance,
149150 } ) ;
150151
151- subpairs. push ( MatchPair :: new ( place . clone ( ) , subpattern, cx) ) ;
152+ subpairs. push ( MatchPair :: new ( place_builder . clone ( ) , subpattern, cx) ) ;
152153 TestCase :: Irrefutable { ascription, binding : None }
153154 }
154155
@@ -161,7 +162,7 @@ impl<'pat, 'tcx> MatchPair<'pat, 'tcx> {
161162 ref subpattern,
162163 is_primary : _,
163164 } => {
164- let binding = place . try_to_place ( cx) . map ( |source| super :: Binding {
165+ let binding = place_builder . try_to_place ( cx) . map ( |source| super :: Binding {
165166 span : pattern. span ,
166167 source,
167168 var_id : var,
@@ -170,14 +171,14 @@ impl<'pat, 'tcx> MatchPair<'pat, 'tcx> {
170171
171172 if let Some ( subpattern) = subpattern. as_ref ( ) {
172173 // this is the `x @ P` case; have to keep matching against `P` now
173- subpairs. push ( MatchPair :: new ( place . clone ( ) , subpattern, cx) ) ;
174+ subpairs. push ( MatchPair :: new ( place_builder . clone ( ) , subpattern, cx) ) ;
174175 }
175176 TestCase :: Irrefutable { ascription : None , binding }
176177 }
177178
178179 PatKind :: InlineConstant { subpattern : ref pattern, def, .. } => {
179180 // Apply a type ascription for the inline constant to the value at `match_pair.place`
180- let ascription = place . try_to_place ( cx) . map ( |source| {
181+ let ascription = place_builder . try_to_place ( cx) . map ( |source| {
181182 let span = pattern. span ;
182183 let parent_id = cx. tcx . typeck_root_def_id ( cx. def_id . to_def_id ( ) ) ;
183184 let args = ty:: InlineConstArgs :: new (
@@ -203,16 +204,16 @@ impl<'pat, 'tcx> MatchPair<'pat, 'tcx> {
203204 super :: Ascription { annotation, source, variance : ty:: Contravariant }
204205 } ) ;
205206
206- subpairs. push ( MatchPair :: new ( place . clone ( ) , pattern, cx) ) ;
207+ subpairs. push ( MatchPair :: new ( place_builder . clone ( ) , pattern, cx) ) ;
207208 TestCase :: Irrefutable { ascription, binding : None }
208209 }
209210
210211 PatKind :: Array { ref prefix, ref slice, ref suffix } => {
211- cx. prefix_slice_suffix ( & mut subpairs, & place , prefix, slice, suffix) ;
212+ cx. prefix_slice_suffix ( & mut subpairs, & place_builder , prefix, slice, suffix) ;
212213 default_irrefutable ( )
213214 }
214215 PatKind :: Slice { ref prefix, ref slice, ref suffix } => {
215- cx. prefix_slice_suffix ( & mut subpairs, & place , prefix, slice, suffix) ;
216+ cx. prefix_slice_suffix ( & mut subpairs, & place_builder , prefix, slice, suffix) ;
216217
217218 if prefix. is_empty ( ) && slice. is_some ( ) && suffix. is_empty ( ) {
218219 default_irrefutable ( )
@@ -225,7 +226,7 @@ impl<'pat, 'tcx> MatchPair<'pat, 'tcx> {
225226 }
226227
227228 PatKind :: Variant { adt_def, variant_index, args, ref subpatterns } => {
228- let downcast_place = place . clone ( ) . downcast ( adt_def, variant_index) ; // `(x as Variant)`
229+ let downcast_place = place_builder . clone ( ) . downcast ( adt_def, variant_index) ; // `(x as Variant)`
229230 subpairs = cx. field_match_pairs ( downcast_place, subpatterns) ;
230231
231232 let irrefutable = adt_def. variants ( ) . iter_enumerated ( ) . all ( |( i, v) | {
@@ -247,12 +248,12 @@ impl<'pat, 'tcx> MatchPair<'pat, 'tcx> {
247248 }
248249
249250 PatKind :: Leaf { ref subpatterns } => {
250- subpairs = cx. field_match_pairs ( place . clone ( ) , subpatterns) ;
251+ subpairs = cx. field_match_pairs ( place_builder . clone ( ) , subpatterns) ;
251252 default_irrefutable ( )
252253 }
253254
254255 PatKind :: Deref { ref subpattern } => {
255- let place_builder = place . clone ( ) . deref ( ) ;
256+ let place_builder = place_builder . clone ( ) . deref ( ) ;
256257 subpairs. push ( MatchPair :: new ( place_builder, subpattern, cx) ) ;
257258 default_irrefutable ( )
258259 }
@@ -264,7 +265,7 @@ impl<'pat, 'tcx> MatchPair<'pat, 'tcx> {
264265 }
265266 } ;
266267
267- MatchPair { place, test_case, subpairs, pattern }
268+ MatchPair { place : place_builder , test_case, subpairs, pattern }
268269 }
269270}
270271
0 commit comments