rust-lang / rust-lang/rust-clippy
suggets simplifying Err(_), Some(_) or Ok(_) to _ inside match if all options are exhausted
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
fn get_result(b: bool) -> Result<(u16, u16), String> {
if b {
Ok((42, 1337))
} else {
Err("oh no".to_string())
}
}
fn main() {
let (_, _) = match get_result(false) {
Err(_) => (0, 0),
Ok((x, y)) => (x, y),
};
//println!("a: {}, b: {}", a, b);
}
the match of the main function can be simplified to
let (_, _) = match get_result(false) {
Ok((x, y)) => (x, y),
_ => (0,0),
};
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.
Research direction
Start by reviewing the Rust examples in the issue and the existing match-related lint behavior in rust-clippy. Determine how exhaustive match arms involving Err(), Some(), or Ok(_) should be recognized, then verify that the proposed simplification is reported without affecting non-equivalent matches.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100