Skip to content

Commit

Permalink
Similar names ignore underscore prefixed names
Browse files Browse the repository at this point in the history
  • Loading branch information
camsteffen committed Jan 12, 2021
1 parent 13ca5c8 commit f2d4935
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions clippy_lints/src/non_expressive_names.rs
Expand Up @@ -199,6 +199,10 @@ impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> {
);
return;
}
if interned_name.starts_with('_') {
// these bindings are typically unused or represent an ignored portion of a destructuring pattern
return;
}
let count = interned_name.chars().count();
if count < 3 {
if count == 1 {
Expand Down
5 changes: 5 additions & 0 deletions tests/ui/similar_names.rs
Expand Up @@ -101,3 +101,8 @@ pub(crate) struct DirSizes {
pub(crate) numb_reg_cache_entries: u64,
pub(crate) numb_reg_src_checkouts: u64,
}

fn ignore_underscore_prefix() {
let hello: ();
let _hello: ();
}

0 comments on commit f2d4935

Please sign in to comment.