mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-15 01:17:16 +00:00
Auto merge of #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.
This commit is contained in:
commit
d75bc868ca
3 changed files with 17 additions and 4 deletions
|
@ -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 {
|
||||
|
|
|
@ -104,7 +104,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClosureCall {
|
|||
cx: &'a LateContext<'tcx>,
|
||||
path: &'tcx hir::Path<'tcx>,
|
||||
count: usize,
|
||||
};
|
||||
}
|
||||
impl<'a, 'tcx> hir_visit::Visitor<'tcx> for ClosureUsageCount<'a, 'tcx> {
|
||||
type Map = Map<'tcx>;
|
||||
|
||||
|
@ -124,7 +124,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClosureCall {
|
|||
fn nested_visit_map(&mut self) -> hir_visit::NestedVisitorMap<Self::Map> {
|
||||
hir_visit::NestedVisitorMap::OnlyBodies(self.cx.tcx.hir())
|
||||
}
|
||||
};
|
||||
}
|
||||
let mut closure_usage_count = ClosureUsageCount { cx, path, count: 0 };
|
||||
closure_usage_count.visit_block(block);
|
||||
closure_usage_count.count
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue