[many_single_char_names]: Deduplicate diagnostics

This commit is contained in:
cookie-s 2024-05-26 22:39:23 -04:00
parent 674c641ecf
commit 7110f471d3
No known key found for this signature in database
GPG Key ID: 4D8C63ADDD1637A0
3 changed files with 9 additions and 7 deletions

View File

@ -98,6 +98,10 @@ struct SimilarNamesLocalVisitor<'a, 'tcx> {
impl<'a, 'tcx> SimilarNamesLocalVisitor<'a, 'tcx> {
fn check_single_char_names(&self) {
if self.single_char_names.last().map(Vec::len) == Some(0) {
return;
}
let num_single_char_names = self.single_char_names.iter().flatten().count();
let threshold = self.lint.single_char_binding_names_threshold;
if num_single_char_names as u64 > threshold {

View File

@ -1,5 +1,3 @@
//@compile-flags: -Zdeduplicate-diagnostics=yes
#![allow(clippy::too_many_arguments, clippy::diverging_sub_expression)]
#![warn(clippy::many_single_char_names)]

View File

@ -1,5 +1,5 @@
error: 5 bindings with single-character names in scope
--> tests/ui/many_single_char_names.rs:7:9
--> tests/ui/many_single_char_names.rs:5:9
|
LL | let a: i32;
| ^
@ -14,7 +14,7 @@ LL | let e: i32;
= help: to override `-D warnings` add `#[allow(clippy::many_single_char_names)]`
error: 6 bindings with single-character names in scope
--> tests/ui/many_single_char_names.rs:7:9
--> tests/ui/many_single_char_names.rs:5:9
|
LL | let a: i32;
| ^
@ -28,7 +28,7 @@ LL | let f: i32;
| ^
error: 5 bindings with single-character names in scope
--> tests/ui/many_single_char_names.rs:7:9
--> tests/ui/many_single_char_names.rs:5:9
|
LL | let a: i32;
| ^
@ -40,13 +40,13 @@ LL | e => panic!(),
| ^
error: 8 bindings with single-character names in scope
--> tests/ui/many_single_char_names.rs:36:13
--> tests/ui/many_single_char_names.rs:34:13
|
LL | fn bindings(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, g: i32, h: i32) {}
| ^ ^ ^ ^ ^ ^ ^ ^
error: 8 bindings with single-character names in scope
--> tests/ui/many_single_char_names.rs:40:10
--> tests/ui/many_single_char_names.rs:38:10
|
LL | let (a, b, c, d, e, f, g, h): (bool, bool, bool, bool, bool, bool, bool, bool) = unimplemented!();
| ^ ^ ^ ^ ^ ^ ^ ^