Skip to content

Commit f2d4935

Browse files
committed
Similar names ignore underscore prefixed names
1 parent 13ca5c8 commit f2d4935

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

clippy_lints/src/non_expressive_names.rs

+4
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> {
199199
);
200200
return;
201201
}
202+
if interned_name.starts_with('_') {
203+
// these bindings are typically unused or represent an ignored portion of a destructuring pattern
204+
return;
205+
}
202206
let count = interned_name.chars().count();
203207
if count < 3 {
204208
if count == 1 {

tests/ui/similar_names.rs

+5
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,8 @@ pub(crate) struct DirSizes {
101101
pub(crate) numb_reg_cache_entries: u64,
102102
pub(crate) numb_reg_src_checkouts: u64,
103103
}
104+
105+
fn ignore_underscore_prefix() {
106+
let hello: ();
107+
let _hello: ();
108+
}

0 commit comments

Comments
 (0)