Tweak heuristics for less noise
This commit is contained in:
parent
6dd718ca79
commit
8bf6d35377
7 changed files with 10 additions and 10 deletions
|
@ -2064,9 +2064,9 @@ pub fn is_case_difference(sm: &dyn SourceMapper, suggested: &str, sp: Span) -> b
|
|||
// FIXME: this should probably be extended to also account for `FO0` → `FOO` and unicode.
|
||||
let found = sm.span_to_snippet(sp).unwrap();
|
||||
let ascii_confusables = &['c', 'f', 'i', 'k', 'o', 's', 'u', 'v', 'w', 'x', 'y', 'z'];
|
||||
// There are ASCII chars that are confusable (above) and differ in capitalization:
|
||||
let confusable = found.chars().zip(suggested.chars()).any(|(f, s)| {
|
||||
(ascii_confusables.contains(&f) || ascii_confusables.contains(&s)) && f != s
|
||||
// All the chars that differ in capitalization are confusable (above):
|
||||
let confusable = found.chars().zip(suggested.chars()).filter(|(f, s)| f != s).all(|(f, s)| {
|
||||
(ascii_confusables.contains(&f) || ascii_confusables.contains(&s))
|
||||
});
|
||||
confusable && found.to_lowercase() == suggested.to_lowercase()
|
||||
// FIXME: We sometimes suggest the same thing we already have, which is a
|
||||
|
|
|
@ -20,7 +20,7 @@ warning: constant `X_const` should have an upper case name
|
|||
--> $DIR/const_fn_ptr.rs:9:7
|
||||
|
|
||||
LL | const X_const: fn(usize) -> usize = double_const;
|
||||
| ^^^^^^^ help: convert the identifier to upper case (notice the capitalization): `X_CONST`
|
||||
| ^^^^^^^ help: convert the identifier to upper case: `X_CONST`
|
||||
|
|
||||
= note: `#[warn(non_upper_case_globals)]` on by default
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ error: function `BOGUS` should have a snake case name
|
|||
--> $DIR/enable-unstable-lib-feature.rs:11:8
|
||||
|
|
||||
LL | pub fn BOGUS() { }
|
||||
| ^^^^^ help: convert the identifier to snake case (notice the capitalization): `bogus`
|
||||
| ^^^^^ help: convert the identifier to snake case: `bogus`
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/enable-unstable-lib-feature.rs:6:9
|
||||
|
|
|
@ -20,7 +20,7 @@ error: constant in pattern `not_okay` should have an upper case name
|
|||
--> $DIR/lint-lowercase-static-const-pattern.rs:40:13
|
||||
|
|
||||
LL | (0, not_okay) => 0,
|
||||
| ^^^^^^^^ help: convert the identifier to upper case (notice the capitalization): `NOT_OKAY`
|
||||
| ^^^^^^^^ help: convert the identifier to upper case: `NOT_OKAY`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ error: method `Foo_Method` should have a snake case name
|
|||
--> $DIR/lint-non-snake-case-functions.rs:7:8
|
||||
|
|
||||
LL | fn Foo_Method() {}
|
||||
| ^^^^^^^^^^ help: convert the identifier to snake case (notice the capitalization): `foo_method`
|
||||
| ^^^^^^^^^^ help: convert the identifier to snake case: `foo_method`
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/lint-non-snake-case-functions.rs:1:9
|
||||
|
@ -32,7 +32,7 @@ error: trait method `ABC` should have a snake case name
|
|||
--> $DIR/lint-non-snake-case-functions.rs:22:8
|
||||
|
|
||||
LL | fn ABC();
|
||||
| ^^^ help: convert the identifier to snake case (notice the capitalization): `abc`
|
||||
| ^^^ help: convert the identifier to snake case: `abc`
|
||||
|
||||
error: trait method `a_b_C` should have a snake case name
|
||||
--> $DIR/lint-non-snake-case-functions.rs:25:8
|
||||
|
|
|
@ -2,7 +2,7 @@ error: associated constant `not_upper` should have an upper case name
|
|||
--> $DIR/lint-non-uppercase-associated-const.rs:7:11
|
||||
|
|
||||
LL | const not_upper: bool = true;
|
||||
| ^^^^^^^^^ help: convert the identifier to upper case (notice the capitalization): `NOT_UPPER`
|
||||
| ^^^^^^^^^ help: convert the identifier to upper case: `NOT_UPPER`
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/lint-non-uppercase-associated-const.rs:1:9
|
||||
|
|
|
@ -10,7 +10,7 @@ warning: unknown lint: `DEAD_CODE`
|
|||
--> $DIR/not_found.rs:8:8
|
||||
|
|
||||
LL | #[warn(DEAD_CODE)]
|
||||
| ^^^^^^^^^ help: did you mean (notice the capitalization): `dead_code`
|
||||
| ^^^^^^^^^ help: did you mean: `dead_code`
|
||||
|
||||
warning: unknown lint: `Warnings`
|
||||
--> $DIR/not_found.rs:10:8
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue