11//! Checks for usage of `&Vec[_]` and `&String`.
22
33use crate :: utils:: ptr:: get_spans;
4- use crate :: utils:: { match_qpath, match_type, paths, snippet_opt, span_lint, span_lint_and_then, walk_ptrs_hir_ty} ;
4+ use crate :: utils:: { match_qpath, is_type_diagnostic_item, match_type, paths, snippet_opt,
5+ span_lint, span_lint_and_then, walk_ptrs_hir_ty} ;
56use if_chain:: if_chain;
67use rustc:: hir:: QPath ;
78use rustc:: hir:: * ;
@@ -11,7 +12,7 @@ use rustc::{declare_lint_pass, declare_tool_lint};
1112use rustc_errors:: Applicability ;
1213use std:: borrow:: Cow ;
1314use syntax:: source_map:: Span ;
14- use syntax_pos:: MultiSpan ;
15+ use syntax_pos:: { MultiSpan , symbol :: sym } ;
1516
1617declare_clippy_lint ! {
1718 /// **What it does:** This lint checks for function arguments of type `&String`
@@ -148,7 +149,7 @@ fn check_fn(cx: &LateContext<'_, '_>, decl: &FnDecl, fn_id: HirId, opt_body_id:
148149
149150 for ( idx, ( arg, ty) ) in decl. inputs . iter ( ) . zip ( fn_ty. inputs ( ) ) . enumerate ( ) {
150151 if let ty:: Ref ( _, ty, MutImmutable ) = ty. sty {
151- if match_type ( cx, ty, & paths :: VEC ) {
152+ if is_type_diagnostic_item ( cx, ty, sym :: Vec ) {
152153 let mut ty_snippet = None ;
153154 if_chain ! {
154155 if let TyKind :: Path ( QPath :: Resolved ( _, ref path) ) = walk_ptrs_hir_ty( arg) . node;
0 commit comments