Merge pull request #826 from Manishearth/patho-bool

Ignore pathological cases in boolean lint
This commit is contained in:
Manish Goregaokar 2016-04-01 21:32:41 +05:30
commit c150ae7824
3 changed files with 34 additions and 1 deletions

View file

@ -1,6 +1,6 @@
[package]
name = "clippy"
version = "0.0.59"
version = "0.0.60"
authors = [
"Manish Goregaokar <manishsmail@gmail.com>",
"Andre Bogus <bogusandre@gmail.com>",

View file

@ -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() {

25
tests/issue-825.rs Normal file
View file

@ -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() {}