@@ -2574,33 +2574,31 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
2574
2574
}
2575
2575
impl < ' hir > Visitor < ' hir > for ExpressionFinder < ' hir > {
2576
2576
fn visit_expr ( & mut self , e : & ' hir hir:: Expr < ' hir > ) {
2577
- if e. span . contains ( self . capture_span ) {
2578
- if let hir:: ExprKind :: Closure ( & hir:: Closure {
2577
+ if e. span . contains ( self . capture_span )
2578
+ && let hir:: ExprKind :: Closure ( & hir:: Closure {
2579
2579
kind : hir:: ClosureKind :: Closure ,
2580
2580
body,
2581
2581
fn_arg_span,
2582
2582
fn_decl : hir:: FnDecl { inputs, .. } ,
2583
2583
..
2584
2584
} ) = e. kind
2585
- && let hir:: Node :: Expr ( body) = self . tcx . hir_node ( body. hir_id )
2586
- {
2587
- self . suggest_arg = "this: &Self" . to_string ( ) ;
2588
- if inputs. len ( ) > 0 {
2589
- self . suggest_arg . push_str ( ", " ) ;
2590
- }
2591
- self . in_closure = true ;
2592
- self . closure_arg_span = fn_arg_span;
2593
- self . visit_expr ( body) ;
2594
- self . in_closure = false ;
2585
+ && let hir:: Node :: Expr ( body) = self . tcx . hir_node ( body. hir_id )
2586
+ {
2587
+ self . suggest_arg = "this: &Self" . to_string ( ) ;
2588
+ if inputs. len ( ) > 0 {
2589
+ self . suggest_arg . push_str ( ", " ) ;
2595
2590
}
2591
+ self . in_closure = true ;
2592
+ self . closure_arg_span = fn_arg_span;
2593
+ self . visit_expr ( body) ;
2594
+ self . in_closure = false ;
2596
2595
}
2597
- if let hir:: Expr { kind : hir:: ExprKind :: Path ( path) , .. } = e {
2598
- if let hir:: QPath :: Resolved ( _, hir:: Path { segments : [ seg] , .. } ) = path
2599
- && seg. ident . name == kw:: SelfLower
2600
- && self . in_closure
2601
- {
2602
- self . closure_change_spans . push ( e. span ) ;
2603
- }
2596
+ if let hir:: Expr { kind : hir:: ExprKind :: Path ( path) , .. } = e
2597
+ && let hir:: QPath :: Resolved ( _, hir:: Path { segments : [ seg] , .. } ) = path
2598
+ && seg. ident . name == kw:: SelfLower
2599
+ && self . in_closure
2600
+ {
2601
+ self . closure_change_spans . push ( e. span ) ;
2604
2602
}
2605
2603
hir:: intravisit:: walk_expr ( self , e) ;
2606
2604
}
@@ -2609,20 +2607,19 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
2609
2607
if let hir:: Pat { kind : hir:: PatKind :: Binding ( _, hir_id, _ident, _) , .. } =
2610
2608
local. pat
2611
2609
&& let Some ( init) = local. init
2612
- {
2613
- if let hir:: Expr {
2610
+ && let hir:: Expr {
2614
2611
kind :
2615
2612
hir:: ExprKind :: Closure ( & hir:: Closure {
2616
2613
kind : hir:: ClosureKind :: Closure ,
2617
2614
..
2618
2615
} ) ,
2619
2616
..
2620
2617
} = init
2621
- && init. span . contains ( self . capture_span )
2622
- {
2623
- self . closure_local_id = Some ( * hir_id) ;
2624
- }
2618
+ && init. span . contains ( self . capture_span )
2619
+ {
2620
+ self . closure_local_id = Some ( * hir_id) ;
2625
2621
}
2622
+
2626
2623
hir:: intravisit:: walk_local ( self , local) ;
2627
2624
}
2628
2625
0 commit comments