Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit f1fc9c0

Browse files
committed
[Clippy] Swap unnecessary_owned_empty_strings to use diagnostic item instead of path
1 parent 1b76ae6 commit f1fc9c0

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

clippy_lints/src/unnecessary_owned_empty_strings.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use clippy_utils::diagnostics::span_lint_and_sugg;
22
use clippy_utils::ty::is_type_lang_item;
3-
use clippy_utils::{match_def_path, paths};
43
use rustc_ast::ast::LitKind;
54
use rustc_errors::Applicability;
65
use rustc_hir::{BorrowKind, Expr, ExprKind, LangItem, Mutability};
@@ -42,7 +41,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryOwnedEmptyStrings {
4241
&& let ty::Ref(_, inner_str, _) = cx.typeck_results().expr_ty_adjusted(expr).kind()
4342
&& inner_str.is_str()
4443
{
45-
if match_def_path(cx, fun_def_id, &paths::STRING_NEW) {
44+
if cx.tcx.is_diagnostic_item(sym::string_new, fun_def_id) {
4645
span_lint_and_sugg(
4746
cx,
4847
UNNECESSARY_OWNED_EMPTY_STRINGS,

clippy_utils/src/paths.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ pub const SERDE_DESERIALIZE: [&str; 3] = ["serde", "de", "Deserialize"];
5151
pub const SERDE_DE_VISITOR: [&str; 3] = ["serde", "de", "Visitor"];
5252
pub const STD_IO_SEEK_FROM_CURRENT: [&str; 4] = ["std", "io", "SeekFrom", "Current"];
5353
pub const STD_IO_SEEKFROM_START: [&str; 4] = ["std", "io", "SeekFrom", "Start"];
54-
pub const STRING_NEW: [&str; 4] = ["alloc", "string", "String", "new"];
5554
pub const SYMBOL: [&str; 3] = ["rustc_span", "symbol", "Symbol"];
5655
pub const SYMBOL_AS_STR: [&str; 4] = ["rustc_span", "symbol", "Symbol", "as_str"];
5756
pub const SYMBOL_INTERN: [&str; 4] = ["rustc_span", "symbol", "Symbol", "intern"];

0 commit comments

Comments
 (0)