diff --git a/clippy_lints/src/format_push_string.rs b/clippy_lints/src/format_push_string.rs index d05c5a01f41ce..c6f03c3a7cf9a 100644 --- a/clippy_lints/src/format_push_string.rs +++ b/clippy_lints/src/format_push_string.rs @@ -1,6 +1,6 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::ty::is_type_lang_item; -use clippy_utils::{higher, match_def_path, paths}; +use clippy_utils::higher; use rustc_hir::{BinOpKind, Expr, ExprKind, LangItem, MatchSource}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; @@ -70,7 +70,7 @@ impl<'tcx> LateLintPass<'tcx> for FormatPushString { let arg = match expr.kind { ExprKind::MethodCall(_, _, [arg], _) => { if let Some(fn_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) - && match_def_path(cx, fn_def_id, &paths::PUSH_STR) + && cx.tcx.is_diagnostic_item(sym::string_push_str, fn_def_id) { arg } else { diff --git a/clippy_lints/src/methods/single_char_add_str.rs b/clippy_lints/src/methods/single_char_add_str.rs index 81450fd8c6c3c..ccdf5529d537a 100644 --- a/clippy_lints/src/methods/single_char_add_str.rs +++ b/clippy_lints/src/methods/single_char_add_str.rs @@ -1,13 +1,13 @@ use crate::methods::{single_char_insert_string, single_char_push_string}; -use clippy_utils::{match_def_path, paths}; use rustc_hir as hir; use rustc_lint::LateContext; +use rustc_span::sym; pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, receiver: &hir::Expr<'_>, args: &[hir::Expr<'_>]) { if let Some(fn_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) { - if match_def_path(cx, fn_def_id, &paths::PUSH_STR) { + if cx.tcx.is_diagnostic_item(sym::string_push_str, fn_def_id) { single_char_push_string::check(cx, expr, receiver, args); - } else if match_def_path(cx, fn_def_id, &paths::INSERT_STR) { + } else if cx.tcx.is_diagnostic_item(sym::string_insert_str, fn_def_id) { single_char_insert_string::check(cx, expr, receiver, args); } } diff --git a/clippy_utils/src/paths.rs b/clippy_utils/src/paths.rs index 5e8157ac0c302..64540637cdbfb 100644 --- a/clippy_utils/src/paths.rs +++ b/clippy_utils/src/paths.rs @@ -29,7 +29,6 @@ pub const HASHSET_ITER_TY: [&str; 5] = ["std", "collections", "hash", "set", "It pub const HASHSET_DRAIN: [&str; 5] = ["std", "collections", "hash", "set", "Drain"]; pub const IDENT: [&str; 3] = ["rustc_span", "symbol", "Ident"]; pub const IDENT_AS_STR: [&str; 4] = ["rustc_span", "symbol", "Ident", "as_str"]; -pub const INSERT_STR: [&str; 4] = ["alloc", "string", "String", "insert_str"]; pub const ITERTOOLS_NEXT_TUPLE: [&str; 3] = ["itertools", "Itertools", "next_tuple"]; pub const KW_MODULE: [&str; 3] = ["rustc_span", "symbol", "kw"]; pub const LATE_CONTEXT: [&str; 2] = ["rustc_lint", "LateContext"]; @@ -42,7 +41,6 @@ pub const PARKING_LOT_RWLOCK_READ_GUARD: [&str; 3] = ["lock_api", "rwlock", "RwL pub const PARKING_LOT_RWLOCK_WRITE_GUARD: [&str; 3] = ["lock_api", "rwlock", "RwLockWriteGuard"]; #[cfg_attr(not(unix), allow(clippy::invalid_paths))] pub const PERMISSIONS_FROM_MODE: [&str; 6] = ["std", "os", "unix", "fs", "PermissionsExt", "from_mode"]; -pub const PUSH_STR: [&str; 4] = ["alloc", "string", "String", "push_str"]; pub const REGEX_BUILDER_NEW: [&str; 3] = ["regex", "RegexBuilder", "new"]; pub const REGEX_BYTES_BUILDER_NEW: [&str; 4] = ["regex", "bytes", "RegexBuilder", "new"]; pub const REGEX_BYTES_NEW: [&str; 4] = ["regex", "bytes", "Regex", "new"];