11use clippy_utils:: diagnostics:: span_lint_and_sugg;
22use clippy_utils:: source:: { reindent_multiline, snippet_indent, snippet_with_applicability, snippet_with_context} ;
33use 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 ,
66} ;
77use core:: fmt:: { self , Write } ;
88use rustc_errors:: Applicability ;
@@ -11,7 +11,7 @@ use rustc_hir::intravisit::{walk_expr, Visitor};
1111use rustc_hir:: { Block , Expr , ExprKind , HirId , Pat , Stmt , StmtKind , UnOp } ;
1212use rustc_lint:: { LateContext , LateLintPass } ;
1313use rustc_session:: declare_lint_pass;
14- use rustc_span:: { Span , SyntaxContext , DUMMY_SP } ;
14+ use rustc_span:: { sym , Span , SyntaxContext , DUMMY_SP } ;
1515
1616declare_clippy_lint ! {
1717 /// ### What it does
@@ -269,9 +269,9 @@ fn try_parse_contains<'tcx>(cx: &LateContext<'_>, expr: &'tcx Expr<'_>) -> Optio
269269 key,
270270 call_ctxt : expr. span . ctxt ( ) ,
271271 } ;
272- if match_def_path ( cx , id, & paths :: BTREEMAP_CONTAINS_KEY ) {
272+ if cx . tcx . is_diagnostic_item ( sym :: btreemap_contains_key , id) {
273273 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) {
275275 Some ( ( MapType :: Hash , expr) )
276276 } else {
277277 None
@@ -306,7 +306,7 @@ struct InsertExpr<'tcx> {
306306fn try_parse_insert < ' tcx > ( cx : & LateContext < ' tcx > , expr : & ' tcx Expr < ' _ > ) -> Option < InsertExpr < ' tcx > > {
307307 if let ExprKind :: MethodCall ( _, map, [ key, value] , _) = expr. kind {
308308 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) {
310310 Some ( InsertExpr { map, key, value } )
311311 } else {
312312 None
0 commit comments