Skip to content

Commit 4ee8bc8

Browse files
committed
Auto merge of #4527 - rust-lang:more-vec-diag-items, r=oli-obk
Changed more `Vec` paths to diagnostic_items In #4519, I missed a few instances of path matching for `Vec`, so here they are. r? @oli-obk changelog: none
2 parents c733376 + 507c03a commit 4ee8bc8

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

clippy_lints/src/get_last_with_len.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! lint on using `x.get(x.len() - 1)` instead of `x.last()`
22
3-
use crate::utils::{match_type, paths, snippet_with_applicability, span_lint_and_sugg, SpanlessEq};
3+
use crate::utils::{is_type_diagnostic_item, snippet_with_applicability, span_lint_and_sugg, SpanlessEq};
44
use if_chain::if_chain;
55
use rustc::hir::{BinOpKind, Expr, ExprKind};
66
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
@@ -56,7 +56,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for GetLastWithLen {
5656
// Argument 0 (the struct we're calling the method on) is a vector
5757
if let Some(struct_calling_on) = args.get(0);
5858
let struct_ty = cx.tables.expr_ty(struct_calling_on);
59-
if match_type(cx, struct_ty, &paths::VEC);
59+
if is_type_diagnostic_item(cx, struct_ty, Symbol::intern("vec_type"));
6060

6161
// Argument to "get" is a subtraction
6262
if let Some(get_index_arg) = args.get(1);

clippy_lints/src/loops.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2399,7 +2399,7 @@ fn check_needless_collect<'a, 'tcx>(expr: &'tcx Expr, cx: &LateContext<'a, 'tcx>
23992399
if let Some(GenericArg::Type(ref ty)) = generic_args.args.get(0);
24002400
then {
24012401
let ty = cx.tables.node_type(ty.hir_id);
2402-
if match_type(cx, ty, &paths::VEC) ||
2402+
if is_type_diagnostic_item(cx, ty, Symbol::intern("vec_type")) ||
24032403
match_type(cx, ty, &paths::VEC_DEQUE) ||
24042404
match_type(cx, ty, &paths::BTREEMAP) ||
24052405
match_type(cx, ty, &paths::HASHMAP) {

clippy_lints/src/methods/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1988,7 +1988,7 @@ fn derefs_to_slice<'a, 'tcx>(
19881988
match ty.sty {
19891989
ty::Slice(_) => true,
19901990
ty::Adt(def, _) if def.is_box() => may_slice(cx, ty.boxed_ty()),
1991-
ty::Adt(..) => match_type(cx, ty, &paths::VEC),
1991+
ty::Adt(..) => is_type_diagnostic_item(cx, ty, Symbol::intern("vec_type")),
19921992
ty::Array(_, size) => size.eval_usize(cx.tcx, cx.param_env) < 32,
19931993
ty::Ref(_, inner, _) => may_slice(cx, inner),
19941994
_ => false,

0 commit comments

Comments
 (0)