rust-lang / rust-lang/rust-clippy

`nonminimal_bool` does not work with `||`

Open
#15,364 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug I-false-negative
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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.