@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::{span_lint_hir, span_lint_hir_and_then};
22use clippy_utils:: fn_has_unsatisfiable_preds;
33use clippy_utils:: mir:: { LocalUsage , PossibleBorrowerMap , visit_local_usage} ;
44use 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} ;
66use rustc_errors:: Applicability ;
77use rustc_hir:: intravisit:: FnKind ;
88use 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