Skip to content

Commit c150ae7

Browse files
committed
Merge pull request #826 from Manishearth/patho-bool
Ignore pathological cases in boolean lint
2 parents 833b33c + 9349ec5 commit c150ae7

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.0.59"
3+
version = "0.0.60"
44
authors = [
55
"Manish Goregaokar <[email protected]>",
66
"Andre Bogus <[email protected]>",

src/booleans.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,14 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
294294
cx: self.0,
295295
};
296296
if let Ok(expr) = h2q.run(e) {
297+
298+
if h2q.terminals.len() > 8 {
299+
// QMC has exponentially slow behavior as the number of terminals increases
300+
// 8 is reasonable, it takes approximately 0.2 seconds.
301+
// See #825
302+
return;
303+
}
304+
297305
let stats = terminal_stats(&expr);
298306
let mut simplified = expr.simplify();
299307
for simple in Bool::Not(Box::new(expr.clone())).simplify() {

tests/issue-825.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#![feature(plugin)]
2+
#![plugin(clippy)]
3+
4+
#![allow(warnings)]
5+
6+
// this should compile in a reasonable amount of time
7+
fn rust_type_id(name: String) {
8+
if "bool" == &name[..] ||
9+
"uint" == &name[..] ||
10+
"u8" == &name[..] ||
11+
"u16" == &name[..] ||
12+
"u32" == &name[..] ||
13+
"f32" == &name[..] ||
14+
"f64" == &name[..] ||
15+
"i8" == &name[..] ||
16+
"i16" == &name[..] ||
17+
"i32" == &name[..] ||
18+
"i64" == &name[..] ||
19+
"Self" == &name[..] ||
20+
"str" == &name[..] {
21+
unreachable!();
22+
}
23+
}
24+
25+
fn main() {}

0 commit comments

Comments
 (0)