Skip to content

Commit

Permalink
clippy: In cmp_owned, don't use Deref via * if non-Deref impl exists
Browse files Browse the repository at this point in the history
This avoids making a suggestion to write `*x` if `x` would also work.
  • Loading branch information
joshtriplett committed Jan 15, 2025
1 parent 8b933dd commit 113e13a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/tools/clippy/clippy_lints/src/operators/cmp_owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ fn check_op(cx: &LateContext<'_>, expr: &Expr<'_>, other: &Expr<'_>, left: bool)
let arg_snip = snippet(cx, arg_span, "..");
let expr_snip;
let eq_impl;
if with_deref.is_implemented() {
expr_snip = format!("*{arg_snip}");
eq_impl = with_deref;
} else {
if without_deref.is_implemented() {
expr_snip = arg_snip.to_string();
eq_impl = without_deref;
} else {
expr_snip = format!("*{arg_snip}");
eq_impl = with_deref;
};

let span;
Expand Down

0 comments on commit 113e13a

Please sign in to comment.