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
@ -6,6 +6,7 @@ use rustc_errors::Applicability;
|
|||||||
use rustc_hir::intravisit::{Visitor, walk_block, walk_expr, walk_local};
|
use rustc_hir::intravisit::{Visitor, walk_block, walk_expr, walk_local};
|
||||||
use rustc_hir::{Expr, ExprKind, HirId, LetStmt, Node, PatKind, Stmt, StmtKind};
|
use rustc_hir::{Expr, ExprKind, HirId, LetStmt, Node, PatKind, Stmt, StmtKind};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
|
use rustc_middle::hir::nested_filter;
|
||||||
use rustc_session::declare_lint_pass;
|
use rustc_session::declare_lint_pass;
|
||||||
use rustc_span::sym;
|
use rustc_span::sym;
|
||||||
use std::ops::ControlFlow;
|
use std::ops::ControlFlow;
|
||||||
@ -119,6 +120,7 @@ enum WaitFinder<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Visitor<'tcx> for WaitFinder<'_, 'tcx> {
|
impl<'tcx> Visitor<'tcx> for WaitFinder<'_, 'tcx> {
|
||||||
|
type NestedFilter = nested_filter::OnlyBodies;
|
||||||
type Result = ControlFlow<BreakReason>;
|
type Result = ControlFlow<BreakReason>;
|
||||||
|
|
||||||
fn visit_local(&mut self, l: &'tcx LetStmt<'tcx>) -> Self::Result {
|
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)
|
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.
|
/// 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();
|
x.wait().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
let mut x = Command::new("").spawn().unwrap();
|
||||||
|
std::thread::spawn(move || {
|
||||||
|
x.wait().unwrap();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process_child(c: Child) {
|
fn process_child(c: Child) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user