fork/rust

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

borsAuto merge of #66089 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum4560ea788cb

1.39.0
2.9 KiB70 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:15: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:22:13
15   |
16LL |     let u = U { x: ((Vec::new(), Vec::new()), Vec::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:28: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:35:13
37   |
38LL |     let u = U { x: ((Vec::new(), Vec::new()), Vec::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:41: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[E0382]: use of moved value: `u`
58  --> $DIR/union-borrow-move-parent-sibling.rs:48:13
59   |
60LL |     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
62LL |     let a = *u.y;
63   |             ---- value moved here
64LL |     let b = u.x;
65   |             ^^^ value used here after move
66
67error: aborting due to 6 previous errors
68
69Some errors have detailed explanations: E0382, E0502.
70For more information about an error, try `rustc --explain E0382`.