Skip to content

Commit 566377f

Browse files
committed
Ignore calls to 'len'
1 parent 6bd9cd9 commit 566377f

File tree

1 file changed

+15
-0
lines changed
  • clippy_lints/src/methods

1 file changed

+15
-0
lines changed

clippy_lints/src/methods/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,21 @@ fn lint_or_fun_call<'a, 'tcx>(
16141614
or_has_args: bool,
16151615
span: Span,
16161616
) {
1617+
if let hir::ExprKind::MethodCall(ref path, _, ref args) = &arg.node {
1618+
if path.ident.as_str() == "len" {
1619+
let ty = walk_ptrs_ty(cx.tables.expr_ty(&args[0]));
1620+
1621+
match ty.sty {
1622+
ty::Slice(_) | ty::Array(_, _) => return,
1623+
_ => (),
1624+
}
1625+
1626+
if match_type(cx, ty, &paths::VEC) {
1627+
return;
1628+
}
1629+
}
1630+
}
1631+
16171632
// (path, fn_has_argument, methods, suffix)
16181633
let know_types: &[(&[_], _, &[_], _)] = &[
16191634
(&paths::BTREEMAP_ENTRY, false, &["or_insert"], "with"),

0 commit comments

Comments
 (0)