1
1
use clippy_utils:: diagnostics:: span_lint_and_sugg;
2
2
use clippy_utils:: source:: { reindent_multiline, snippet_indent, snippet_with_applicability, snippet_with_context} ;
3
3
use clippy_utils:: {
4
- can_move_expr_to_closure_no_visit, higher, is_expr_final_block_expr, is_expr_used_or_unified, match_def_path ,
5
- paths , peel_hir_expr_while, SpanlessEq ,
4
+ can_move_expr_to_closure_no_visit, higher, is_expr_final_block_expr, is_expr_used_or_unified,
5
+ peel_hir_expr_while, SpanlessEq ,
6
6
} ;
7
7
use core:: fmt:: { self , Write } ;
8
8
use rustc_errors:: Applicability ;
@@ -11,7 +11,7 @@ use rustc_hir::intravisit::{walk_expr, Visitor};
11
11
use rustc_hir:: { Block , Expr , ExprKind , HirId , Pat , Stmt , StmtKind , UnOp } ;
12
12
use rustc_lint:: { LateContext , LateLintPass } ;
13
13
use rustc_session:: declare_lint_pass;
14
- use rustc_span:: { Span , SyntaxContext , DUMMY_SP } ;
14
+ use rustc_span:: { sym , Span , SyntaxContext , DUMMY_SP } ;
15
15
16
16
declare_clippy_lint ! {
17
17
/// ### What it does
@@ -269,9 +269,9 @@ fn try_parse_contains<'tcx>(cx: &LateContext<'_>, expr: &'tcx Expr<'_>) -> Optio
269
269
key,
270
270
call_ctxt : expr. span . ctxt ( ) ,
271
271
} ;
272
- if match_def_path ( cx , id, & paths :: BTREEMAP_CONTAINS_KEY ) {
272
+ if cx . tcx . is_diagnostic_item ( sym :: btreemap_contains_key , id) {
273
273
Some ( ( MapType :: BTree , expr) )
274
- } else if match_def_path ( cx , id, & paths :: HASHMAP_CONTAINS_KEY ) {
274
+ } else if cx . tcx . is_diagnostic_item ( sym :: hashmap_contains_key , id) {
275
275
Some ( ( MapType :: Hash , expr) )
276
276
} else {
277
277
None
@@ -306,7 +306,7 @@ struct InsertExpr<'tcx> {
306
306
fn try_parse_insert < ' tcx > ( cx : & LateContext < ' tcx > , expr : & ' tcx Expr < ' _ > ) -> Option < InsertExpr < ' tcx > > {
307
307
if let ExprKind :: MethodCall ( _, map, [ key, value] , _) = expr. kind {
308
308
let id = cx. typeck_results ( ) . type_dependent_def_id ( expr. hir_id ) ?;
309
- if match_def_path ( cx , id, & paths :: BTREEMAP_INSERT ) || match_def_path ( cx , id, & paths :: HASHMAP_INSERT ) {
309
+ if cx . tcx . is_diagnostic_item ( sym :: btreemap_insert , id) || cx . tcx . is_diagnostic_item ( sym :: hashmap_insert , id) {
310
310
Some ( InsertExpr { map, key, value } )
311
311
} else {
312
312
None
0 commit comments