@@ -60,19 +60,18 @@ impl<'tcx> LateLintPass<'tcx> for ZombieProcesses {
60
60
}
61
61
62
62
// Don't emit a suggestion since the binding is used later
63
- check ( cx, expr, local . hir_id , false ) ;
63
+ check ( cx, expr, false ) ;
64
64
} ,
65
- Node :: LetStmt ( & LetStmt { pat, hir_id , .. } ) if let PatKind :: Wild = pat. kind => {
65
+ Node :: LetStmt ( & LetStmt { pat, .. } ) if let PatKind :: Wild = pat. kind => {
66
66
// `let _ = child;`, also dropped immediately without `wait()`ing
67
- check ( cx, expr, hir_id , true ) ;
67
+ check ( cx, expr, true ) ;
68
68
} ,
69
69
Node :: Stmt ( & Stmt {
70
70
kind : StmtKind :: Semi ( _) ,
71
- hir_id,
72
71
..
73
72
} ) => {
74
73
// Immediately dropped. E.g. `std::process::Command::new("echo").spawn().unwrap();`
75
- check ( cx, expr, hir_id , true ) ;
74
+ check ( cx, expr, true ) ;
76
75
} ,
77
76
_ => { } ,
78
77
}
@@ -212,9 +211,8 @@ impl<'a, 'tcx> Visitor<'tcx> for WaitFinder<'a, 'tcx> {
212
211
/// such as checking that the binding is not used in certain ways, which isn't necessary for
213
212
/// `let _ = <expr that spawns child>;`.
214
213
///
215
- /// This checks if the program doesn't unconditionally exit after the spawn expression and that it
216
- /// isn't the last statement of the program.
217
- fn check < ' tcx > ( cx : & LateContext < ' tcx > , spawn_expr : & ' tcx Expr < ' tcx > , node_id : HirId , emit_suggestion : bool ) {
214
+ /// This checks if the program doesn't unconditionally exit after the spawn expression.
215
+ fn check < ' tcx > ( cx : & LateContext < ' tcx > , spawn_expr : & ' tcx Expr < ' tcx > , emit_suggestion : bool ) {
218
216
let Some ( block) = get_enclosing_block ( cx, spawn_expr. hir_id ) else {
219
217
return ;
220
218
} ;
@@ -228,12 +226,6 @@ fn check<'tcx>(cx: &LateContext<'tcx>, spawn_expr: &'tcx Expr<'tcx>, node_id: Hi
228
226
return ;
229
227
}
230
228
231
- // This might be the last effective node of the program (main function).
232
- // There's no need to lint in that case either, as this is basically equivalent to calling `exit()`
233
- if is_last_node_in_main ( cx, node_id) {
234
- return ;
235
- }
236
-
237
229
span_lint_and_then (
238
230
cx,
239
231
ZOMBIE_PROCESSES ,
@@ -257,26 +249,6 @@ fn check<'tcx>(cx: &LateContext<'tcx>, spawn_expr: &'tcx Expr<'tcx>, node_id: Hi
257
249
) ;
258
250
}
259
251
260
- /// The hir id id may either correspond to a `Local` or `Stmt`, depending on how we got here.
261
- /// This function gets the enclosing function, checks if it's `main` and if so,
262
- /// check if the last statement modulo blocks is the given id.
263
- fn is_last_node_in_main ( cx : & LateContext < ' _ > , id : HirId ) -> bool {
264
- let hir = cx. tcx . hir ( ) ;
265
- let body_owner = hir. enclosing_body_owner ( id) ;
266
- let enclosing_body = hir. body_owned_by ( body_owner) ;
267
-
268
- if let Some ( ( main_def_id, _) ) = cx. tcx . entry_fn ( ( ) )
269
- && main_def_id == body_owner. to_def_id ( )
270
- && let ExprKind :: Block ( block, _) = & enclosing_body. value . peel_blocks ( ) . kind
271
- && let [ .., stmt] = block. stmts
272
- {
273
- matches ! ( stmt. kind, StmtKind :: Let ( local) if local. hir_id == id)
274
- || matches ! ( stmt. kind, StmtKind :: Semi ( ..) if stmt. hir_id == id)
275
- } else {
276
- false
277
- }
278
- }
279
-
280
252
/// Checks if the given expression exits the process.
281
253
fn is_exit_expression ( cx : & LateContext < ' _ > , expr : & Expr < ' _ > ) -> bool {
282
254
fn_def_id ( cx, expr) . is_some_and ( |fn_did| {
0 commit comments