mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-08 13:02:50 +00:00
Only apply when there is a single argument.
This commit is contained in:
parent
82793768b7
commit
67aeb2eaeb
@ -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()
|
||||
);
|
||||
}
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user