@@ -2574,33 +2574,31 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
25742574 }
25752575 impl < ' hir > Visitor < ' hir > for ExpressionFinder < ' hir > {
25762576 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 {
25792579 kind : hir:: ClosureKind :: Closure ,
25802580 body,
25812581 fn_arg_span,
25822582 fn_decl : hir:: FnDecl { inputs, .. } ,
25832583 ..
25842584 } ) = 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 ( ", " ) ;
25952590 }
2591+ self . in_closure = true ;
2592+ self . closure_arg_span = fn_arg_span;
2593+ self . visit_expr ( body) ;
2594+ self . in_closure = false ;
25962595 }
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 ) ;
26042602 }
26052603 hir:: intravisit:: walk_expr ( self , e) ;
26062604 }
@@ -2609,20 +2607,19 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
26092607 if let hir:: Pat { kind : hir:: PatKind :: Binding ( _, hir_id, _ident, _) , .. } =
26102608 local. pat
26112609 && let Some ( init) = local. init
2612- {
2613- if let hir:: Expr {
2610+ && let hir:: Expr {
26142611 kind :
26152612 hir:: ExprKind :: Closure ( & hir:: Closure {
26162613 kind : hir:: ClosureKind :: Closure ,
26172614 ..
26182615 } ) ,
26192616 ..
26202617 } = 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) ;
26252621 }
2622+
26262623 hir:: intravisit:: walk_local ( self , local) ;
26272624 }
26282625
0 commit comments