]> git.lizzy.rs Git - rust.git/commitdiff
cmp_owned correct error message if rhs is deref
authorJosh Mcguigan <joshmcg88@gmail.com>
Fri, 12 Oct 2018 11:34:41 +0000 (04:34 -0700)
committerJosh Mcguigan <joshmcg88@gmail.com>
Fri, 12 Oct 2018 11:34:41 +0000 (04:34 -0700)
clippy_lints/src/misc.rs
tests/ui/cmp_owned.stderr

index be863cd7bc87443b0f36a9e2d453435f8f1d5f2e..0a65953313ed79751deb1a78b3ef0a38f710b883 100644 (file)
@@ -579,6 +579,10 @@ fn check_to_owned(cx: &LateContext<'_, '_>, expr: &Expr, other: &Expr) {
                     }
                 }
             }
+            if other_gets_derefed {
+                db.span_label(lint_span, "try implementing the comparison without allocating");
+                return;
+            }
             db.span_suggestion_with_applicability(
                 lint_span,
                 "try",
index 1db60be54d60d4ee18d59cfc222f7e8c2f9beaa0..a7371ab4b6c3fbe380200d2f6365b89cd34db2ec 100644 (file)
@@ -40,13 +40,13 @@ error: this creates an owned instance just for comparison
   --> $DIR/cmp_owned.rs:42:5
    |
 42 |     y.to_owned() == *x;
-   |     ^^^^^^^^^^^^^^^^^^ help: try: `y == x`
+   |     ^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating
 
 error: this creates an owned instance just for comparison
   --> $DIR/cmp_owned.rs:47:5
    |
 47 |     y.to_owned() == **x;
-   |     ^^^^^^^^^^^^^^^^^^^ help: try: `y == *x`
+   |     ^^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating
 
 error: this creates an owned instance just for comparison
   --> $DIR/cmp_owned.rs:54:9