@@ -16,18 +16,17 @@ use rustc::{declare_lint_pass, declare_tool_lint};
16
16
use rustc_errors:: Applicability ;
17
17
use syntax:: ast;
18
18
use syntax:: source_map:: Span ;
19
- use syntax:: symbol:: { sym, LocalInternedString } ;
19
+ use syntax:: symbol:: { sym, Symbol , LocalInternedString } ;
20
20
21
- use crate :: utils:: sugg;
22
21
use crate :: utils:: usage:: mutated_variables;
23
22
use crate :: utils:: {
24
23
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
29
29
} ;
30
- use crate :: utils:: { paths, span_help_and_lint} ;
31
30
32
31
declare_clippy_lint ! {
33
32
/// **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:
1765
1764
1766
1765
fn lint_iter_cloned_collect < ' a , ' tcx > ( cx : & LateContext < ' a , ' tcx > , expr : & hir:: Expr , iter_args : & ' tcx [ hir:: Expr ] ) {
1767
1766
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" ) ) ;
1769
1768
if let Some ( slice) = derefs_to_slice( cx, & iter_args[ 0 ] , cx. tables. expr_ty( & iter_args[ 0 ] ) ) ;
1770
1769
if let Some ( to_replace) = expr. span. trim_start( slice. span. source_callsite( ) ) ;
1771
1770
@@ -1875,7 +1874,7 @@ fn lint_iter_nth<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &hir::Expr, iter_ar
1875
1874
let mut_str = if is_mut { "_mut" } else { "" } ;
1876
1875
let caller_type = if derefs_to_slice ( cx, & iter_args[ 0 ] , cx. tables . expr_ty ( & iter_args[ 0 ] ) ) . is_some ( ) {
1877
1876
"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" ) ) {
1879
1878
"Vec"
1880
1879
} else if match_type ( cx, cx. tables . expr_ty ( & iter_args[ 0 ] ) , & paths:: VEC_DEQUE ) {
1881
1880
"VecDeque"
@@ -1908,7 +1907,7 @@ fn lint_get_unwrap<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &hir::Expr, get_a
1908
1907
let caller_type = if derefs_to_slice ( cx, & get_args[ 0 ] , expr_ty) . is_some ( ) {
1909
1908
needs_ref = get_args_str. parse :: < usize > ( ) . is_ok ( ) ;
1910
1909
"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" ) ) {
1912
1911
needs_ref = get_args_str. parse :: < usize > ( ) . is_ok ( ) ;
1913
1912
"Vec"
1914
1913
} else if match_type ( cx, expr_ty, & paths:: VEC_DEQUE ) {
0 commit comments