fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #67350 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum73528e339aa

1.40.0
2.6 KiB60 linesraw
1error[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:53:13
3   |
4LL |     let a = &mut u.x.0;
5   |             ---------- mutable borrow occurs here (via `u.x.0`)
6LL |     let b = &u.y;
7   |             ^^^^ immutable borrow of `u.y` -- which overlaps with `u.x.0` -- occurs here
8LL |     use_borrow(a);
9   |                - mutable borrow later used here
10   |
11   = note: `u.y` is a field of the union `U`, so it overlaps the field `u.x.0`
12
13error[E0382]: use of moved value: `u`
14  --> $DIR/union-borrow-move-parent-sibling.rs:60:13
15   |
16LL |     let u = U { x: ((MockVec::new(), MockVec::new()), MockVec::new()) };
17   |         - move occurs because `u` has type `U`, which does not implement the `Copy` trait
18LL |     let a = u.x.0;
19   |             ----- value moved here
20LL |     let b = u.y;
21   |             ^^^ value used here after move
22
23error[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:66:13
25   |
26LL |     let a = &mut (u.x.0).0;
27   |             -------------- mutable borrow occurs here (via `u.x.0.0`)
28LL |     let b = &u.y;
29   |             ^^^^ immutable borrow of `u.y` -- which overlaps with `u.x.0.0` -- occurs here
30LL |     use_borrow(a);
31   |                - mutable borrow later used here
32   |
33   = note: `u.y` is a field of the union `U`, so it overlaps the field `u.x.0.0`
34
35error[E0382]: use of moved value: `u`
36  --> $DIR/union-borrow-move-parent-sibling.rs:73:13
37   |
38LL |     let u = U { x: ((MockVec::new(), MockVec::new()), MockVec::new()) };
39   |         - move occurs because `u` has type `U`, which does not implement the `Copy` trait
40LL |     let a = (u.x.0).0;
41   |             --------- value moved here
42LL |     let b = u.y;
43   |             ^^^ value used here after move
44
45error[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:79:13
47   |
48LL |     let a = &mut *u.y;
49   |                   --- mutable borrow occurs here (via `u.y`)
50LL |     let b = &u.x;
51   |             ^^^^ immutable borrow of `u.x` -- which overlaps with `u.y` -- occurs here
52LL |     use_borrow(a);
53   |                - mutable borrow later used here
54   |
55   = note: `u.x` is a field of the union `U`, so it overlaps the field `u.y`
56
57error: aborting due to 5 previous errors
58
59Some errors have detailed explanations: E0382, E0502.
60For more information about an error, try `rustc --explain E0382`.