@@ -16,18 +16,17 @@ use rustc::{declare_lint_pass, declare_tool_lint};
1616use rustc_errors:: Applicability ;
1717use syntax:: ast;
1818use syntax:: source_map:: Span ;
19- use syntax:: symbol:: { sym, LocalInternedString } ;
19+ use syntax:: symbol:: { sym, Symbol , LocalInternedString } ;
2020
21- use crate :: utils:: sugg;
2221use crate :: utils:: usage:: mutated_variables;
2322use crate :: utils:: {
2423 get_arg_name, get_parent_expr, get_trait_def_id, has_iter_method, implements_trait, in_macro, is_copy,
25- is_ctor_function, is_expn_of, iter_input_pats, last_path_segment, match_def_path, match_qpath, match_trait_method,
26- match_type, match_var, method_calls, method_chain_args, remove_blocks, return_ty, same_tys, single_segment_path,
27- snippet, snippet_with_applicability, snippet_with_macro_callsite, span_lint, span_lint_and_sugg,
28- span_lint_and_then, span_note_and_lint, walk_ptrs_ty, walk_ptrs_ty_depth, SpanlessEq ,
24+ is_ctor_function, is_expn_of, is_type_diagnostic_item, iter_input_pats, last_path_segment, match_def_path,
25+ match_qpath, match_trait_method, match_type, match_var, method_calls, method_chain_args, remove_blocks,
26+ return_ty, same_tys, single_segment_path, snippet, snippet_with_applicability, snippet_with_macro_callsite,
27+ span_lint, span_lint_and_sugg, span_lint_and_then, span_note_and_lint, walk_ptrs_ty, walk_ptrs_ty_depth,
28+ SpanlessEq , sugg, paths, span_help_and_lint
2929} ;
30- use crate :: utils:: { paths, span_help_and_lint} ;
3130
3231declare_clippy_lint ! {
3332 /// **What it does:** Checks for `.unwrap()` calls on `Option`s.
@@ -1765,7 +1764,7 @@ fn lint_cstring_as_ptr(cx: &LateContext<'_, '_>, expr: &hir::Expr, source: &hir:
17651764
17661765fn lint_iter_cloned_collect < ' a , ' tcx > ( cx : & LateContext < ' a , ' tcx > , expr : & hir:: Expr , iter_args : & ' tcx [ hir:: Expr ] ) {
17671766 if_chain ! {
1768- if match_type ( cx, cx. tables. expr_ty( expr) , & paths :: VEC ) ;
1767+ if is_type_diagnostic_item ( cx, cx. tables. expr_ty( expr) , Symbol :: intern ( "vec_type" ) ) ;
17691768 if let Some ( slice) = derefs_to_slice( cx, & iter_args[ 0 ] , cx. tables. expr_ty( & iter_args[ 0 ] ) ) ;
17701769 if let Some ( to_replace) = expr. span. trim_start( slice. span. source_callsite( ) ) ;
17711770
@@ -1875,7 +1874,7 @@ fn lint_iter_nth<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &hir::Expr, iter_ar
18751874 let mut_str = if is_mut { "_mut" } else { "" } ;
18761875 let caller_type = if derefs_to_slice ( cx, & iter_args[ 0 ] , cx. tables . expr_ty ( & iter_args[ 0 ] ) ) . is_some ( ) {
18771876 "slice"
1878- } else if match_type ( cx, cx. tables . expr_ty ( & iter_args[ 0 ] ) , & paths :: VEC ) {
1877+ } else if is_type_diagnostic_item ( cx, cx. tables . expr_ty ( & iter_args[ 0 ] ) , Symbol :: intern ( "vec_type" ) ) {
18791878 "Vec"
18801879 } else if match_type ( cx, cx. tables . expr_ty ( & iter_args[ 0 ] ) , & paths:: VEC_DEQUE ) {
18811880 "VecDeque"
@@ -1908,7 +1907,7 @@ fn lint_get_unwrap<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &hir::Expr, get_a
19081907 let caller_type = if derefs_to_slice ( cx, & get_args[ 0 ] , expr_ty) . is_some ( ) {
19091908 needs_ref = get_args_str. parse :: < usize > ( ) . is_ok ( ) ;
19101909 "slice"
1911- } else if match_type ( cx, expr_ty, & paths :: VEC ) {
1910+ } else if is_type_diagnostic_item ( cx, expr_ty, Symbol :: intern ( "vec_type" ) ) {
19121911 needs_ref = get_args_str. parse :: < usize > ( ) . is_ok ( ) ;
19131912 "Vec"
19141913 } else if match_type ( cx, expr_ty, & paths:: VEC_DEQUE ) {
0 commit comments