mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
Auto merge of #13462 - y21:issue13459, r=dswij
`zombie_processes`: consider `wait()` calls in nested bodies Fixes #13459 Small oversight. We weren't considering uses of the local in closures. changelog: none
This commit is contained in:
commit
71c7d445db
2 changed files with 14 additions and 0 deletions
|
@ -6,6 +6,7 @@ use rustc_errors::Applicability;
|
|||
use rustc_hir::intravisit::{Visitor, walk_block, walk_expr, walk_local};
|
||||
use rustc_hir::{Expr, ExprKind, HirId, LetStmt, Node, PatKind, Stmt, StmtKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::hir::nested_filter;
|
||||
use rustc_session::declare_lint_pass;
|
||||
use rustc_span::sym;
|
||||
use std::ops::ControlFlow;
|
||||
|
@ -119,6 +120,7 @@ enum WaitFinder<'a, 'tcx> {
|
|||
}
|
||||
|
||||
impl<'tcx> Visitor<'tcx> for WaitFinder<'_, 'tcx> {
|
||||
type NestedFilter = nested_filter::OnlyBodies;
|
||||
type Result = ControlFlow<BreakReason>;
|
||||
|
||||
fn visit_local(&mut self, l: &'tcx LetStmt<'tcx>) -> Self::Result {
|
||||
|
@ -204,6 +206,11 @@ impl<'tcx> Visitor<'tcx> for WaitFinder<'_, 'tcx> {
|
|||
|
||||
walk_expr(self, ex)
|
||||
}
|
||||
|
||||
fn nested_visit_map(&mut self) -> Self::Map {
|
||||
let (Self::Found(cx, _) | Self::WalkUpTo(cx, _)) = self;
|
||||
cx.tcx.hir()
|
||||
}
|
||||
}
|
||||
|
||||
/// This function has shared logic between the different kinds of nodes that can trigger the lint.
|
||||
|
|
|
@ -131,6 +131,13 @@ fn main() {
|
|||
}
|
||||
x.wait().unwrap();
|
||||
}
|
||||
|
||||
{
|
||||
let mut x = Command::new("").spawn().unwrap();
|
||||
std::thread::spawn(move || {
|
||||
x.wait().unwrap();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn process_child(c: Child) {
|
||||
|
|
Loading…
Reference in a new issue