mirror of
https://github.com/rust-lang/rust.git
synced 2025-09-26 20:21:59 +00:00
Rollup merge of #146907 - cyrgani:146537-test, r=nnethercote
add regression test for issue 146537 Adds a test based on the reduction in https://github.com/rust-lang/rust/issues/146537#issuecomment-3289438439. This was already fixed in rust-lang/rust#142882 before the issue was even reported, but no test for it was added yet.
This commit is contained in:
commit
6617536d14
8
tests/ui/suggestions/non_copy_move_out_of_tuple.rs
Normal file
8
tests/ui/suggestions/non_copy_move_out_of_tuple.rs
Normal file
@ -0,0 +1,8 @@
|
||||
// Regression test for #146537.
|
||||
|
||||
struct NonCopy;
|
||||
fn main() {
|
||||
let tuple = &(NonCopy,);
|
||||
let b: NonCopy;
|
||||
(b,) = *tuple; //~ ERROR: cannot move out of `tuple.0` which is behind a shared reference [E0507]
|
||||
}
|
26
tests/ui/suggestions/non_copy_move_out_of_tuple.stderr
Normal file
26
tests/ui/suggestions/non_copy_move_out_of_tuple.stderr
Normal file
@ -0,0 +1,26 @@
|
||||
error[E0507]: cannot move out of `tuple.0` which is behind a shared reference
|
||||
--> $DIR/non_copy_move_out_of_tuple.rs:7:12
|
||||
|
|
||||
LL | (b,) = *tuple;
|
||||
| - ^^^^^^
|
||||
| |
|
||||
| data moved here
|
||||
| move occurs because the place has type `NonCopy`, which does not implement the `Copy` trait
|
||||
|
|
||||
note: if `NonCopy` implemented `Clone`, you could clone the value
|
||||
--> $DIR/non_copy_move_out_of_tuple.rs:3:1
|
||||
|
|
||||
LL | struct NonCopy;
|
||||
| ^^^^^^^^^^^^^^ consider implementing `Clone` for this type
|
||||
...
|
||||
LL | (b,) = *tuple;
|
||||
| - you could clone this value
|
||||
help: consider removing the dereference here
|
||||
|
|
||||
LL - (b,) = *tuple;
|
||||
LL + (b,) = tuple;
|
||||
|
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0507`.
|
Loading…
x
Reference in New Issue
Block a user