Skip to content

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

@bend-n

Description

@bend-n

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-bugIssue: The suggestion compiles but changes the code to behave in an unintended way

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions