1
1
error[E0502]: cannot borrow `u` (via `u.y`) as immutable because it is also borrowed as mutable (via `u.x.0`)
2
- --> $DIR/union-borrow-move-parent-sibling.rs:15 :13
2
+ --> $DIR/union-borrow-move-parent-sibling.rs:54 :13
3
3
|
4
4
LL | let a = &mut u.x.0;
5
5
| ---------- mutable borrow occurs here (via `u.x.0`)
@@ -11,17 +11,17 @@ LL | use_borrow(a);
11
11
= note: `u.y` is a field of the union `U`, so it overlaps the field `u.x.0`
12
12
13
13
error[E0382]: use of moved value: `u`
14
- --> $DIR/union-borrow-move-parent-sibling.rs:22 :13
14
+ --> $DIR/union-borrow-move-parent-sibling.rs:61 :13
15
15
|
16
- LL | let u = U { x: ((Vec ::new(), Vec ::new()), Vec ::new()) };
16
+ LL | let u = U { x: ((MockVec ::new(), MockVec ::new()), MockVec ::new()) };
17
17
| - move occurs because `u` has type `U`, which does not implement the `Copy` trait
18
18
LL | let a = u.x.0;
19
19
| ----- value moved here
20
20
LL | let b = u.y;
21
21
| ^^^ value used here after move
22
22
23
23
error[E0502]: cannot borrow `u` (via `u.y`) as immutable because it is also borrowed as mutable (via `u.x.0.0`)
24
- --> $DIR/union-borrow-move-parent-sibling.rs:28 :13
24
+ --> $DIR/union-borrow-move-parent-sibling.rs:67 :13
25
25
|
26
26
LL | let a = &mut (u.x.0).0;
27
27
| -------------- mutable borrow occurs here (via `u.x.0.0`)
@@ -33,38 +33,28 @@ LL | use_borrow(a);
33
33
= note: `u.y` is a field of the union `U`, so it overlaps the field `u.x.0.0`
34
34
35
35
error[E0382]: use of moved value: `u`
36
- --> $DIR/union-borrow-move-parent-sibling.rs:35 :13
36
+ --> $DIR/union-borrow-move-parent-sibling.rs:74 :13
37
37
|
38
- LL | let u = U { x: ((Vec ::new(), Vec ::new()), Vec ::new()) };
38
+ LL | let u = U { x: ((MockVec ::new(), MockVec ::new()), MockVec ::new()) };
39
39
| - move occurs because `u` has type `U`, which does not implement the `Copy` trait
40
40
LL | let a = (u.x.0).0;
41
41
| --------- value moved here
42
42
LL | let b = u.y;
43
43
| ^^^ value used here after move
44
44
45
- error[E0502]: cannot borrow `u` (via `u.x`) as immutable because it is also borrowed as mutable (via `* u.y`)
46
- --> $DIR/union-borrow-move-parent-sibling.rs:41 :13
45
+ error[E0502]: cannot borrow `u` (via `u.x`) as immutable because it is also borrowed as mutable (via `u.y`)
46
+ --> $DIR/union-borrow-move-parent-sibling.rs:80 :13
47
47
|
48
48
LL | let a = &mut *u.y;
49
- | --------- mutable borrow occurs here (via `* u.y`)
49
+ | --- mutable borrow occurs here (via `u.y`)
50
50
LL | let b = &u.x;
51
- | ^^^^ immutable borrow of `u.x` -- which overlaps with `* u.y` -- occurs here
51
+ | ^^^^ immutable borrow of `u.x` -- which overlaps with `u.y` -- occurs here
52
52
LL | use_borrow(a);
53
53
| - mutable borrow later used here
54
54
|
55
- = note: `u.x` is a field of the union `U`, so it overlaps the field `* u.y`
55
+ = note: `u.x` is a field of the union `U`, so it overlaps the field `u.y`
56
56
57
- error[E0382]: use of moved value: `u`
58
- --> $DIR/union-borrow-move-parent-sibling.rs:48:13
59
- |
60
- LL | let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) };
61
- | - move occurs because `u` has type `U`, which does not implement the `Copy` trait
62
- LL | let a = *u.y;
63
- | ---- value moved here
64
- LL | let b = u.x;
65
- | ^^^ value used here after move
66
-
67
- error: aborting due to 6 previous errors
57
+ error: aborting due to 5 previous errors
68
58
69
59
Some errors have detailed explanations: E0382, E0502.
70
60
For more information about an error, try `rustc --explain E0382`.
0 commit comments