1
1
//! Checks for usage of `&Vec[_]` and `&String`.
2
2
3
3
use 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} ;
5
6
use if_chain:: if_chain;
6
7
use rustc:: hir:: QPath ;
7
8
use rustc:: hir:: * ;
@@ -11,7 +12,7 @@ use rustc::{declare_lint_pass, declare_tool_lint};
11
12
use rustc_errors:: Applicability ;
12
13
use std:: borrow:: Cow ;
13
14
use syntax:: source_map:: Span ;
14
- use syntax_pos:: MultiSpan ;
15
+ use syntax_pos:: { MultiSpan , symbol :: sym } ;
15
16
16
17
declare_clippy_lint ! {
17
18
/// **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:
148
149
149
150
for ( idx, ( arg, ty) ) in decl. inputs . iter ( ) . zip ( fn_ty. inputs ( ) ) . enumerate ( ) {
150
151
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 ) {
152
153
let mut ty_snippet = None ;
153
154
if_chain ! {
154
155
if let TyKind :: Path ( QPath :: Resolved ( _, ref path) ) = walk_ptrs_hir_ty( arg) . node;
0 commit comments