Skip to content

Commit dca603c

Browse files
committed
redundant_clone: partially inline is_type_diagnostic_item
to be able to reuse `did`
1 parent b934e68 commit dca603c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

clippy_lints/src/redundant_clone.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::{span_lint_hir, span_lint_hir_and_then};
22
use clippy_utils::fn_has_unsatisfiable_preds;
33
use clippy_utils::mir::{LocalUsage, PossibleBorrowerMap, visit_local_usage};
44
use clippy_utils::source::SpanRangeExt;
5-
use clippy_utils::ty::{has_drop, is_copy, is_type_diagnostic_item, is_type_lang_item, walk_ptrs_ty_depth};
5+
use clippy_utils::ty::{has_drop, is_copy, is_type_lang_item, walk_ptrs_ty_depth};
66
use rustc_errors::Applicability;
77
use rustc_hir::intravisit::FnKind;
88
use rustc_hir::{Body, FnDecl, LangItem, def_id};
@@ -147,8 +147,9 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClone {
147147
is_call_with_ref_arg(cx, mir, &pred_terminator.kind)
148148
&& res == cloned
149149
&& cx.tcx.is_diagnostic_item(sym::deref_method, pred_fn_def_id)
150-
&& (is_type_diagnostic_item(cx, pred_arg_ty, sym::PathBuf)
151-
|| is_type_diagnostic_item(cx, pred_arg_ty, sym::OsString))
150+
&& let ty::Adt(pred_arg_def, _) = pred_arg_ty.kind()
151+
&& let Some(pred_arg_name) = cx.tcx.get_diagnostic_name(pred_arg_def.did())
152+
&& matches!(pred_arg_name, sym::PathBuf | sym::OsString)
152153
{
153154
(pred_arg, res)
154155
} else {

0 commit comments

Comments
 (0)