@@ -292,30 +292,32 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
292292 ..
293293 } ,
294294 user_ty : ascription_user_ty,
295+ user_ty_span,
295296 } => {
296297 let place =
297298 self . storage_live_binding ( block, var, irrefutable_pat. span , OutsideGuard ) ;
298299 unpack ! ( block = self . into( & place, block, initializer) ) ;
299300
300- let source_info = self . source_info ( irrefutable_pat. span ) ;
301+ // Inject a fake read, see comments on `FakeReadCause::ForLet`.
302+ let pattern_source_info = self . source_info ( irrefutable_pat. span ) ;
301303 self . cfg . push (
302304 block,
303305 Statement {
304- source_info,
305- kind : StatementKind :: AscribeUserType (
306- place. clone ( ) ,
307- ty:: Variance :: Invariant ,
308- ascription_user_ty,
309- ) ,
306+ source_info : pattern_source_info,
307+ kind : StatementKind :: FakeRead ( FakeReadCause :: ForLet , place. clone ( ) ) ,
310308 } ,
311309 ) ;
312310
313- // Inject a fake read, see comments on `FakeReadCause::ForLet`.
311+ let ty_source_info = self . source_info ( user_ty_span ) ;
314312 self . cfg . push (
315313 block,
316314 Statement {
317- source_info,
318- kind : StatementKind :: FakeRead ( FakeReadCause :: ForLet , place. clone ( ) ) ,
315+ source_info : ty_source_info,
316+ kind : StatementKind :: AscribeUserType (
317+ place. clone ( ) ,
318+ ty:: Variance :: Invariant ,
319+ ascription_user_ty,
320+ ) ,
319321 } ,
320322 ) ;
321323
@@ -489,7 +491,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
489491 pub fn visit_bindings (
490492 & mut self ,
491493 pattern : & Pattern < ' tcx > ,
492- mut pattern_user_ty : Option < CanonicalTy < ' tcx > > ,
494+ mut pattern_user_ty : Option < ( CanonicalTy < ' tcx > , Span ) > ,
493495 f : & mut impl FnMut (
494496 & mut Self ,
495497 Mutability ,
@@ -498,7 +500,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
498500 NodeId ,
499501 Span ,
500502 Ty < ' tcx > ,
501- Option < CanonicalTy < ' tcx > > ,
503+ Option < ( CanonicalTy < ' tcx > , Span ) > ,
502504 ) ,
503505 ) {
504506 match * pattern. kind {
@@ -549,16 +551,15 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
549551 // FIXME(#47184): extract or handle `pattern_user_ty` somehow
550552 self . visit_bindings ( subpattern, None , f) ;
551553 }
552- PatternKind :: AscribeUserType { ref subpattern, user_ty } => {
554+ PatternKind :: AscribeUserType { ref subpattern, user_ty, user_ty_span } => {
553555 // This corresponds to something like
554556 //
555557 // ```
556- // let (p1: T1 ): T2 = ...;
558+ // let A::<'a>(_ ): A<'static> = ...;
557559 // ```
558560 //
559- // Not presently possible, though maybe someday.
560- assert ! ( pattern_user_ty. is_none( ) ) ;
561- self . visit_bindings ( subpattern, Some ( user_ty) , f)
561+ // FIXME(#47184): handle `pattern_user_ty` somehow
562+ self . visit_bindings ( subpattern, Some ( ( user_ty, user_ty_span) ) , f)
562563 }
563564 PatternKind :: Leaf { ref subpatterns }
564565 | PatternKind :: Variant {
@@ -1469,7 +1470,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
14691470 num_patterns : usize ,
14701471 var_id : NodeId ,
14711472 var_ty : Ty < ' tcx > ,
1472- user_var_ty : Option < CanonicalTy < ' tcx > > ,
1473+ user_var_ty : Option < ( CanonicalTy < ' tcx > , Span ) > ,
14731474 has_guard : ArmHasGuard ,
14741475 opt_match_place : Option < ( Option < Place < ' tcx > > , Span ) > ,
14751476 pat_span : Span ,
0 commit comments