Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive with numerals in match_str_case_mismatch #7863

Closed
Herschel opened this issue Oct 23, 2021 · 0 comments · Fixed by #7865
Closed

False positive with numerals in match_str_case_mismatch #7863

Herschel opened this issue Oct 23, 2021 · 0 comments · Fixed by #7865
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@Herschel
Copy link
Contributor

Lint name:
match_str_case_mismatch

I tried this code:

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=1efc4425e26da357ac3f0734bd11df1a

match s.to_ascii_lowercase().as_str() {
        "8x8" => 8,
        "16x16" => 16,
        _ => 0,
    };

I expected to see this happen: No lints triggered.

Instead, this happened:

error: this `match` arm has a differing case than its expression
 --> src/main.rs:4:9
  |
4 |         "8x8" => 8,
  |         ^^^^^
  |
  = note: `#[deny(clippy::match_str_case_mismatch)]` on by default
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_str_case_mismatch
help: consider changing the case of this arm to respect `to_ascii_lowercase`

Meta

Rust version (rustc -Vv):

rustc 1.58.0-nightly (514b38779 2021-10-22)
binary: rustc
commit-hash: 514b3877956dc594823106b66c164f8cdbc8b3da
commit-date: 2021-10-22
host: x86_64-pc-windows-msvc
release: 1.58.0-nightly
LLVM version: 13.0.0
@Herschel Herschel added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Oct 23, 2021
@Herschel Herschel changed the title False positive on match_str_case_mismatch False positive with numerals in match_str_case_mismatch Oct 23, 2021
Herschel added a commit to Herschel/rust-clippy that referenced this issue Oct 23, 2021
Herschel added a commit to Herschel/rust-clippy that referenced this issue Oct 23, 2021
Herschel added a commit to Herschel/rust-clippy that referenced this issue Oct 23, 2021
Herschel added a commit to Herschel/rust-clippy that referenced this issue Oct 23, 2021
jsdanielh added a commit to nimiq/core-rs-albatross that referenced this issue Oct 25, 2021
In recent clippy versions this issue was introduced:
rust-lang/rust-clippy#7863.
That started to flag false positives to a match statement in
lib/src/config/config_file/mod.rs. So, until the issue is fixed,
we will ignore the check for this particular statement.
jsdanielh added a commit to nimiq/core-rs-albatross that referenced this issue Oct 25, 2021
In recent clippy versions this issue was introduced:
rust-lang/rust-clippy#7863.
That started to flag false positives to a match statement in
lib/src/config/config_file/mod.rs. So, until the issue is fixed,
we will ignore the check for this particular statement.
jsdanielh added a commit to nimiq/core-rs-albatross that referenced this issue Oct 25, 2021
In recent clippy versions this issue was introduced:
rust-lang/rust-clippy#7863.
That started to flag false positives to a match statement in
lib/src/config/config_file/mod.rs. So, until the issue is fixed,
we will ignore the check for this particular statement.
bors added a commit that referenced this issue Oct 25, 2021
Fix `match_str_case_mismatch` on uncased chars

False positives would result because `char::is_lowercase` and friends will return `false` for non-alphabetic chars and alphabetic chars lacking case (such as CJK scripts). Care also has to be taken for handling titlecase characters (`Dz`) and lowercased chars with no uppercase equivalent (`ʁ`).

For example, when verifying lowercase:
 * Check `!any(char::is_ascii_uppercase)` instead of `all(char::is_ascii_lowercase)` for ASCII.
 * Check that `all(|c| c.to_lowercase() == c)` instead of `all(char::is_lowercase)` for non-ASCII

Fixes #7863.

changelog: Fix false positives in [`match_str_case_mismatch`] on uncased characters
@bors bors closed this as completed in e953dff Oct 25, 2021
jsdanielh added a commit to nimiq/core-rs-albatross that referenced this issue Oct 26, 2021
In recent clippy versions this issue was introduced:
rust-lang/rust-clippy#7863.
That started to flag false positives to a match statement in
lib/src/config/config_file/mod.rs. So, until the issue is fixed,
we will ignore the check for this particular statement.
jsdanielh added a commit to nimiq/core-rs-albatross that referenced this issue Oct 26, 2021
In recent clippy versions this issue was introduced:
rust-lang/rust-clippy#7863.
That started to flag false positives to a match statement in
lib/src/config/config_file/mod.rs. So, until the issue is fixed,
we will ignore the check for this particular statement.
viquezclaudio pushed a commit to viquezclaudio/core-rs-albatross that referenced this issue Nov 2, 2021
In recent clippy versions this issue was introduced:
rust-lang/rust-clippy#7863.
That started to flag false positives to a match statement in
lib/src/config/config_file/mod.rs. So, until the issue is fixed,
we will ignore the check for this particular statement.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant