don't lint macro_rules! in items_after_statements

This commit is contained in:
Oliver Schneider 2017-03-13 11:09:56 +01:00
parent 9aebb59a68
commit 2d145b2ef5
2 changed files with 15 additions and 0 deletions

View file

@ -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,

View file

@ -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);
}