|
1 | 1 | use clippy_utils::diagnostics::span_lint; |
2 | | -use clippy_utils::{match_def_path, paths, trait_ref_of_method}; |
| 2 | +use clippy_utils::trait_ref_of_method; |
3 | 3 | use rustc_hir as hir; |
4 | 4 | use rustc_lint::{LateContext, LateLintPass}; |
5 | 5 | use rustc_middle::ty::TypeFoldable; |
6 | 6 | use rustc_middle::ty::{Adt, Array, RawPtr, Ref, Slice, Tuple, Ty, TypeAndMut}; |
7 | 7 | use rustc_session::{declare_lint_pass, declare_tool_lint}; |
8 | 8 | use rustc_span::source_map::Span; |
| 9 | +use rustc_span::symbol::sym; |
9 | 10 | use std::iter; |
10 | 11 |
|
11 | 12 | declare_clippy_lint! { |
@@ -99,9 +100,9 @@ fn check_sig<'tcx>(cx: &LateContext<'tcx>, item_hir_id: hir::HirId, decl: &hir:: |
99 | 100 | fn check_ty<'tcx>(cx: &LateContext<'tcx>, span: Span, ty: Ty<'tcx>) { |
100 | 101 | let ty = ty.peel_refs(); |
101 | 102 | if let Adt(def, substs) = ty.kind() { |
102 | | - if [&paths::HASHMAP, &paths::BTREEMAP, &paths::HASHSET, &paths::BTREESET] |
| 103 | + if [sym::hashmap_type, sym::BTreeMap, sym::hashset_type, sym::BTreeMap] |
103 | 104 | .iter() |
104 | | - .any(|path| match_def_path(cx, def.did, &**path)) |
| 105 | + .any(|diag_item| cx.tcx.is_diagnostic_item(*diag_item, def.did)) |
105 | 106 | && is_mutable_type(cx, substs.type_at(0), span) |
106 | 107 | { |
107 | 108 | span_lint(cx, MUTABLE_KEY_TYPE, span, "mutable key type"); |
|
0 commit comments