items_after_statements: don't lint when they a separated by trailing semicolons

This commit is contained in:
flip1995 2020-11-28 17:18:15 +01:00
parent c1b991588f
commit 0e5aee1fc1
No known key found for this signature in database
GPG Key ID: 2CEFCDB27ED0BE79
2 changed files with 15 additions and 2 deletions

View File

@ -58,12 +58,12 @@ impl EarlyLintPass for ItemsAfterStatements {
return;
}
// skip initial items
// skip initial items and trailing semicolons
let stmts = item
.stmts
.iter()
.map(|stmt| &stmt.kind)
.skip_while(|s| matches!(**s, StmtKind::Item(..)));
.skip_while(|s| matches!(**s, StmtKind::Item(..) | StmtKind::Empty));
// lint on all further items
for stmt in stmts {

View File

@ -37,3 +37,16 @@ fn mac() {
b!();
println!("{}", a);
}
fn semicolon() {
struct S {
a: u32,
};
impl S {
fn new(a: u32) -> Self {
Self { a }
}
}
let _ = S::new(3);
}