rust-lang / rust-lang/rust-clippy
`nonminimal_bool` does not work with `||`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
When i have code like
if !(first3 == 333
|| first3 == 444
|| first3 == 555
|| first3 == 666
|| first3 == 777)
{
println!("This was found while developing the `lose95-keygen-rs` crate");
}
i dont get nonminimal_bool
Also this may be in the docs, i could not understand what it meant by short circutting behaviour and i could not find a issue for this
Lint Name
nonminimal_bool
Reproducer
I tried this code:
#![deny(clippy::nonminimal_bool)]
pub fn foo(first3: u16) {
if !(first3 == 333
|| first3 == 444
|| first3 == 555
|| first3 == 666
|| first3 == 777)
{
println!("This was found while developing the lose95-keygen-rs crate");
}
}
I expected to see this happen:
Clippy compains and suggests I use != instead
Instead, this happened:
Clippy is happy
Version
rustc 1.88.0 (6b00bc388 2025-06-23)
binary: rustc
commit-hash: 6b00bc3880198600130e1cf62b8f8a93494488cc
commit-date: 2025-06-23
host: x86_64-unknown-linux-gnu
release: 1.88.0
LLVM version: 20.1.5
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 nonminimal_bool lint and run the supplied Rust reproducer to inspect how negated || expressions are handled. Compare the observed behavior with the lint documentation's short-circuiting explanation; done means the intended diagnostic or documentation behavior is covered by an appropriate test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100