rust-lang / rust-lang/rust-clippy
`manual_let_else` doesn't trigger if binding has a type annotation.
Open
@ericwu17 is already working on this.
Since Jan 6, 2023.
C-bug
I-false-negative
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
manual_let_else doesn't trigger if binding has a type annotation.
Lint Name
manual_let_else
Reproducer
I tried this code:
#![warn(clippy::pedantic)]
#![allow(unused_variables)]
fn main() {
let x: u32 = match "14".parse() {
Ok(i) => i,
Err(_) => return,
};
}
I expected to see this happen:
A suggestion to use:
let Ok(i): Result<u32, _> = "14".parse() else { return };
Instead, this happened:
Nothing. This is a false negative.
Version
clippy: 0.1.68 (2023-01-02 d6f99e5)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.