Skip to content

Commit 0b65462

Browse files
committed
cmp_owned current suggestion for multiple deref
1 parent d416155 commit 0b65462

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

clippy_lints/src/misc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ fn check_to_owned(cx: &LateContext<'_, '_>, expr: &Expr, other: &Expr) {
546546
} else if other_gets_derefed {
547547
// suggest dropping the to_owned on the left and the deref on the right
548548
let other_snippet = snippet(cx, other.span, "..").into_owned();
549-
let other_without_deref = other_snippet.trim_left_matches('*');
549+
let other_without_deref = other_snippet.replacen('*', "", 1);
550550

551551
(expr.span.to(other.span), format!("{} == {}", snip.to_string(), other_without_deref))
552552
} else {

tests/ui/cmp_owned.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ error: this creates an owned instance just for comparison
4646
--> $DIR/cmp_owned.rs:47:5
4747
|
4848
47 | y.to_owned() == **x;
49-
| ^^^^^^^^^^^^^^^^^^^ help: try: `y == x`
49+
| ^^^^^^^^^^^^^^^^^^^ help: try: `y == *x`
5050

5151
error: this creates an owned instance just for comparison
5252
--> $DIR/cmp_owned.rs:54:9

0 commit comments

Comments
 (0)