Skip to content

Commit 2316f4d

Browse files
committed
Auto merge of #7671 - dtolnay-contrib:singlecharnames, r=xFrednet
Downgrade many_single_char_names to pedantic As suggested by `@flip1995` in #7666 (comment), by today's standards this lint would be considered `pedantic`. This is one of the most widely suppressed Clippy lints on crates.io according to https://github.com/dtolnay/noisy-clippy. In my opinion this lint is just too domain specific for Clippy to have reliable visibility into. Sure there are some cases where the author is just being lazy and could use a kick in the butt, but we're still left with an enormous number of suppressions where single chars are the most appropriate name. For example in the context of colors, a function using `h`, `s`, `l`, `r`, `g`, `b` is 100% sensible and spelling all those out is silly, but it's past the default lint threshold. --- changelog: Moved [`many_single_char_names`] to `pedantic`
2 parents 746a005 + c2783c1 commit 2316f4d

40 files changed

+124
-139
lines changed

clippy_lints/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
11371137
LintId::of(needless_continue::NEEDLESS_CONTINUE),
11381138
LintId::of(needless_for_each::NEEDLESS_FOR_EACH),
11391139
LintId::of(needless_pass_by_value::NEEDLESS_PASS_BY_VALUE),
1140+
LintId::of(non_expressive_names::MANY_SINGLE_CHAR_NAMES),
11401141
LintId::of(non_expressive_names::SIMILAR_NAMES),
11411142
LintId::of(pass_by_ref_or_value::LARGE_TYPES_PASSED_BY_VALUE),
11421143
LintId::of(pass_by_ref_or_value::TRIVIALLY_COPY_PASS_BY_REF),
@@ -1393,7 +1394,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
13931394
LintId::of(non_copy_const::BORROW_INTERIOR_MUTABLE_CONST),
13941395
LintId::of(non_copy_const::DECLARE_INTERIOR_MUTABLE_CONST),
13951396
LintId::of(non_expressive_names::JUST_UNDERSCORES_AND_DIGITS),
1396-
LintId::of(non_expressive_names::MANY_SINGLE_CHAR_NAMES),
13971397
LintId::of(non_octal_unix_permissions::NON_OCTAL_UNIX_PERMISSIONS),
13981398
LintId::of(open_options::NONSENSICAL_OPEN_OPTIONS),
13991399
LintId::of(option_env_unwrap::OPTION_ENV_UNWRAP),
@@ -1567,7 +1567,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
15671567
LintId::of(non_copy_const::BORROW_INTERIOR_MUTABLE_CONST),
15681568
LintId::of(non_copy_const::DECLARE_INTERIOR_MUTABLE_CONST),
15691569
LintId::of(non_expressive_names::JUST_UNDERSCORES_AND_DIGITS),
1570-
LintId::of(non_expressive_names::MANY_SINGLE_CHAR_NAMES),
15711570
LintId::of(ptr::CMP_NULL),
15721571
LintId::of(ptr::PTR_ARG),
15731572
LintId::of(ptr_eq::PTR_EQ),

clippy_lints/src/non_expressive_names.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ declare_clippy_lint! {
4343
/// let (a, b, c, d, e, f, g) = (...);
4444
/// ```
4545
pub MANY_SINGLE_CHAR_NAMES,
46-
style,
46+
pedantic,
4747
"too many single character bindings"
4848
}
4949

clippy_utils/src/hir_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
540540
std::mem::discriminant(&b.rules).hash(&mut self.s);
541541
}
542542

543-
#[allow(clippy::many_single_char_names, clippy::too_many_lines)]
543+
#[allow(clippy::too_many_lines)]
544544
pub fn hash_expr(&mut self, e: &Expr<'_>) {
545545
let simple_const = self
546546
.maybe_typeck_results

tests/ui-toml/toml_trivially_copy/test.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// normalize-stderr-test "\(limit: \d+ byte\)" -> "(limit: N byte)"
33

44
#![deny(clippy::trivially_copy_pass_by_ref)]
5-
#![allow(clippy::many_single_char_names)]
65

76
#[derive(Copy, Clone)]
87
struct Foo(u8);

tests/ui-toml/toml_trivially_copy/test.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte)
2-
--> $DIR/test.rs:15:11
2+
--> $DIR/test.rs:14:11
33
|
44
LL | fn bad(x: &u16, y: &Foo) {}
55
| ^^^^ help: consider passing by value instead: `u16`
@@ -11,7 +11,7 @@ LL | #![deny(clippy::trivially_copy_pass_by_ref)]
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error: this argument (N byte) is passed by reference, but would be more efficient if passed by value (limit: N byte)
14-
--> $DIR/test.rs:15:20
14+
--> $DIR/test.rs:14:20
1515
|
1616
LL | fn bad(x: &u16, y: &Foo) {}
1717
| ^^^^ help: consider passing by value instead: `Foo`

tests/ui/deref_addrof.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fn get_reference(n: &usize) -> &usize {
99
n
1010
}
1111

12-
#[allow(clippy::many_single_char_names, clippy::double_parens)]
12+
#[allow(clippy::double_parens)]
1313
#[allow(unused_variables, unused_parens)]
1414
fn main() {
1515
let a = 10;

tests/ui/deref_addrof.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fn get_reference(n: &usize) -> &usize {
99
n
1010
}
1111

12-
#[allow(clippy::many_single_char_names, clippy::double_parens)]
12+
#[allow(clippy::double_parens)]
1313
#[allow(unused_variables, unused_parens)]
1414
fn main() {
1515
let a = 10;

tests/ui/eq_op.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#[rustfmt::skip]
44
#[warn(clippy::eq_op)]
5-
#[allow(clippy::identity_op, clippy::double_parens, clippy::many_single_char_names)]
5+
#[allow(clippy::identity_op, clippy::double_parens)]
66
#[allow(clippy::no_effect, unused_variables, clippy::unnecessary_operation, clippy::short_circuit_statement)]
77
#[allow(clippy::nonminimal_bool)]
88
#[allow(unused)]

tests/ui/eta.fixed

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
unused,
55
clippy::no_effect,
66
clippy::redundant_closure_call,
7-
clippy::many_single_char_names,
87
clippy::needless_pass_by_value,
98
clippy::option_map_unit_fn
109
)]

tests/ui/eta.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
unused,
55
clippy::no_effect,
66
clippy::redundant_closure_call,
7-
clippy::many_single_char_names,
87
clippy::needless_pass_by_value,
98
clippy::option_map_unit_fn
109
)]

0 commit comments

Comments
 (0)