cmp_owned add test for multiple dereference

This commit is contained in:
Josh Mcguigan 2018-10-10 04:51:06 -07:00
parent 88ee209a1d
commit d41615548e
2 changed files with 14 additions and 3 deletions

View File

@ -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;

View File

@ -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