@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::{span_lint_hir, span_lint_hir_and_then};
2
2
use clippy_utils:: fn_has_unsatisfiable_preds;
3
3
use clippy_utils:: mir:: { LocalUsage , PossibleBorrowerMap , visit_local_usage} ;
4
4
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} ;
6
6
use rustc_errors:: Applicability ;
7
7
use rustc_hir:: intravisit:: FnKind ;
8
8
use rustc_hir:: { Body , FnDecl , LangItem , def_id} ;
@@ -147,8 +147,9 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClone {
147
147
is_call_with_ref_arg ( cx, mir, & pred_terminator. kind )
148
148
&& res == cloned
149
149
&& 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 )
152
153
{
153
154
( pred_arg, res)
154
155
} else {
0 commit comments