From 108c04acf0bdb90e68ec7c12e86c5fbb21548061 Mon Sep 17 00:00:00 2001 From: Centri3 <114838443+Centri3@users.noreply.github.com> Date: Sun, 11 Jun 2023 09:43:26 -0500 Subject: [PATCH] Stop visiting once it's found `Let` --- clippy_lints/src/needless_if.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clippy_lints/src/needless_if.rs b/clippy_lints/src/needless_if.rs index b118516e09b..dbffbd6f0d3 100644 --- a/clippy_lints/src/needless_if.rs +++ b/clippy_lints/src/needless_if.rs @@ -96,8 +96,8 @@ impl Visitor<'_> for IsAnyLetVisitor { fn visit_expr(&mut self, expr: &Expr<'_>) { if matches!(expr.kind, ExprKind::Let(..)) { self.0 = true; + } else { + walk_expr(self, expr); } - - walk_expr(self, expr); } }