diff --git a/tests/ui/cmp_owned.rs b/tests/ui/cmp_owned.rs
index 65351cd9b9d..dc0880e7089 100644
--- a/tests/ui/cmp_owned.rs
+++ b/tests/ui/cmp_owned.rs
@@ -40,6 +40,11 @@ fn main() {
     let y = &Baz;
 
     y.to_owned() == *x;
+
+    let x = &&Baz;
+    let y = &Baz;
+
+    y.to_owned() == **x;
 }
 
 struct Foo;
diff --git a/tests/ui/cmp_owned.stderr b/tests/ui/cmp_owned.stderr
index 2613d3b7500..0982467aeee 100644
--- a/tests/ui/cmp_owned.stderr
+++ b/tests/ui/cmp_owned.stderr
@@ -43,10 +43,16 @@ error: this creates an owned instance just for comparison
    |     ^^^^^^^^^^^^^^^^^^ help: try: `y == x`
 
 error: this creates an owned instance just for comparison
-  --> $DIR/cmp_owned.rs:49:9
+  --> $DIR/cmp_owned.rs:47:5
    |
-49 |         self.to_owned() == *other
+47 |     y.to_owned() == **x;
+   |     ^^^^^^^^^^^^^^^^^^^ help: try: `y == x`
+
+error: this creates an owned instance just for comparison
+  --> $DIR/cmp_owned.rs:54:9
+   |
+54 |         self.to_owned() == *other
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating
 
-error: aborting due to 8 previous errors
+error: aborting due to 9 previous errors