Skip to content

Commit e450a27

Browse files
committed
Auto merge of rust-lang#12372 - GuillaumeGomez:fix-nonminimal_bool-regression, r=flip1995
Fix `nonminimal_bool` lint regression Fixes rust-lang#12371. Fixes rust-lang#12369. cc `@RalfJung` The problem was an invalid condition. Shame on me... changelog: Fix `nonminimal_bool` lint regression
2 parents b4021ee + 8473716 commit e450a27

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

clippy_lints/src/booleans.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ fn check_inverted_bool_in_condition(
148148
right: &Expr<'_>,
149149
) {
150150
if expr_span.from_expansion()
151-
&& (!cx.typeck_results().node_types()[left.hir_id].is_bool()
152-
|| !cx.typeck_results().node_types()[right.hir_id].is_bool())
151+
|| !cx.typeck_results().node_types()[left.hir_id].is_bool()
152+
|| !cx.typeck_results().node_types()[right.hir_id].is_bool()
153153
{
154154
return;
155155
}

tests/ui/nonminimal_bool.rs

+5
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,8 @@ fn issue_5794() {
173173
if !b == !c {} //~ ERROR: this boolean expression can be simplified
174174
if !b != !c {} //~ ERROR: this boolean expression can be simplified
175175
}
176+
177+
fn issue_12371(x: usize) -> bool {
178+
// Should not warn!
179+
!x != 0
180+
}

0 commit comments

Comments
 (0)