diff options
| author | bors <bors@rust-lang.org> | 2024-02-28 15:30:49 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-02-28 15:30:49 +0000 |
| commit | e450a27a203fcdc808eb6b070169320bc9109425 (patch) | |
| tree | 2ab6e048d1f9774516bd81cc350df832745b3f55 | |
| parent | b4021ee114a69613508aa9b5e4c4810d3c54000e (diff) | |
| parent | 8473716f6e79310d67126c94e673597592ee39e1 (diff) | |
| download | rust-e450a27a203fcdc808eb6b070169320bc9109425.tar.gz rust-e450a27a203fcdc808eb6b070169320bc9109425.zip | |
Auto merge of #12372 - GuillaumeGomez:fix-nonminimal_bool-regression, 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
| -rw-r--r-- | clippy_lints/src/booleans.rs | 4 | ||||
| -rw-r--r-- | tests/ui/nonminimal_bool.rs | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index 0d66f2d644d..614ddc41b15 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -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; } diff --git a/tests/ui/nonminimal_bool.rs b/tests/ui/nonminimal_bool.rs index 908ef6cb2a0..1de8d4f9e58 100644 --- a/tests/ui/nonminimal_bool.rs +++ b/tests/ui/nonminimal_bool.rs @@ -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 +} |
