Ignore calls to 'len'

This commit is contained in:
Jeremy Stucki 2019-08-21 21:19:28 +02:00 committed by Jeremy Stucki
parent 6bd9cd99a3
commit 566377f627
No known key found for this signature in database
GPG key ID: 49C41BB0B206632B

View file

@ -1614,6 +1614,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"),