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 on (return) || true #12744

Closed
bend-n opened this issue May 2, 2024 · 1 comment
Closed

overly_complex_bool_expr triggers wrongly on (return) || true #12744

bend-n opened this issue May 2, 2024 · 1 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 I-suggestion-causes-bug Issue: The suggestion compiles but changes the code to behave in an unintended way

Comments

@bend-n
Copy link
Contributor

bend-n commented May 2, 2024

Summary

_ = (return) || true suggests being replaced with true

Lint Name

overly_complex_bool_expr

Reproducer

I tried this code:

#![allow(unreachable_code, clippy::never_loop, clippy::diverging_sub_expression)]
fn main() {
    _ = (return) || true;
}

I saw this happen:


error: this boolean expression contains a logic bug
 --> src/main.rs:3:9
  |
3 |     _ = (return) || 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:9
  |
3 |     _ = (return) || 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 defau

I expected to see this happen:

Version

rustc 1.80.0-nightly (c987ad527 2024-05-01)
binary: rustc
commit-hash: c987ad527540e8f1565f57c31204bde33f63df76
commit-date: 2024-05-01
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.4

Additional Labels

@rustbot label +I-suggestion-causes-bug

@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 May 2, 2024
@rustbot rustbot added the I-suggestion-causes-bug Issue: The suggestion compiles but changes the code to behave in an unintended way label May 2, 2024
@bend-n bend-n changed the title overly_clompex_bool_expr triggers wrongly on (return) || true overly_complex_bool_expr triggers wrongly on (return) || true May 2, 2024
@bend-n
Copy link
Contributor Author

bend-n commented May 2, 2024

wait im an idiot
i already reported this #12689

@bend-n bend-n closed this as not planned Won't fix, can't repro, duplicate, stale May 2, 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 I-suggestion-causes-bug Issue: The suggestion compiles but changes the code to behave in an unintended way
Projects
None yet
Development

No branches or pull requests

2 participants