mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 15:11:30 +00:00
don't lint macro_rules! in items_after_statements
This commit is contained in:
parent
9aebb59a68
commit
2d145b2ef5
2 changed files with 15 additions and 0 deletions
|
@ -58,6 +58,10 @@ impl EarlyLintPass for ItemsAfterStatements {
|
||||||
if in_macro(cx, it.span) {
|
if in_macro(cx, it.span) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if let ItemKind::MacroDef(..) = it.node {
|
||||||
|
// do not lint `macro_rules`, but continue processing further statements
|
||||||
|
continue;
|
||||||
|
}
|
||||||
span_lint(cx,
|
span_lint(cx,
|
||||||
ITEMS_AFTER_STATEMENTS,
|
ITEMS_AFTER_STATEMENTS,
|
||||||
it.span,
|
it.span,
|
||||||
|
|
|
@ -17,3 +17,14 @@ fn main() {
|
||||||
fn foo() { println!("foo"); }
|
fn foo() { println!("foo"); }
|
||||||
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);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue