@@ -2,7 +2,6 @@ use super::utils::derefs_to_slice;
2
2
use clippy_utils:: diagnostics:: span_lint_and_then;
3
3
use clippy_utils:: get_parent_expr;
4
4
use clippy_utils:: source:: snippet_with_applicability;
5
- use clippy_utils:: ty:: is_type_diagnostic_item;
6
5
use rustc_errors:: Applicability ;
7
6
use rustc_hir as hir;
8
7
use rustc_lint:: LateContext ;
@@ -22,16 +21,17 @@ pub(super) fn check<'tcx>(
22
21
let expr_ty = cx. typeck_results ( ) . expr_ty ( recv) ;
23
22
let caller_type = if derefs_to_slice ( cx, recv, expr_ty) . is_some ( ) {
24
23
"slice"
25
- } else if is_type_diagnostic_item ( cx, expr_ty, sym:: Vec ) {
26
- "Vec"
27
- } else if is_type_diagnostic_item ( cx, expr_ty, sym:: VecDeque ) {
28
- "VecDeque"
29
- } else if !is_mut && is_type_diagnostic_item ( cx, expr_ty, sym:: HashMap ) {
30
- "HashMap"
31
- } else if !is_mut && is_type_diagnostic_item ( cx, expr_ty, sym:: BTreeMap ) {
32
- "BTreeMap"
33
24
} else {
34
- return ; // caller is not a type that we want to lint
25
+ match expr_ty
26
+ . ty_adt_def ( )
27
+ . and_then ( |def| cx. tcx . get_diagnostic_name ( def. did ( ) ) )
28
+ {
29
+ Some ( sym:: Vec ) => "Vec" ,
30
+ Some ( sym:: VecDeque ) => "VecDeque" ,
31
+ Some ( sym:: HashMap ) if !is_mut => "HashMap" ,
32
+ Some ( sym:: BTreeMap ) if !is_mut => "BTreeMap" ,
33
+ _ => return , // caller is not a type that we want to lint
34
+ }
35
35
} ;
36
36
37
37
let mut span = expr. span ;
0 commit comments