diff --git a/clippy_lints/src/items_after_statements.rs b/clippy_lints/src/items_after_statements.rs index 3b3cd423729b..5789f6a5f80b 100644 --- a/clippy_lints/src/items_after_statements.rs +++ b/clippy_lints/src/items_after_statements.rs @@ -58,6 +58,10 @@ impl EarlyLintPass for ItemsAfterStatements { if in_macro(cx, it.span) { return; } + if let ItemKind::MacroDef(..) = it.node { + // do not lint `macro_rules`, but continue processing further statements + continue; + } span_lint(cx, ITEMS_AFTER_STATEMENTS, it.span, diff --git a/src/main.rs b/src/main.rs index 12dd5d1f695b..1ca0d2b92f34 100644 --- a/src/main.rs +++ b/src/main.rs @@ -89,7 +89,6 @@ impl<'a> CompilerCalls<'a> for ClippyCompilerCalls { lint_groups, llvm_passes, attributes, - mir_passes, .. } = registry; let sess = &state.session; let mut ls = sess.lint_store.borrow_mut(); @@ -105,7 +104,6 @@ impl<'a> CompilerCalls<'a> for ClippyCompilerCalls { } sess.plugin_llvm_passes.borrow_mut().extend(llvm_passes); - sess.mir_passes.borrow_mut().extend(mir_passes); sess.plugin_attributes.borrow_mut().extend(attributes); } old(state); diff --git a/tests/ui/item_after_statement.rs b/tests/ui/item_after_statement.rs index 09b509673dc3..5ba94383cc69 100644 --- a/tests/ui/item_after_statement.rs +++ b/tests/ui/item_after_statement.rs @@ -17,3 +17,14 @@ fn main() { fn foo() { println!("foo"); } foo(); } + +fn mac() { + let mut a = 5; + println!("{}", a); + // do not lint this, because it needs to be after `a` + macro_rules! b { + () => {{ a = 6 }} + } + b!(); + println!("{}", a); +}