Skip to content

Commit

Permalink
Ignore calls to 'len'
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystucki committed Aug 21, 2019
1 parent f53e766 commit cfc0174
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,21 @@ fn lint_or_fun_call<'a, 'tcx>(
or_has_args: bool,
span: Span,
) {
if let hir::ExprKind::MethodCall(ref path, _, ref args) = &arg.node {
if path.ident.as_str() == "len" {
let ty = walk_ptrs_ty(cx.tables.expr_ty(&args[0]));

match ty.sty {
ty::Slice(_) | ty::Array(_, _) => return,
_ => (),
}

if match_type(cx, ty, &paths::VEC) {
return;
}
}
}

// (path, fn_has_argument, methods, suffix)
let know_types: &[(&[_], _, &[_], _)] = &[
(&paths::BTREEMAP_ENTRY, false, &["or_insert"], "with"),
Expand Down

0 comments on commit cfc0174

Please sign in to comment.