Skip to content

Commit

Permalink
Auto merge of #12372 - GuillaumeGomez:fix-nonminimal_bool-regression,…
Browse files Browse the repository at this point in the history
… r=flip1995

Fix `nonminimal_bool` lint regression

Fixes #12371.
Fixes #12369.

cc `@RalfJung`

The problem was an invalid condition. Shame on me...

changelog: Fix `nonminimal_bool` lint regression
  • Loading branch information
bors committed Feb 28, 2024
2 parents b4021ee + 8473716 commit e450a27
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions clippy_lints/src/booleans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ fn check_inverted_bool_in_condition(
right: &Expr<'_>,
) {
if expr_span.from_expansion()
&& (!cx.typeck_results().node_types()[left.hir_id].is_bool()
|| !cx.typeck_results().node_types()[right.hir_id].is_bool())
|| !cx.typeck_results().node_types()[left.hir_id].is_bool()
|| !cx.typeck_results().node_types()[right.hir_id].is_bool()
{
return;
}
Expand Down
5 changes: 5 additions & 0 deletions tests/ui/nonminimal_bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,8 @@ fn issue_5794() {
if !b == !c {} //~ ERROR: this boolean expression can be simplified
if !b != !c {} //~ ERROR: this boolean expression can be simplified
}

fn issue_12371(x: usize) -> bool {
// Should not warn!
!x != 0
}

0 comments on commit e450a27

Please sign in to comment.