@@ -155,12 +155,16 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
155155 ascription : thir:: Ascription { variance, user_ty, user_ty_span } ,
156156 } => {
157157 // Apply the type ascription to the value at `match_pair.place`, which is the
158- candidate. ascriptions . push ( Ascription {
159- span : user_ty_span,
160- user_ty,
161- source : match_pair. place . clone ( ) . into_place ( self . tcx , self . typeck_results ) ,
162- variance,
163- } ) ;
158+ if let Ok ( place_resolved) =
159+ match_pair. place . clone ( ) . try_upvars_resolved ( self . tcx , self . typeck_results )
160+ {
161+ candidate. ascriptions . push ( Ascription {
162+ span : user_ty_span,
163+ user_ty,
164+ source : place_resolved. into_place ( self . tcx , self . typeck_results ) ,
165+ variance,
166+ } ) ;
167+ }
164168
165169 candidate. match_pairs . push ( MatchPair :: new ( match_pair. place , subpattern) ) ;
166170
@@ -173,15 +177,19 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
173177 }
174178
175179 PatKind :: Binding { name, mutability, mode, var, ty, ref subpattern, is_primary : _ } => {
176- candidate. bindings . push ( Binding {
177- name,
178- mutability,
179- span : match_pair. pattern . span ,
180- source : match_pair. place . clone ( ) . into_place ( self . tcx , self . typeck_results ) ,
181- var_id : var,
182- var_ty : ty,
183- binding_mode : mode,
184- } ) ;
180+ if let Ok ( place_resolved) =
181+ match_pair. place . clone ( ) . try_upvars_resolved ( self . tcx , self . typeck_results )
182+ {
183+ candidate. bindings . push ( Binding {
184+ name,
185+ mutability,
186+ span : match_pair. pattern . span ,
187+ source : place_resolved. into_place ( self . tcx , self . typeck_results ) ,
188+ var_id : var,
189+ var_ty : ty,
190+ binding_mode : mode,
191+ } ) ;
192+ }
185193
186194 if let Some ( subpattern) = subpattern. as_ref ( ) {
187195 // this is the `x @ P` case; have to keep matching against `P` now
0 commit comments