Skip to content

Commit

Permalink
Tweak heuristics for less noise
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Oct 14, 2019
1 parent 6dd718c commit 8bf6d35
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/consts/const-eval/const_fn_ptr.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 1 addition & 1 deletion src/test/ui/enable-unstable-lib-feature.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

4 changes: 2 additions & 2 deletions src/test/ui/lint/lint-non-snake-case-functions.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/lint/not_found.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8bf6d35

Please sign in to comment.