about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJason Newcomb <jsnewcomb@pm.me>2024-06-09 22:29:11 -0400
committerJason Newcomb <jsnewcomb@pm.me>2024-07-05 03:07:32 -0400
commit441500b55b4529e8ba231c8b7165f8686f32e67c (patch)
tree197d159c16931990461fc7922071886881db33e3
parentd15ec0ff852f8e1befc34e83dc2865b78f506898 (diff)
downloadrust-441500b55b4529e8ba231c8b7165f8686f32e67c.tar.gz
rust-441500b55b4529e8ba231c8b7165f8686f32e67c.zip
Refactor `else_if_without_else`: Check the AST before the macro check.
-rw-r--r--clippy_lints/src/else_if_without_else.rs5
1 files changed, 1 insertions, 4 deletions
diff --git a/clippy_lints/src/else_if_without_else.rs b/clippy_lints/src/else_if_without_else.rs
index bb6f9aac223..7a6dc469727 100644
--- a/clippy_lints/src/else_if_without_else.rs
+++ b/clippy_lints/src/else_if_without_else.rs
@@ -50,12 +50,9 @@ declare_lint_pass!(ElseIfWithoutElse => [ELSE_IF_WITHOUT_ELSE]);
 
 impl EarlyLintPass for ElseIfWithoutElse {
     fn check_expr(&mut self, cx: &EarlyContext<'_>, item: &Expr) {
-        if in_external_macro(cx.sess(), item.span) {
-            return;
-        }
-
         if let ExprKind::If(_, _, Some(ref els)) = item.kind
             && let ExprKind::If(_, _, None) = els.kind
+            && !in_external_macro(cx.sess(), item.span)
         {
             span_lint_and_help(
                 cx,