Skip to content

Commit

Permalink
Only apply when there is a single argument.
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentMazare committed Nov 7, 2017
1 parent 8279376 commit 67aeb2e
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions clippy_lints/src/booleans.rs
Expand Up @@ -405,24 +405,26 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
}

fn handle_method_call_in_not(&mut self, e: &'tcx Expr, inner: &'tcx Expr) {
if let ExprMethodCall(ref path, _, _) = inner.node {
METHODS_WITH_NEGATION.iter().for_each(|&(method, negation_method)| {
if method == path.name.as_str() {
span_lint_and_then(
self.cx,
NONMINIMAL_BOOL,
e.span,
"this boolean expression can be simplified",
|db| {
db.span_suggestion(
e.span,
"try",
negation_method.to_owned()
);
}
)
}
})
if let ExprMethodCall(ref path, _, ref args) = inner.node {
if args.len() == 1 {
METHODS_WITH_NEGATION.iter().for_each(|&(method, negation_method)| {
if method == path.name.as_str() {
span_lint_and_then(
self.cx,
NONMINIMAL_BOOL,
e.span,
"this boolean expression can be simplified",
|db| {
db.span_suggestion(
e.span,
"try",
negation_method.to_owned()
);
}
)
}
})
}
}
}
}
Expand Down

0 comments on commit 67aeb2e

Please sign in to comment.