Skip to content

Commit 2d145b2

Browse files
committed
don't lint macro_rules! in items_after_statements
1 parent 9aebb59 commit 2d145b2

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

clippy_lints/src/items_after_statements.rs

+4
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ impl EarlyLintPass for ItemsAfterStatements {
5858
if in_macro(cx, it.span) {
5959
return;
6060
}
61+
if let ItemKind::MacroDef(..) = it.node {
62+
// do not lint `macro_rules`, but continue processing further statements
63+
continue;
64+
}
6165
span_lint(cx,
6266
ITEMS_AFTER_STATEMENTS,
6367
it.span,

tests/ui/item_after_statement.rs

+11
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,14 @@ fn main() {
1717
fn foo() { println!("foo"); }
1818
foo();
1919
}
20+
21+
fn mac() {
22+
let mut a = 5;
23+
println!("{}", a);
24+
// do not lint this, because it needs to be after `a`
25+
macro_rules! b {
26+
() => {{ a = 6 }}
27+
}
28+
b!();
29+
println!("{}", a);
30+
}

0 commit comments

Comments
 (0)