@@ -482,8 +482,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
482
482
match irrefutable_pat. kind {
483
483
// Optimize the case of `let x = ...` to write directly into `x`
484
484
PatKind :: Binding { mode : BindingMode :: ByValue , var, subpattern : None , .. } => {
485
- let place =
486
- self . storage_live_binding ( block, var, irrefutable_pat. span , OutsideGuard , true ) ;
485
+ let place = self . storage_live_binding (
486
+ block,
487
+ var,
488
+ irrefutable_pat. span ,
489
+ false ,
490
+ OutsideGuard ,
491
+ true ,
492
+ ) ;
487
493
unpack ! ( block = self . expr_into_dest( place, block, initializer) ) ;
488
494
489
495
// Inject a fake read, see comments on `FakeReadCause::ForLet`.
@@ -513,8 +519,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
513
519
} ,
514
520
ascription : thir:: Ascription { ref annotation, variance : _ } ,
515
521
} => {
516
- let place =
517
- self . storage_live_binding ( block, var, irrefutable_pat. span , OutsideGuard , true ) ;
522
+ let place = self . storage_live_binding (
523
+ block,
524
+ var,
525
+ irrefutable_pat. span ,
526
+ false ,
527
+ OutsideGuard ,
528
+ true ,
529
+ ) ;
518
530
unpack ! ( block = self . expr_into_dest( place, block, initializer) ) ;
519
531
520
532
// Inject a fake read, see comments on `FakeReadCause::ForLet`.
@@ -682,6 +694,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
682
694
block : BasicBlock ,
683
695
var : LocalVarId ,
684
696
span : Span ,
697
+ is_shorthand : bool ,
685
698
for_guard : ForGuard ,
686
699
schedule_drop : bool ,
687
700
) -> Place < ' tcx > {
@@ -693,6 +706,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
693
706
if let Some ( region_scope) = self . region_scope_tree . var_scope ( var. 0 . local_id ) && schedule_drop {
694
707
self . schedule_drop ( span, region_scope, local_id, DropKind :: Storage ) ;
695
708
}
709
+ let local_info = self . local_decls [ local_id] . local_info . as_mut ( ) . assert_crate_local ( ) ;
710
+ if let LocalInfo :: User ( BindingForm :: Var ( var_info) ) = & mut * * local_info {
711
+ var_info. introductions . push ( ( span, is_shorthand) ) ;
712
+ }
696
713
Place :: from ( local_id)
697
714
}
698
715
@@ -914,6 +931,7 @@ struct Binding<'tcx> {
914
931
source : Place < ' tcx > ,
915
932
var_id : LocalVarId ,
916
933
binding_mode : BindingMode ,
934
+ is_shorthand : bool ,
917
935
}
918
936
919
937
/// Indicates that the type of `source` must be a subtype of the
@@ -2124,6 +2142,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2124
2142
block,
2125
2143
binding. var_id ,
2126
2144
binding. span ,
2145
+ binding. is_shorthand ,
2127
2146
RefWithinGuard ,
2128
2147
schedule_drops,
2129
2148
) ;
@@ -2137,6 +2156,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2137
2156
block,
2138
2157
binding. var_id ,
2139
2158
binding. span ,
2159
+ binding. is_shorthand ,
2140
2160
OutsideGuard ,
2141
2161
schedule_drops,
2142
2162
) ;
@@ -2175,6 +2195,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2175
2195
block,
2176
2196
binding. var_id ,
2177
2197
binding. span ,
2198
+ binding. is_shorthand ,
2178
2199
OutsideGuard ,
2179
2200
schedule_drops,
2180
2201
)
@@ -2234,6 +2255,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2234
2255
opt_ty_info : None ,
2235
2256
opt_match_place,
2236
2257
pat_span,
2258
+ introductions : Vec :: new ( ) ,
2237
2259
} ,
2238
2260
) ) ) ) ,
2239
2261
} ;
0 commit comments