]> git.lizzy.rs Git - rust.git/blobdiff - src/tools/clippy/clippy_lints/src/operators/cmp_owned.rs
Merge commit '4f142aa1058f14f153f8bfd2d82f04ddb9982388' into clippyup
[rust.git] / src / tools / clippy / clippy_lints / src / operators / cmp_owned.rs
index c9c777f1bd8d8854e66e19f4c0fa77b17a3bc059..24aeb82a37f3107095a9944ca1b5fb9738a0c51b 100644 (file)
@@ -1,7 +1,7 @@
 use clippy_utils::diagnostics::span_lint_and_then;
 use clippy_utils::source::snippet;
 use clippy_utils::ty::{implements_trait, is_copy};
-use clippy_utils::{match_any_def_paths, path_def_id, paths};
+use clippy_utils::{match_def_path, path_def_id, paths};
 use rustc_errors::Applicability;
 use rustc_hir::{BinOpKind, Expr, ExprKind, UnOp};
 use rustc_lint::LateContext;
@@ -49,13 +49,15 @@ fn check_op(cx: &LateContext<'_>, expr: &Expr<'_>, other: &Expr<'_>, left: bool)
             (arg, arg.span)
         },
         ExprKind::Call(path, [arg])
-            if path_def_id(cx, path)
-                .and_then(|id| match_any_def_paths(cx, id, &[&paths::FROM_STR_METHOD, &paths::FROM_FROM]))
-                .map_or(false, |idx| match idx {
-                    0 => true,
-                    1 => !is_copy(cx, typeck.expr_ty(expr)),
-                    _ => false,
-                }) =>
+            if path_def_id(cx, path).map_or(false, |id| {
+                if match_def_path(cx, id, &paths::FROM_STR_METHOD) {
+                    true
+                } else if cx.tcx.lang_items().from_fn() == Some(id) {
+                    !is_copy(cx, typeck.expr_ty(expr))
+                } else {
+                    false
+                }
+            }) =>
         {
             (arg, arg.span)
         },