about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-08-03 15:50:00 +0000
committerbors <bors@rust-lang.org>2024-08-03 15:50:00 +0000
commit8dd459d4c750dbf200bbd48a10f129b1401e7bf3 (patch)
tree730943ebb012eeefe71a462a8adc92e6b20d91fb
parenteb7b6769f1fe21e56996e9a61369a54f6ab66f19 (diff)
parentb2d06313008194ef30751a8d85d37c3e0c78546b (diff)
downloadrust-8dd459d4c750dbf200bbd48a10f129b1401e7bf3.tar.gz
rust-8dd459d4c750dbf200bbd48a10f129b1401e7bf3.zip
Auto merge of #13209 - Alexendoo:nonminimal-bool-limit-ops, r=y21
Limit number of `nonminimal_bool` ops

Fixes https://github.com/rust-lang/rust-clippy/issues/11257
Fixes https://github.com/rust-lang/rust-clippy/issues/13206

changelog: none
-rw-r--r--clippy_lints/src/booleans.rs10
-rw-r--r--tests/ui/nonminimal_bool.rs6
2 files changed, 10 insertions, 6 deletions
diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs
index a1c6c0b608f..a2f48c18170 100644
--- a/clippy_lints/src/booleans.rs
+++ b/clippy_lints/src/booleans.rs
@@ -477,14 +477,12 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
             cx: self.cx,
         };
         if let Ok(expr) = h2q.run(e) {
-            if h2q.terminals.len() > 8 {
-                // QMC has exponentially slow behavior as the number of terminals increases
-                // 8 is reasonable, it takes approximately 0.2 seconds.
-                // See #825
+            let stats = terminal_stats(&expr);
+            if stats.ops > 7 {
+                // QMC has exponentially slow behavior as the number of ops increases.
+                // See #825, #13206
                 return;
             }
-
-            let stats = terminal_stats(&expr);
             let mut simplified = expr.simplify();
             for simple in Bool::Not(Box::new(expr)).simplify() {
                 match simple {
diff --git a/tests/ui/nonminimal_bool.rs b/tests/ui/nonminimal_bool.rs
index d117e8bf9c7..52b0155a762 100644
--- a/tests/ui/nonminimal_bool.rs
+++ b/tests/ui/nonminimal_bool.rs
@@ -177,3 +177,9 @@ fn issue_12371(x: usize) -> bool {
     // Should not warn!
     !x != 0
 }
+
+// Not linted because it is slow to do so
+// https://github.com/rust-lang/rust-clippy/issues/13206
+fn many_ops(a: bool, b: bool, c: bool, d: bool, e: bool, f: bool) -> bool {
+    (a && c && f) || (!a && b && !d) || (!b && !c && !e) || (d && e && !f)
+}