Skip to content

Commit d416155

Browse files
committed
cmp_owned add test for multiple dereference
1 parent 88ee209 commit d416155

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

tests/ui/cmp_owned.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ fn main() {
4040
let y = &Baz;
4141

4242
y.to_owned() == *x;
43+
44+
let x = &&Baz;
45+
let y = &Baz;
46+
47+
y.to_owned() == **x;
4348
}
4449

4550
struct Foo;

tests/ui/cmp_owned.stderr

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,16 @@ error: this creates an owned instance just for comparison
4343
| ^^^^^^^^^^^^^^^^^^ help: try: `y == x`
4444

4545
error: this creates an owned instance just for comparison
46-
--> $DIR/cmp_owned.rs:49:9
46+
--> $DIR/cmp_owned.rs:47:5
4747
|
48-
49 | self.to_owned() == *other
48+
47 | y.to_owned() == **x;
49+
| ^^^^^^^^^^^^^^^^^^^ help: try: `y == x`
50+
51+
error: this creates an owned instance just for comparison
52+
--> $DIR/cmp_owned.rs:54:9
53+
|
54+
54 | self.to_owned() == *other
4955
| ^^^^^^^^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating
5056

51-
error: aborting due to 8 previous errors
57+
error: aborting due to 9 previous errors
5258

0 commit comments

Comments
 (0)