rust-lang / rust-lang/rust-clippy
nonminimal_bool fires several times on the same code
Open
Nobody has claimed this yet.
C-bug
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
fn main() {
if !!true {}
}
😆 can we somehow only emit one diagnostic here? :D
warning: this boolean expression can be simplified
--> src/main.rs:2:8
|
2 | if !!true {}
| ^^^^^^ help: try: `true`
|
= note: `#[warn(clippy::nonminimal_bool)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonminimal_bool
warning: this boolean expression can be simplified
--> src/main.rs:2:9
|
2 | if !!true {}
| ^^^^^ help: try: `false`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonminimal_bool
warning: `playground` (bin "playground") generated 2 warnings
Reproducer
No response
Version
No response
Additional Labels
No response
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 reproducing the Rust snippet with the nonminimal_bool lint enabled and trace how diagnostics are emitted for !!true. Done means the example produces one diagnostic instead of two, with coverage confirming the behavior.
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
- 45/100