rust-lang / rust-lang/rust-clippy

nonminimal_bool fires several times on the same code

Open
#8,891 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.