Skip to content

Commit 113e13a

Browse files
committed
clippy: In cmp_owned, don't use Deref via * if non-Deref impl exists
This avoids making a suggestion to write `*x` if `x` would also work.
1 parent 8b933dd commit 113e13a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/tools/clippy/clippy_lints/src/operators/cmp_owned.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ fn check_op(cx: &LateContext<'_>, expr: &Expr<'_>, other: &Expr<'_>, left: bool)
9898
let arg_snip = snippet(cx, arg_span, "..");
9999
let expr_snip;
100100
let eq_impl;
101-
if with_deref.is_implemented() {
102-
expr_snip = format!("*{arg_snip}");
103-
eq_impl = with_deref;
104-
} else {
101+
if without_deref.is_implemented() {
105102
expr_snip = arg_snip.to_string();
106103
eq_impl = without_deref;
104+
} else {
105+
expr_snip = format!("*{arg_snip}");
106+
eq_impl = with_deref;
107107
};
108108

109109
let span;

0 commit comments

Comments
 (0)