@@ -5,7 +5,7 @@ use rustc_ast::Mutability;
5
5
use rustc_ast:: visit:: visit_opt;
6
6
use rustc_errors:: Applicability ;
7
7
use rustc_hir:: def_id:: LocalDefId ;
8
- use rustc_hir:: intravisit:: { Visitor , walk_block, walk_expr, walk_local } ;
8
+ use rustc_hir:: intravisit:: { Visitor , walk_block, walk_expr} ;
9
9
use rustc_hir:: { Expr , ExprKind , HirId , LetStmt , Node , PatKind , Stmt , StmtKind } ;
10
10
use rustc_lint:: { LateContext , LateLintPass } ;
11
11
use rustc_middle:: hir:: nested_filter;
@@ -69,8 +69,9 @@ impl<'tcx> LateLintPass<'tcx> for ZombieProcesses {
69
69
let mut vis = WaitFinder {
70
70
cx,
71
71
local_id,
72
+ create_id : expr. hir_id ,
72
73
body_id : cx. tcx . hir_enclosing_body_owner ( expr. hir_id ) ,
73
- state : VisitorState :: WalkUpToLocal ,
74
+ state : VisitorState :: WalkUpToCreate ,
74
75
early_return : None ,
75
76
missing_wait_branch : None ,
76
77
} ;
@@ -131,6 +132,7 @@ struct MaybeWait(Span);
131
132
struct WaitFinder < ' a , ' tcx > {
132
133
cx : & ' a LateContext < ' tcx > ,
133
134
local_id : HirId ,
135
+ create_id : HirId ,
134
136
body_id : LocalDefId ,
135
137
state : VisitorState ,
136
138
early_return : Option < Span > ,
@@ -141,8 +143,8 @@ struct WaitFinder<'a, 'tcx> {
141
143
142
144
#[ derive( PartialEq ) ]
143
145
enum VisitorState {
144
- WalkUpToLocal ,
145
- LocalFound ,
146
+ WalkUpToCreate ,
147
+ CreateFound ,
146
148
}
147
149
148
150
#[ derive( Copy , Clone ) ]
@@ -155,19 +157,13 @@ impl<'tcx> Visitor<'tcx> for WaitFinder<'_, 'tcx> {
155
157
type NestedFilter = nested_filter:: OnlyBodies ;
156
158
type Result = ControlFlow < MaybeWait > ;
157
159
158
- fn visit_local ( & mut self , l : & ' tcx LetStmt < ' tcx > ) -> Self :: Result {
159
- if self . state == VisitorState :: WalkUpToLocal
160
- && let PatKind :: Binding ( _, pat_id, ..) = l. pat . kind
161
- && self . local_id == pat_id
162
- {
163
- self . state = VisitorState :: LocalFound ;
160
+ fn visit_expr ( & mut self , ex : & ' tcx Expr < ' tcx > ) -> Self :: Result {
161
+ if ex. hir_id == self . create_id {
162
+ self . state = VisitorState :: CreateFound ;
163
+ return Continue ( ( ) ) ;
164
164
}
165
165
166
- walk_local ( self , l)
167
- }
168
-
169
- fn visit_expr ( & mut self , ex : & ' tcx Expr < ' tcx > ) -> Self :: Result {
170
- if self . state != VisitorState :: LocalFound {
166
+ if self . state != VisitorState :: CreateFound {
171
167
return walk_expr ( self , ex) ;
172
168
}
173
169
0 commit comments