@@ -292,30 +292,32 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
292
292
..
293
293
} ,
294
294
user_ty : ascription_user_ty,
295
+ user_ty_span,
295
296
} => {
296
297
let place =
297
298
self . storage_live_binding ( block, var, irrefutable_pat. span , OutsideGuard ) ;
298
299
unpack ! ( block = self . into( & place, block, initializer) ) ;
299
300
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 ) ;
301
303
self . cfg . push (
302
304
block,
303
305
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 ( ) ) ,
310
308
} ,
311
309
) ;
312
310
313
- // Inject a fake read, see comments on `FakeReadCause::ForLet`.
311
+ let ty_source_info = self . source_info ( user_ty_span ) ;
314
312
self . cfg . push (
315
313
block,
316
314
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
+ ) ,
319
321
} ,
320
322
) ;
321
323
@@ -489,7 +491,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
489
491
pub fn visit_bindings (
490
492
& mut self ,
491
493
pattern : & Pattern < ' tcx > ,
492
- mut pattern_user_ty : Option < CanonicalTy < ' tcx > > ,
494
+ mut pattern_user_ty : Option < ( CanonicalTy < ' tcx > , Span ) > ,
493
495
f : & mut impl FnMut (
494
496
& mut Self ,
495
497
Mutability ,
@@ -498,7 +500,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
498
500
NodeId ,
499
501
Span ,
500
502
Ty < ' tcx > ,
501
- Option < CanonicalTy < ' tcx > > ,
503
+ Option < ( CanonicalTy < ' tcx > , Span ) > ,
502
504
) ,
503
505
) {
504
506
match * pattern. kind {
@@ -549,16 +551,15 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
549
551
// FIXME(#47184): extract or handle `pattern_user_ty` somehow
550
552
self . visit_bindings ( subpattern, None , f) ;
551
553
}
552
- PatternKind :: AscribeUserType { ref subpattern, user_ty } => {
554
+ PatternKind :: AscribeUserType { ref subpattern, user_ty, user_ty_span } => {
553
555
// This corresponds to something like
554
556
//
555
557
// ```
556
- // let (p1: T1 ): T2 = ...;
558
+ // let A::<'a>(_ ): A<'static> = ...;
557
559
// ```
558
560
//
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)
562
563
}
563
564
PatternKind :: Leaf { ref subpatterns }
564
565
| PatternKind :: Variant {
@@ -1469,7 +1470,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
1469
1470
num_patterns : usize ,
1470
1471
var_id : NodeId ,
1471
1472
var_ty : Ty < ' tcx > ,
1472
- user_var_ty : Option < CanonicalTy < ' tcx > > ,
1473
+ user_var_ty : Option < ( CanonicalTy < ' tcx > , Span ) > ,
1473
1474
has_guard : ArmHasGuard ,
1474
1475
opt_match_place : Option < ( Option < Place < ' tcx > > , Span ) > ,
1475
1476
pat_span : Span ,
0 commit comments