Skip to content

Commit 8bf6d35

Browse files
committed
Tweak heuristics for less noise
1 parent 6dd718c commit 8bf6d35

7 files changed

+10
-10
lines changed

src/librustc_errors/emitter.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2064,9 +2064,9 @@ pub fn is_case_difference(sm: &dyn SourceMapper, suggested: &str, sp: Span) -> b
20642064
// FIXME: this should probably be extended to also account for `FO0` → `FOO` and unicode.
20652065
let found = sm.span_to_snippet(sp).unwrap();
20662066
let ascii_confusables = &['c', 'f', 'i', 'k', 'o', 's', 'u', 'v', 'w', 'x', 'y', 'z'];
2067-
// There are ASCII chars that are confusable (above) and differ in capitalization:
2068-
let confusable = found.chars().zip(suggested.chars()).any(|(f, s)| {
2069-
(ascii_confusables.contains(&f) || ascii_confusables.contains(&s)) && f != s
2067+
// All the chars that differ in capitalization are confusable (above):
2068+
let confusable = found.chars().zip(suggested.chars()).filter(|(f, s)| f != s).all(|(f, s)| {
2069+
(ascii_confusables.contains(&f) || ascii_confusables.contains(&s))
20702070
});
20712071
confusable && found.to_lowercase() == suggested.to_lowercase()
20722072
// FIXME: We sometimes suggest the same thing we already have, which is a

src/test/ui/consts/const-eval/const_fn_ptr.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ warning: constant `X_const` should have an upper case name
2020
--> $DIR/const_fn_ptr.rs:9:7
2121
|
2222
LL | const X_const: fn(usize) -> usize = double_const;
23-
| ^^^^^^^ help: convert the identifier to upper case (notice the capitalization): `X_CONST`
23+
| ^^^^^^^ help: convert the identifier to upper case: `X_CONST`
2424
|
2525
= note: `#[warn(non_upper_case_globals)]` on by default
2626

src/test/ui/enable-unstable-lib-feature.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: function `BOGUS` should have a snake case name
22
--> $DIR/enable-unstable-lib-feature.rs:11:8
33
|
44
LL | pub fn BOGUS() { }
5-
| ^^^^^ help: convert the identifier to snake case (notice the capitalization): `bogus`
5+
| ^^^^^ help: convert the identifier to snake case: `bogus`
66
|
77
note: lint level defined here
88
--> $DIR/enable-unstable-lib-feature.rs:6:9

src/test/ui/lint/lint-lowercase-static-const-pattern.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ error: constant in pattern `not_okay` should have an upper case name
2020
--> $DIR/lint-lowercase-static-const-pattern.rs:40:13
2121
|
2222
LL | (0, not_okay) => 0,
23-
| ^^^^^^^^ help: convert the identifier to upper case (notice the capitalization): `NOT_OKAY`
23+
| ^^^^^^^^ help: convert the identifier to upper case: `NOT_OKAY`
2424

2525
error: aborting due to 3 previous errors
2626

src/test/ui/lint/lint-non-snake-case-functions.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: method `Foo_Method` should have a snake case name
22
--> $DIR/lint-non-snake-case-functions.rs:7:8
33
|
44
LL | fn Foo_Method() {}
5-
| ^^^^^^^^^^ help: convert the identifier to snake case (notice the capitalization): `foo_method`
5+
| ^^^^^^^^^^ help: convert the identifier to snake case: `foo_method`
66
|
77
note: lint level defined here
88
--> $DIR/lint-non-snake-case-functions.rs:1:9
@@ -32,7 +32,7 @@ error: trait method `ABC` should have a snake case name
3232
--> $DIR/lint-non-snake-case-functions.rs:22:8
3333
|
3434
LL | fn ABC();
35-
| ^^^ help: convert the identifier to snake case (notice the capitalization): `abc`
35+
| ^^^ help: convert the identifier to snake case: `abc`
3636

3737
error: trait method `a_b_C` should have a snake case name
3838
--> $DIR/lint-non-snake-case-functions.rs:25:8

src/test/ui/lint/lint-non-uppercase-associated-const.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: associated constant `not_upper` should have an upper case name
22
--> $DIR/lint-non-uppercase-associated-const.rs:7:11
33
|
44
LL | const not_upper: bool = true;
5-
| ^^^^^^^^^ help: convert the identifier to upper case (notice the capitalization): `NOT_UPPER`
5+
| ^^^^^^^^^ help: convert the identifier to upper case: `NOT_UPPER`
66
|
77
note: lint level defined here
88
--> $DIR/lint-non-uppercase-associated-const.rs:1:9

src/test/ui/lint/not_found.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ warning: unknown lint: `DEAD_CODE`
1010
--> $DIR/not_found.rs:8:8
1111
|
1212
LL | #[warn(DEAD_CODE)]
13-
| ^^^^^^^^^ help: did you mean (notice the capitalization): `dead_code`
13+
| ^^^^^^^^^ help: did you mean: `dead_code`
1414

1515
warning: unknown lint: `Warnings`
1616
--> $DIR/not_found.rs:10:8

0 commit comments

Comments
 (0)