From 6b0eb107694aa07abf8a85e42b5991e9744b73eb Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 1 Apr 2016 21:24:26 +0530 Subject: [PATCH 1/3] Ignore pathological cases in boolean lint (#825) --- src/booleans.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/booleans.rs b/src/booleans.rs index 877a45a355ad..37ad927ef920 100644 --- a/src/booleans.rs +++ b/src/booleans.rs @@ -294,6 +294,14 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> { cx: self.0, }; 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 + return; + } + let stats = terminal_stats(&expr); let mut simplified = expr.simplify(); for simple in Bool::Not(Box::new(expr.clone())).simplify() { From a504ef488a719ef2dd7daecc1ad092b3bc454c32 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 1 Apr 2016 21:25:20 +0530 Subject: [PATCH 2/3] Add regression test for #825 --- tests/issue-825.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/issue-825.rs diff --git a/tests/issue-825.rs b/tests/issue-825.rs new file mode 100644 index 000000000000..f5c0725f812e --- /dev/null +++ b/tests/issue-825.rs @@ -0,0 +1,25 @@ +#![feature(plugin)] +#![plugin(clippy)] + +#![allow(warnings)] + +// this should compile in a reasonable amount of time +fn rust_type_id(name: String) { + if "bool" == &name[..] || + "uint" == &name[..] || + "u8" == &name[..] || + "u16" == &name[..] || + "u32" == &name[..] || + "f32" == &name[..] || + "f64" == &name[..] || + "i8" == &name[..] || + "i16" == &name[..] || + "i32" == &name[..] || + "i64" == &name[..] || + "Self" == &name[..] || + "str" == &name[..] { + unreachable!(); + } +} + +fn main() {} \ No newline at end of file From 9349ec597d54e125d740bfafca3dd381410f7243 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 1 Apr 2016 21:25:38 +0530 Subject: [PATCH 3/3] Bump to 0.0.60 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 6dcadfca46b2..febe1ab9c19b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clippy" -version = "0.0.59" +version = "0.0.60" authors = [ "Manish Goregaokar ", "Andre Bogus ",