clippy::single_match
does not report if a comment is on top of an arm · Issue #14418 · rust-lang/rust-clippy (original) (raw)
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::::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)