rust-lang / rust-lang/rust-clippy
if_same_then_else does not detect same `if let` expression
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Lint name: if_same_then_else
I tried this code: https://github.com/deltachat/deltachat-core-rust/blob/master/src/message.rs#L1081-L1091
if chat.id.is_deaddrop() {
if let Some(contact) = contact {
self.text1 = Some(msg.get_sender_name(contact));
} else {
self.text1 = None;
}
} else if let Some(contact) = contact {
self.text1 = Some(msg.get_sender_name(contact));
} else {
self.text1 = None;
}
I expected to see this happen: detect that chat.id.is_deaddrop() condition could be removed.
Instead, this happened: clippy did not detect anything.
Meta
cargo clippy -V: clippy 0.0.212 (e1884a8 2020-12-29)rustc -Vv:rustc 1.49.0 (e1884a8e3 2020-12-29) binary: rustc commit-hash: e1884a8e3c3e813aada8254edfa120e85bf5ffca commit-date: 2020-12-29 host: x86_64-unknown-linux-gnu release: 1.49.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 with the linked src/message.rs example around lines 1081-1091 and reproduce the behavior using cargo clippy. Trace the if_same_then_else lint entry point and its existing coverage, then add detection for this repeated if let expression and verify that Clippy reports the removable condition.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100