Skip to content

Commit d75bc86

Browse files
committed
Auto merge of rust-lang#6396 - flip1995:rustup, r=ebroto
Rustup? Basically a rustup from an unknown source. I added a regression test (and slightly changed the lint), so this'll need a review. changelog: Fix bug in [`items_after_statements`] wher it triggered, if items were separated by trailing semicolons.
2 parents 7a73a25 + 0e5aee1 commit d75bc86

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
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 {

clippy_lints/src/redundant_closure_call.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClosureCall {
104104
cx: &'a LateContext<'tcx>,
105105
path: &'tcx hir::Path<'tcx>,
106106
count: usize,
107-
};
107+
}
108108
impl<'a, 'tcx> hir_visit::Visitor<'tcx> for ClosureUsageCount<'a, 'tcx> {
109109
type Map = Map<'tcx>;
110110

@@ -124,7 +124,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClosureCall {
124124
fn nested_visit_map(&mut self) -> hir_visit::NestedVisitorMap<Self::Map> {
125125
hir_visit::NestedVisitorMap::OnlyBodies(self.cx.tcx.hir())
126126
}
127-
};
127+
}
128128
let mut closure_usage_count = ClosureUsageCount { cx, path, count: 0 };
129129
closure_usage_count.visit_block(block);
130130
closure_usage_count.count

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)