@@ -495,13 +495,19 @@ fn resolve_expr<'tcx>(
495
495
visitor. cx = prev_cx;
496
496
}
497
497
498
+ #[ derive( Copy , Clone , PartialEq , Eq , Debug ) ]
499
+ enum LetKind {
500
+ Regular ,
501
+ Super ,
502
+ }
503
+
498
504
fn resolve_local < ' tcx > (
499
505
visitor : & mut ScopeResolutionVisitor < ' tcx > ,
500
506
pat : Option < & ' tcx hir:: Pat < ' tcx > > ,
501
507
init : Option < & ' tcx hir:: Expr < ' tcx > > ,
502
- super_let : bool ,
508
+ let_kind : LetKind ,
503
509
) {
504
- debug ! ( "resolve_local(pat={:?}, init={:?}, super_let ={:?})" , pat, init, super_let ) ;
510
+ debug ! ( "resolve_local(pat={:?}, init={:?}, let_kind ={:?})" , pat, init, let_kind ) ;
505
511
506
512
// As an exception to the normal rules governing temporary
507
513
// lifetimes, initializers in a let have a temporary lifetime
@@ -559,7 +565,7 @@ fn resolve_local<'tcx>(
559
565
// A, but the inner rvalues `a()` and `b()` have an extended lifetime
560
566
// due to rule C.
561
567
562
- if super_let {
568
+ if let_kind == LetKind :: Super {
563
569
if let Some ( scope) = visitor. extended_super_lets . remove ( & pat. unwrap ( ) . hir_id . local_id ) {
564
570
// This expression was lifetime-extended by a parent let binding. E.g.
565
571
//
@@ -861,7 +867,7 @@ impl<'tcx> Visitor<'tcx> for ScopeResolutionVisitor<'tcx> {
861
867
local_id : body. value . hir_id . local_id ,
862
868
data : ScopeData :: Destruction ,
863
869
} ) ;
864
- resolve_local ( this, None , Some ( body. value ) , false ) ;
870
+ resolve_local ( this, None , Some ( body. value ) , LetKind :: Regular ) ;
865
871
}
866
872
} )
867
873
}
@@ -879,7 +885,11 @@ impl<'tcx> Visitor<'tcx> for ScopeResolutionVisitor<'tcx> {
879
885
resolve_expr ( self , ex, false ) ;
880
886
}
881
887
fn visit_local ( & mut self , l : & ' tcx LetStmt < ' tcx > ) {
882
- resolve_local ( self , Some ( l. pat ) , l. init , l. super_ . is_some ( ) ) ;
888
+ let let_kind = match l. super_ {
889
+ Some ( _) => LetKind :: Super ,
890
+ None => LetKind :: Regular ,
891
+ } ;
892
+ resolve_local ( self , Some ( l. pat ) , l. init , let_kind) ;
883
893
}
884
894
fn visit_inline_const ( & mut self , c : & ' tcx hir:: ConstBlock ) {
885
895
let body = self . tcx . hir_body ( c. body ) ;
0 commit comments