Skip to content

Commit 8dd459d

Browse files
committed
Auto merge of #13209 - Alexendoo:nonminimal-bool-limit-ops, r=y21
Limit number of `nonminimal_bool` ops Fixes rust-lang/rust-clippy#11257 Fixes rust-lang/rust-clippy#13206 changelog: none
2 parents eb7b676 + b2d0631 commit 8dd459d

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

clippy_lints/src/booleans.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -477,14 +477,12 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
477477
cx: self.cx,
478478
};
479479
if let Ok(expr) = h2q.run(e) {
480-
if h2q.terminals.len() > 8 {
481-
// QMC has exponentially slow behavior as the number of terminals increases
482-
// 8 is reasonable, it takes approximately 0.2 seconds.
483-
// See #825
480+
let stats = terminal_stats(&expr);
481+
if stats.ops > 7 {
482+
// QMC has exponentially slow behavior as the number of ops increases.
483+
// See #825, #13206
484484
return;
485485
}
486-
487-
let stats = terminal_stats(&expr);
488486
let mut simplified = expr.simplify();
489487
for simple in Bool::Not(Box::new(expr)).simplify() {
490488
match simple {

tests/ui/nonminimal_bool.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,9 @@ fn issue_12371(x: usize) -> bool {
177177
// Should not warn!
178178
!x != 0
179179
}
180+
181+
// Not linted because it is slow to do so
182+
// https://github.com/rust-lang/rust-clippy/issues/13206
183+
fn many_ops(a: bool, b: bool, c: bool, d: bool, e: bool, f: bool) -> bool {
184+
(a && c && f) || (!a && b && !d) || (!b && !c && !e) || (d && e && !f)
185+
}

0 commit comments

Comments
 (0)