Skip to content

Commit 0e5aee1

Browse files
committed
items_after_statements: don't lint when they a separated by trailing semicolons
1 parent c1b9915 commit 0e5aee1

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

clippy_lints/src/items_after_statements.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ impl EarlyLintPass for ItemsAfterStatements {
5858
return;
5959
}
6060

61-
// skip initial items
61+
// skip initial items and trailing semicolons
6262
let stmts = item
6363
.stmts
6464
.iter()
6565
.map(|stmt| &stmt.kind)
66-
.skip_while(|s| matches!(**s, StmtKind::Item(..)));
66+
.skip_while(|s| matches!(**s, StmtKind::Item(..) | StmtKind::Empty));
6767

6868
// lint on all further items
6969
for stmt in stmts {

tests/ui/item_after_statement.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,16 @@ fn mac() {
3737
b!();
3838
println!("{}", a);
3939
}
40+
41+
fn semicolon() {
42+
struct S {
43+
a: u32,
44+
};
45+
impl S {
46+
fn new(a: u32) -> Self {
47+
Self { a }
48+
}
49+
}
50+
51+
let _ = S::new(3);
52+
}

0 commit comments

Comments
 (0)