rust-lang / rust-lang/rust-clippy
Manual && or ||
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
What it does
Suggests replacing if-else expressions where one branch is a boolean literal with && / || operators.
Advantage
- Boolean expressions are easier to read and understand and are more concise.
Drawbacks
- There could be cases where the underlying reasoning is made more obvious by the explicit if-else.
- The control flow is clearer.
&&and||obscure branching.
Example
if a {
b
} else {
false
}
→ a && b
if a {
true
} else {
b
}
→ a || b
The other two combinations are less clear wins: I'd generally prefer !a || b to if a {b} else {true}, but exceptions seem more likely here. Of course, something like if !a {b} else {true} is much better as a || b.
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
The issue does not name an implementation file, test, or entry point. First clarify which if-else combinations and exceptions the lint should cover, then locate the relevant Rust Clippy lint implementation and tests; done means the intended transformations are diagnosed consistently without suggesting the explicitly excluded unclear cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100