]> git.lizzy.rs Git - rust.git/commitdiff
cmp_owned current suggestion for multiple deref
authorJosh Mcguigan <joshmcg88@gmail.com>
Thu, 11 Oct 2018 12:03:02 +0000 (05:03 -0700)
committerJosh Mcguigan <joshmcg88@gmail.com>
Thu, 11 Oct 2018 12:03:02 +0000 (05:03 -0700)
clippy_lints/src/misc.rs
tests/ui/cmp_owned.stderr

index 5f8480d8282d36b80e31a2209b5f15f147c27d64..be863cd7bc87443b0f36a9e2d453435f8f1d5f2e 100644 (file)
@@ -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 {
index 0982467aeee13e93baa099ec11b2dbcbd811eeaa..1db60be54d60d4ee18d59cfc222f7e8c2f9beaa0 100644 (file)
@@ -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