don't unnecessarily walk more in visitor and add more tests

This commit is contained in:
y21 2023-06-15 22:04:25 +02:00
parent e305b0730f
commit 3fe2478ecf
4 changed files with 30 additions and 4 deletions

View file

@ -55,9 +55,9 @@ impl<'tcx> Visitor<'tcx> for ReturnVisitor {
fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) {
if let hir::ExprKind::Ret(_) | hir::ExprKind::Match(.., hir::MatchSource::TryDesugar) = ex.kind {
self.found_return = true;
} else {
hir_visit::walk_expr(self, ex);
}
hir_visit::walk_expr(self, ex);
}
}
@ -122,7 +122,7 @@ fn get_parent_call_exprs<'tcx>(
let mut depth = 1;
while let Some(parent) = get_parent_expr(cx, expr)
&& let hir::ExprKind::Call(recv, _) = parent.kind
&& let hir::ExprKind::Call(..) = recv.kind
&& expr.span == recv.span
{
expr = parent;
depth += 1;