don't lint macro_rules! in items_after_statements
This commit is contained in:
@@ -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);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user