Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overly_complex_bool_expr triggers wrongly #12689

Open
bend-n opened this issue Apr 18, 2024 · 0 comments · May be fixed by #12700
Open

overly_complex_bool_expr triggers wrongly #12689

bend-n opened this issue Apr 18, 2024 · 0 comments · May be fixed by #12700
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@bend-n
Copy link
Contributor

bend-n commented Apr 18, 2024

Summary

#[allow(unreachable_code, clippy::never_loop, clippy::diverging_sub_expression)]
loop { _ = (break) || true; }

this triggers the overly_complex_bool_expr error, incorrectly, as it suggests loop { _ = true }.

Lint Name

overly_complex_bool_expr

Reproducer

I tried this code:

#[allow(unreachable_code, clippy::never_loop, clippy::diverging_sub_expression)]
loop { _ = (break) || true; }

I saw this happen:

error: this boolean expression contains a logic bug
 --> src/main.rs:3:12
  |
3 | loop { _ = (break) || true; }
  |            ^^^^^^^^^^^^^^^ help: it would look like the following: `true`
  |
help: this expression can be optimized out by applying boolean operations to the outer expression
 --> src/main.rs:3:12
  |
3 | loop { _ = (break) || true; }
  |            ^^^^^^^
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#overly_complex_bool_expr
  = note: `#[deny(clippy::overly_complex_bool_expr)]` on by default

I expected to see this happen:

Version

rustc 1.79.0-nightly (ccfcd950b 2024-04-15)
binary: rustc
commit-hash: ccfcd950b333fed046275dd8d54fe736ca498aa7
commit-date: 2024-04-15
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.3

Additional Labels

No response

@bend-n bend-n added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant