File: union-borrow-move-parent-sibling.stderr

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, sid, trixie
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (92 lines) | stat: -rw-r--r-- 3,787 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
error[E0502]: cannot borrow `u` (via `u.y`) as immutable because it is also borrowed as mutable (via `u.x`)
  --> $DIR/union-borrow-move-parent-sibling.rs:53:13
   |
LL |     let a = &mut (*u.x).0;
   |                    --- mutable borrow occurs here (via `u.x`)
LL |     let b = &u.y;
   |             ^^^^ immutable borrow of `u.y` -- which overlaps with `u.x` -- occurs here
LL |     use_borrow(a);
   |                - mutable borrow later used here
   |
   = 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>)>`
  --> $DIR/union-borrow-move-parent-sibling.rs:59:13
   |
LL |     let a = u.x.0;
   |             ^^^^^ 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;
   |             +

error[E0382]: use of moved value: `u`
  --> $DIR/union-borrow-move-parent-sibling.rs:61:13
   |
LL |     let u = U { x: ManuallyDrop::new(((MockVec::new(), MockVec::new()), MockVec::new())) };
   |         - move occurs because `u` has type `U`, which does not implement the `Copy` trait
LL |     let a = u.x.0;
LL |     let a = u.x;
   |             --- value moved here
LL |     let b = u.y;
   |             ^^^ value used here after move

error[E0502]: cannot borrow `u` (via `u.y`) as immutable because it is also borrowed as mutable (via `u.x`)
  --> $DIR/union-borrow-move-parent-sibling.rs:67:13
   |
LL |     let a = &mut ((*u.x).0).0;
   |                     --- mutable borrow occurs here (via `u.x`)
LL |     let b = &u.y;
   |             ^^^^ immutable borrow of `u.y` -- which overlaps with `u.x` -- occurs here
LL |     use_borrow(a);
   |                - mutable borrow later used here
   |
   = 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>)>`
  --> $DIR/union-borrow-move-parent-sibling.rs:73:13
   |
LL |     let a = (u.x.0).0;
   |             ^^^^^^^^^ move occurs because value has type `MockVec<u8>`, which does not implement the `Copy` trait
   |
note: if `MockVec<u8>` implemented `Clone`, you could clone the value
  --> $DIR/union-borrow-move-parent-sibling.rs:25:1
   |
LL | struct MockVec<T> {
   | ^^^^^^^^^^^^^^^^^ consider implementing `Clone` for this type
...
LL |     let a = (u.x.0).0;
   |             --------- you could clone this value
help: consider borrowing here
   |
LL |     let a = &(u.x.0).0;
   |             +

error[E0382]: use of moved value: `u`
  --> $DIR/union-borrow-move-parent-sibling.rs:75:13
   |
LL |     let u = U { x: ManuallyDrop::new(((MockVec::new(), MockVec::new()), MockVec::new())) };
   |         - move occurs because `u` has type `U`, which does not implement the `Copy` trait
LL |     let a = (u.x.0).0;
LL |     let a = u.x;
   |             --- value moved here
LL |     let b = u.y;
   |             ^^^ value used here after move

error[E0502]: cannot borrow `u` (via `u.x`) as immutable because it is also borrowed as mutable (via `u.y`)
  --> $DIR/union-borrow-move-parent-sibling.rs:81:13
   |
LL |     let a = &mut *u.y;
   |                   --- mutable borrow occurs here (via `u.y`)
LL |     let b = &u.x;
   |             ^^^^ immutable borrow of `u.x` -- which overlaps with `u.y` -- occurs here
LL |     use_borrow(a);
   |                - mutable borrow later used here
   |
   = note: `u.x` is a field of the union `U`, so it overlaps the field `u.y`

error: aborting due to 7 previous errors

Some errors have detailed explanations: E0382, E0502, E0507.
For more information about an error, try `rustc --explain E0382`.