refactor: remove unnecessary variables
This commit is contained in:
parent
4bcaddeeb2
commit
097ef517fe
8 changed files with 67 additions and 76 deletions
|
@ -370,7 +370,7 @@ fn check_for_is_empty<'tcx>(
|
|||
}
|
||||
|
||||
fn check_cmp(cx: &LateContext<'_>, span: Span, method: &Expr<'_>, lit: &Expr<'_>, op: &str, compare_to: u32) {
|
||||
if let (&ExprKind::MethodCall(method_path, receiver, ..), &ExprKind::Lit(ref lit)) = (&method.kind, &lit.kind) {
|
||||
if let (&ExprKind::MethodCall(method_path, receiver, args, _), &ExprKind::Lit(ref lit)) = (&method.kind, &lit.kind) {
|
||||
// check if we are in an is_empty() method
|
||||
if let Some(name) = get_item_name(cx, method) {
|
||||
if name.as_str() == "is_empty" {
|
||||
|
@ -378,7 +378,7 @@ fn check_cmp(cx: &LateContext<'_>, span: Span, method: &Expr<'_>, lit: &Expr<'_>
|
|||
}
|
||||
}
|
||||
|
||||
check_len(cx, span, method_path.ident.name, receiver, &lit.node, op, compare_to);
|
||||
check_len(cx, span, method_path.ident.name, receiver, args, &lit.node, op, compare_to);
|
||||
} else {
|
||||
check_empty_expr(cx, span, method, lit, op);
|
||||
}
|
||||
|
@ -389,6 +389,7 @@ fn check_len(
|
|||
span: Span,
|
||||
method_name: Symbol,
|
||||
receiver: &Expr<'_>,
|
||||
args: &[Expr<'_>],
|
||||
lit: &LitKind,
|
||||
op: &str,
|
||||
compare_to: u32,
|
||||
|
@ -399,7 +400,7 @@ fn check_len(
|
|||
return;
|
||||
}
|
||||
|
||||
if method_name == sym::len && has_is_empty(cx, receiver) {
|
||||
if method_name == sym::len && args.is_empty() && has_is_empty(cx, receiver) {
|
||||
let mut applicability = Applicability::MachineApplicable;
|
||||
span_lint_and_sugg(
|
||||
cx,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue