@@ -482,8 +482,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
482482 match irrefutable_pat. kind {
483483 // Optimize the case of `let x = ...` to write directly into `x`
484484 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+ ) ;
487493 unpack ! ( block = self . expr_into_dest( place, block, initializer) ) ;
488494
489495 // Inject a fake read, see comments on `FakeReadCause::ForLet`.
@@ -513,8 +519,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
513519 } ,
514520 ascription : thir:: Ascription { ref annotation, variance : _ } ,
515521 } => {
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+ ) ;
518530 unpack ! ( block = self . expr_into_dest( place, block, initializer) ) ;
519531
520532 // Inject a fake read, see comments on `FakeReadCause::ForLet`.
@@ -682,6 +694,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
682694 block : BasicBlock ,
683695 var : LocalVarId ,
684696 span : Span ,
697+ is_shorthand : bool ,
685698 for_guard : ForGuard ,
686699 schedule_drop : bool ,
687700 ) -> Place < ' tcx > {
@@ -693,6 +706,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
693706 if let Some ( region_scope) = self . region_scope_tree . var_scope ( var. 0 . local_id ) && schedule_drop {
694707 self . schedule_drop ( span, region_scope, local_id, DropKind :: Storage ) ;
695708 }
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+ }
696713 Place :: from ( local_id)
697714 }
698715
@@ -914,6 +931,7 @@ struct Binding<'tcx> {
914931 source : Place < ' tcx > ,
915932 var_id : LocalVarId ,
916933 binding_mode : BindingMode ,
934+ is_shorthand : bool ,
917935}
918936
919937/// Indicates that the type of `source` must be a subtype of the
@@ -2124,6 +2142,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
21242142 block,
21252143 binding. var_id ,
21262144 binding. span ,
2145+ binding. is_shorthand ,
21272146 RefWithinGuard ,
21282147 schedule_drops,
21292148 ) ;
@@ -2137,6 +2156,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
21372156 block,
21382157 binding. var_id ,
21392158 binding. span ,
2159+ binding. is_shorthand ,
21402160 OutsideGuard ,
21412161 schedule_drops,
21422162 ) ;
@@ -2175,6 +2195,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
21752195 block,
21762196 binding. var_id ,
21772197 binding. span ,
2198+ binding. is_shorthand ,
21782199 OutsideGuard ,
21792200 schedule_drops,
21802201 )
@@ -2234,6 +2255,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
22342255 opt_ty_info : None ,
22352256 opt_match_place,
22362257 pat_span,
2258+ introductions : Vec :: new ( ) ,
22372259 } ,
22382260 ) ) ) ) ,
22392261 } ;
0 commit comments