-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't havegood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Description
Summary
clippy::pedantic
shows a warning when using ends_with()
with a .
followed by one to five numbers.
Lint Name
case_sensitive_file_extension_comparisons
Reproducer
I tried this code:
fn main() {
"hello world".ends_with(".123");
}
I saw this happen:
$ cargo clippy -- -W clippy::pedantic
Checking hello_world v0.1.0 (/home/dho/projects/hello_world)
warning: case-sensitive file extension comparison
--> src/main.rs:2:5
|
2 | "hello world".ends_with(".123");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: consider using a case-insensitive comparison instead
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#case_sensitive_file_extension_comparisons
= note: `-W clippy::case-sensitive-file-extension-comparisons` implied by `-W clippy::pedantic`
= help: to override `-W clippy::pedantic` add `#[allow(clippy::case_sensitive_file_extension_comparisons)]`
help: use std::path::Path
|
2 ~ std::path::Path::new("hello world")
3 + .extension()
4 ~ .map_or(false, |ext| ext.eq_ignore_ascii_case("123"));
|
warning: `hello_world` (bin "hello_world") generated 1 warning
Finished dev [unoptimized + debuginfo] target(s) in 0.06s
I expected to see this happen:
No clippy warning
Version
rustc 1.76.0 (07dca489a 2024-02-04)
binary: rustc
commit-hash: 07dca489ac2d933c78d3c5158e3f43beefeb02ce
commit-date: 2024-02-04
host: x86_64-unknown-linux-gnu
release: 1.76.0
LLVM version: 17.0.6
Additional Labels
No response
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't havegood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy