-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't
Description
Summary
Starting with Rust 1.85.0, clippy::single_match
apparently does not get emitted when there is a comment on top of an arm.
Is this intended?
Lint Name
clippy::single_match
Reproducer
I tried this code:
fn _f() {
match Vec::<i32>::new().try_reserve(42) {
Err(_) => (),
// X
Ok(()) => (),
}
}
I expected to see this happen: Lint emitted as usual, e.g.
warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
--> <source>:2:5
|
2 | / match Vec::<i32>::new().try_reserve(42) {
3 | | Err(_) => (),
4 | | Ok(()) => (),
5 | | }
| |_____^ help: try: `if let Err(_) = Vec::<i32>::new().try_reserve(42) { () }`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
= note: `#[warn(clippy::single_match)]` on by default
warning: 1 warning emitted
Instead, this happened: No lint emitted.
If one removes the // X
line, or if one downgrades to 1.84.0, then the lint does get emitted.
Reproducer: https://godbolt.org/z/K7zoonG8j (Compiler Explorer supports Clippy now! :)
Version
rustc 1.85.0 (4d91de4e4 2025-02-17)
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't