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

Commit acb6748

Browse files
committed
[Clippy] Swap unnecessary_to_owned to use diagnostic item instead of path
1 parent 98dc68e commit acb6748

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

clippy_lints/src/methods/unnecessary_to_owned.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use clippy_utils::source::{snippet, SpanRangeExt};
66
use clippy_utils::ty::{get_iterator_item_ty, implements_trait, is_copy, is_type_diagnostic_item, is_type_lang_item};
77
use clippy_utils::visitors::find_all_ret_expressions;
88
use clippy_utils::{
9-
fn_def_id, get_parent_expr, is_diag_item_method, is_diag_trait_item, match_def_path, paths, peel_middle_ty_refs,
9+
fn_def_id, get_parent_expr, is_diag_item_method, is_diag_trait_item, peel_middle_ty_refs,
1010
return_ty,
1111
};
1212
use rustc_errors::Applicability;
@@ -250,7 +250,7 @@ fn check_string_from_utf8<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>,
250250
if let Some((call, arg)) = skip_addr_of_ancestors(cx, expr)
251251
&& !arg.span.from_expansion()
252252
&& let ExprKind::Call(callee, _) = call.kind
253-
&& fn_def_id(cx, call).is_some_and(|did| match_def_path(cx, did, &paths::STRING_FROM_UTF8))
253+
&& fn_def_id(cx, call).is_some_and(|did| cx.tcx.is_diagnostic_item(sym::string_from_utf8, did))
254254
&& let Some(unwrap_call) = get_parent_expr(cx, call)
255255
&& let ExprKind::MethodCall(unwrap_method_name, ..) = unwrap_call.kind
256256
&& matches!(unwrap_method_name.ident.name, sym::unwrap | sym::expect)

clippy_utils/src/paths.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ pub const SYMBOL_INTERN: [&str; 4] = ["rustc_span", "symbol", "Symbol", "intern"
6161
pub const SYMBOL_TO_IDENT_STRING: [&str; 4] = ["rustc_span", "symbol", "Symbol", "to_ident_string"];
6262
pub const SYM_MODULE: [&str; 3] = ["rustc_span", "symbol", "sym"];
6363
pub const SYNTAX_CONTEXT: [&str; 3] = ["rustc_span", "hygiene", "SyntaxContext"];
64-
pub const STRING_FROM_UTF8: [&str; 4] = ["alloc", "string", "String", "from_utf8"];
6564
#[expect(clippy::invalid_paths)] // internal lints do not know about all external crates
6665
pub const TOKIO_FILE_OPTIONS: [&str; 5] = ["tokio", "fs", "file", "File", "options"];
6766
#[expect(clippy::invalid_paths)] // internal lints do not know about all external crates

0 commit comments

Comments
 (0)