From 0b65462ca52599162949df162239ce55de96b4b3 Mon Sep 17 00:00:00 2001 From: Josh Mcguigan Date: Thu, 11 Oct 2018 05:03:02 -0700 Subject: [PATCH] cmp_owned current suggestion for multiple deref --- clippy_lints/src/misc.rs | 2 +- tests/ui/cmp_owned.stderr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index 5f8480d8282..be863cd7bc8 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -546,7 +546,7 @@ fn check_to_owned(cx: &LateContext<'_, '_>, expr: &Expr, other: &Expr) { } else if other_gets_derefed { // suggest dropping the to_owned on the left and the deref on the right let other_snippet = snippet(cx, other.span, "..").into_owned(); - let other_without_deref = other_snippet.trim_left_matches('*'); + let other_without_deref = other_snippet.replacen('*', "", 1); (expr.span.to(other.span), format!("{} == {}", snip.to_string(), other_without_deref)) } else { diff --git a/tests/ui/cmp_owned.stderr b/tests/ui/cmp_owned.stderr index 0982467aeee..1db60be54d6 100644 --- a/tests/ui/cmp_owned.stderr +++ b/tests/ui/cmp_owned.stderr @@ -46,7 +46,7 @@ error: this creates an owned instance just for comparison --> $DIR/cmp_owned.rs:47:5 | 47 | y.to_owned() == **x; - | ^^^^^^^^^^^^^^^^^^^ help: try: `y == x` + | ^^^^^^^^^^^^^^^^^^^ help: try: `y == *x` error: this creates an owned instance just for comparison --> $DIR/cmp_owned.rs:54:9