@@ -11,7 +11,7 @@ use rustc_data_structures::fx::FxHashSet;
11
11
use rustc_hir as hir;
12
12
use rustc_hir:: def_id:: DefId ;
13
13
use rustc_hir:: intravisit:: { self , NestedVisitorMap , Visitor } ;
14
- use rustc_hir:: { Arm , Block , Expr , Local , Node , Pat , PatKind , Stmt } ;
14
+ use rustc_hir:: { Arm , Block , Expr , Local , Node , Pat , PatKind , Stmt , HirId } ;
15
15
use rustc_index:: vec:: Idx ;
16
16
use rustc_middle:: middle:: region:: * ;
17
17
use rustc_middle:: ty:: query:: Providers ;
@@ -432,6 +432,7 @@ fn resolve_local<'tcx>(
432
432
visitor : & mut RegionResolutionVisitor < ' tcx > ,
433
433
pat : Option < & ' tcx hir:: Pat < ' tcx > > ,
434
434
init : Option < & ' tcx hir:: Expr < ' tcx > > ,
435
+ local_hir_id : Option < HirId > ,
435
436
) {
436
437
debug ! ( "resolve_local(pat={:?}, init={:?})" , pat, init) ;
437
438
@@ -493,6 +494,10 @@ fn resolve_local<'tcx>(
493
494
// A, but the inner rvalues `a()` and `b()` have an extended lifetime
494
495
// due to rule C.
495
496
497
+ if let Some ( hir_id) = local_hir_id {
498
+ visitor. enter_node_scope_with_dtor ( hir_id. local_id ) ;
499
+ }
500
+
496
501
if let Some ( expr) = init {
497
502
record_rvalue_scope_if_borrow_expr ( visitor, & expr, blk_scope) ;
498
503
@@ -767,7 +772,7 @@ impl<'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> {
767
772
// (i.e., `'static`), which means that after `g` returns, it drops,
768
773
// and all the associated destruction scope rules apply.
769
774
self . cx . var_parent = None ;
770
- resolve_local ( self , None , Some ( & body. value ) ) ;
775
+ resolve_local ( self , None , Some ( & body. value ) , None ) ;
771
776
}
772
777
773
778
if body. generator_kind . is_some ( ) {
@@ -794,7 +799,7 @@ impl<'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> {
794
799
resolve_expr ( self , ex) ;
795
800
}
796
801
fn visit_local ( & mut self , l : & ' tcx Local < ' tcx > ) {
797
- resolve_local ( self , Some ( & l. pat ) , l. init . as_deref ( ) ) ;
802
+ resolve_local ( self , Some ( & l. pat ) , l. init . as_deref ( ) , Some ( l . hir_id ) ) ;
798
803
}
799
804
}
800
805
0 commit comments