2022-06-30 02:33:18 +00:00
|
|
|
error[E0502]: cannot borrow `u` (via `u.y`) as immutable because it is also borrowed as mutable (via `u.x`)
|
2023-10-26 16:13:20 +00:00
|
|
|
--> $DIR/union-borrow-move-parent-sibling.rs:53:13
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
2022-06-30 02:33:18 +00:00
|
|
|
LL | let a = &mut (*u.x).0;
|
|
|
|
| --- mutable borrow occurs here (via `u.x`)
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let b = &u.y;
|
2022-06-30 02:33:18 +00:00
|
|
|
| ^^^^ immutable borrow of `u.y` -- which overlaps with `u.x` -- occurs here
|
2018-11-04 17:36:30 +00:00
|
|
|
LL | use_borrow(a);
|
2019-04-22 07:40:08 +00:00
|
|
|
| - mutable borrow later used here
|
|
|
|
|
|
2022-06-30 02:33:18 +00:00
|
|
|
= note: `u.y` is a field of the union `U`, so it overlaps the field `u.x`
|
|
|
|
|
|
|
|
error[E0507]: cannot move out of dereference of `ManuallyDrop<((MockVec<u8>, MockVec<u8>), MockVec<u8>)>`
|
2023-10-26 16:13:20 +00:00
|
|
|
--> $DIR/union-borrow-move-parent-sibling.rs:59:13
|
2022-06-30 02:33:18 +00:00
|
|
|
|
|
|
|
|
LL | let a = u.x.0;
|
2022-12-08 17:02:54 +00:00
|
|
|
| ^^^^^ move occurs because value has type `(MockVec<u8>, MockVec<u8>)`, which does not implement the `Copy` trait
|
|
|
|
|
|
|
|
|
help: consider borrowing here
|
|
|
|
|
|
|
|
|
LL | let a = &u.x.0;
|
|
|
|
| +
|
2018-08-08 12:28:26 +00:00
|
|
|
|
2019-04-22 07:40:08 +00:00
|
|
|
error[E0382]: use of moved value: `u`
|
2023-10-26 16:13:20 +00:00
|
|
|
--> $DIR/union-borrow-move-parent-sibling.rs:61:13
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
2022-06-30 02:33:18 +00:00
|
|
|
LL | let u = U { x: ManuallyDrop::new(((MockVec::new(), MockVec::new()), MockVec::new())) };
|
2019-04-22 07:40:08 +00:00
|
|
|
| - move occurs because `u` has type `U`, which does not implement the `Copy` trait
|
2018-08-08 12:28:26 +00:00
|
|
|
LL | let a = u.x.0;
|
2022-06-30 02:33:18 +00:00
|
|
|
LL | let a = u.x;
|
|
|
|
| --- value moved here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let b = u.y;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ^^^ value used here after move
|
2018-08-08 12:28:26 +00:00
|
|
|
|
2022-06-30 02:33:18 +00:00
|
|
|
error[E0502]: cannot borrow `u` (via `u.y`) as immutable because it is also borrowed as mutable (via `u.x`)
|
2023-10-26 16:13:20 +00:00
|
|
|
--> $DIR/union-borrow-move-parent-sibling.rs:67:13
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
2022-06-30 02:33:18 +00:00
|
|
|
LL | let a = &mut ((*u.x).0).0;
|
|
|
|
| --- mutable borrow occurs here (via `u.x`)
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let b = &u.y;
|
2022-06-30 02:33:18 +00:00
|
|
|
| ^^^^ immutable borrow of `u.y` -- which overlaps with `u.x` -- occurs here
|
2018-11-04 17:36:30 +00:00
|
|
|
LL | use_borrow(a);
|
2019-04-22 07:40:08 +00:00
|
|
|
| - mutable borrow later used here
|
|
|
|
|
|
2022-06-30 02:33:18 +00:00
|
|
|
= note: `u.y` is a field of the union `U`, so it overlaps the field `u.x`
|
2018-08-08 12:28:26 +00:00
|
|
|
|
2022-06-30 02:33:18 +00:00
|
|
|
error[E0507]: cannot move out of dereference of `ManuallyDrop<((MockVec<u8>, MockVec<u8>), MockVec<u8>)>`
|
2023-10-26 16:13:20 +00:00
|
|
|
--> $DIR/union-borrow-move-parent-sibling.rs:73:13
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
2022-06-30 02:33:18 +00:00
|
|
|
LL | let a = (u.x.0).0;
|
2022-12-08 17:02:54 +00:00
|
|
|
| ^^^^^^^^^ move occurs because value has type `MockVec<u8>`, which does not implement the `Copy` trait
|
|
|
|
|
|
2024-03-17 21:25:38 +00:00
|
|
|
note: if `MockVec<u8>` implemented `Clone`, you could clone the value
|
|
|
|
--> $DIR/union-borrow-move-parent-sibling.rs:25:1
|
|
|
|
|
|
|
|
|
LL | struct MockVec<T> {
|
Mention when type parameter could be `Clone`
```
error[E0382]: use of moved value: `t`
--> $DIR/use_of_moved_value_copy_suggestions.rs:7:9
|
LL | fn duplicate_t<T>(t: T) -> (T, T) {
| - move occurs because `t` has type `T`, which does not implement the `Copy` trait
...
LL | (t, t)
| - ^ value used here after move
| |
| value moved here
|
help: if `T` implemented `Clone`, you could clone the value
--> $DIR/use_of_moved_value_copy_suggestions.rs:4:16
|
LL | fn duplicate_t<T>(t: T) -> (T, T) {
| ^ consider constraining this type parameter with `Clone`
...
LL | (t, t)
| - you could clone this value
help: consider restricting type parameter `T`
|
LL | fn duplicate_t<T: Copy>(t: T) -> (T, T) {
| ++++++
```
The `help` is new. On ADTs, we also extend the output with span labels:
```
error[E0507]: cannot move out of static item `FOO`
--> $DIR/issue-17718-static-move.rs:6:14
|
LL | let _a = FOO;
| ^^^ move occurs because `FOO` has type `Foo`, which does not implement the `Copy` trait
|
note: if `Foo` implemented `Clone`, you could clone the value
--> $DIR/issue-17718-static-move.rs:1:1
|
LL | struct Foo;
| ^^^^^^^^^^ consider implementing `Clone` for this type
...
LL | let _a = FOO;
| --- you could clone this value
help: consider borrowing here
|
LL | let _a = &FOO;
| +
```
2024-04-18 22:18:19 +00:00
|
|
|
| ^^^^^^^^^^^^^^^^^ consider implementing `Clone` for this type
|
|
|
|
...
|
|
|
|
LL | let a = (u.x.0).0;
|
|
|
|
| --------- you could clone this value
|
2022-12-08 17:02:54 +00:00
|
|
|
help: consider borrowing here
|
|
|
|
|
|
|
|
|
LL | let a = &(u.x.0).0;
|
|
|
|
| +
|
2022-06-30 02:33:18 +00:00
|
|
|
|
|
|
|
error[E0382]: use of moved value: `u`
|
2023-10-26 16:13:20 +00:00
|
|
|
--> $DIR/union-borrow-move-parent-sibling.rs:75:13
|
2022-06-30 02:33:18 +00:00
|
|
|
|
|
|
|
|
LL | let u = U { x: ManuallyDrop::new(((MockVec::new(), MockVec::new()), MockVec::new())) };
|
2019-04-22 07:40:08 +00:00
|
|
|
| - move occurs because `u` has type `U`, which does not implement the `Copy` trait
|
2018-08-08 12:28:26 +00:00
|
|
|
LL | let a = (u.x.0).0;
|
2022-06-30 02:33:18 +00:00
|
|
|
LL | let a = u.x;
|
|
|
|
| --- value moved here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let b = u.y;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ^^^ value used here after move
|
2018-08-08 12:28:26 +00:00
|
|
|
|
2019-07-03 10:35:02 +00:00
|
|
|
error[E0502]: cannot borrow `u` (via `u.x`) as immutable because it is also borrowed as mutable (via `u.y`)
|
2023-10-26 16:13:20 +00:00
|
|
|
--> $DIR/union-borrow-move-parent-sibling.rs:81:13
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let a = &mut *u.y;
|
2019-07-03 10:35:02 +00:00
|
|
|
| --- mutable borrow occurs here (via `u.y`)
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let b = &u.x;
|
2019-07-03 10:35:02 +00:00
|
|
|
| ^^^^ immutable borrow of `u.x` -- which overlaps with `u.y` -- occurs here
|
2018-11-04 17:36:30 +00:00
|
|
|
LL | use_borrow(a);
|
2019-04-22 07:40:08 +00:00
|
|
|
| - mutable borrow later used here
|
|
|
|
|
|
2019-07-03 10:35:02 +00:00
|
|
|
= note: `u.x` is a field of the union `U`, so it overlaps the field `u.y`
|
2018-08-08 12:28:26 +00:00
|
|
|
|
2022-06-30 02:33:18 +00:00
|
|
|
error: aborting due to 7 previous errors
|
2018-08-08 12:28:26 +00:00
|
|
|
|
2022-06-30 02:33:18 +00:00
|
|
|
Some errors have detailed explanations: E0382, E0502, E0507.
|
2018-08-08 12:28:26 +00:00
|
|
|
For more information about an error, try `rustc --explain E0382`.
|