Skip to content

Commit 6617536

Browse files
authored
Rollup merge of #146907 - cyrgani:146537-test, r=nnethercote
add regression test for issue 146537 Adds a test based on the reduction in #146537 (comment). This was already fixed in #142882 before the issue was even reported, but no test for it was added yet.
2 parents bba509e + 60f6012 commit 6617536

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Regression test for #146537.
2+
3+
struct NonCopy;
4+
fn main() {
5+
let tuple = &(NonCopy,);
6+
let b: NonCopy;
7+
(b,) = *tuple; //~ ERROR: cannot move out of `tuple.0` which is behind a shared reference [E0507]
8+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
error[E0507]: cannot move out of `tuple.0` which is behind a shared reference
2+
--> $DIR/non_copy_move_out_of_tuple.rs:7:12
3+
|
4+
LL | (b,) = *tuple;
5+
| - ^^^^^^
6+
| |
7+
| data moved here
8+
| move occurs because the place has type `NonCopy`, which does not implement the `Copy` trait
9+
|
10+
note: if `NonCopy` implemented `Clone`, you could clone the value
11+
--> $DIR/non_copy_move_out_of_tuple.rs:3:1
12+
|
13+
LL | struct NonCopy;
14+
| ^^^^^^^^^^^^^^ consider implementing `Clone` for this type
15+
...
16+
LL | (b,) = *tuple;
17+
| - you could clone this value
18+
help: consider removing the dereference here
19+
|
20+
LL - (b,) = *tuple;
21+
LL + (b,) = tuple;
22+
|
23+
24+
error: aborting due to 1 previous error
25+
26+
For more information about this error, try `rustc --explain E0507`.

0 commit comments

Comments
 (0)