]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrowck-union-borrow.stderr
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / borrowck / borrowck-union-borrow.stderr
1 error[E0502]: cannot borrow `u.a` as mutable because it is also borrowed as immutable
2   --> $DIR/borrowck-union-borrow.rs:23:23
3    |
4 LL |             let ra = &u.a;
5    |                      ---- immutable borrow occurs here
6 LL |             let rma = &mut u.a;
7    |                       ^^^^^^^^ mutable borrow occurs here
8 LL |             drop(ra);
9    |                  -- immutable borrow later used here
10
11 error[E0506]: cannot assign to `u.a` because it is borrowed
12   --> $DIR/borrowck-union-borrow.rs:28:13
13    |
14 LL |             let ra = &u.a;
15    |                      ---- borrow of `u.a` occurs here
16 LL |             u.a = 1;
17    |             ^^^^^^^ assignment to borrowed `u.a` occurs here
18 LL |             drop(ra);
19    |                  -- borrow later used here
20
21 error[E0502]: cannot borrow `u` (via `u.b`) as mutable because it is also borrowed as immutable (via `u.a`)
22   --> $DIR/borrowck-union-borrow.rs:44:23
23    |
24 LL |             let ra = &u.a;
25    |                      ---- immutable borrow occurs here (via `u.a`)
26 LL |             let rmb = &mut u.b;
27    |                       ^^^^^^^^ mutable borrow of `u.b` -- which overlaps with `u.a` -- occurs here
28 LL |             drop(ra);
29    |                  -- immutable borrow later used here
30    |
31    = note: `u.b` is a field of the union `U`, so it overlaps the field `u.a`
32
33 error[E0506]: cannot assign to `u.b` because it is borrowed
34   --> $DIR/borrowck-union-borrow.rs:49:13
35    |
36 LL |             let ra = &u.a;
37    |                      ---- borrow of `u.b` occurs here
38 LL |             u.b = 1;
39    |             ^^^^^^^ assignment to borrowed `u.b` occurs here
40 LL |             drop(ra);
41    |                  -- borrow later used here
42
43 error[E0502]: cannot borrow `u.a` as immutable because it is also borrowed as mutable
44   --> $DIR/borrowck-union-borrow.rs:55:22
45    |
46 LL |             let rma = &mut u.a;
47    |                       -------- mutable borrow occurs here
48 LL |             let ra = &u.a;
49    |                      ^^^^ immutable borrow occurs here
50 LL |             drop(rma);
51    |                  --- mutable borrow later used here
52
53 error[E0503]: cannot use `u.a` because it was mutably borrowed
54   --> $DIR/borrowck-union-borrow.rs:60:21
55    |
56 LL |             let ra = &mut u.a;
57    |                      -------- borrow of `u.a` occurs here
58 LL |             let a = u.a;
59    |                     ^^^ use of borrowed `u.a`
60 LL |             drop(ra);
61    |                  -- borrow later used here
62
63 error[E0499]: cannot borrow `u.a` as mutable more than once at a time
64   --> $DIR/borrowck-union-borrow.rs:65:24
65    |
66 LL |             let rma = &mut u.a;
67    |                       -------- first mutable borrow occurs here
68 LL |             let rma2 = &mut u.a;
69    |                        ^^^^^^^^ second mutable borrow occurs here
70 LL |             drop(rma);
71    |                  --- first borrow later used here
72
73 error[E0506]: cannot assign to `u.a` because it is borrowed
74   --> $DIR/borrowck-union-borrow.rs:70:13
75    |
76 LL |             let rma = &mut u.a;
77    |                       -------- borrow of `u.a` occurs here
78 LL |             u.a = 1;
79    |             ^^^^^^^ assignment to borrowed `u.a` occurs here
80 LL |             drop(rma);
81    |                  --- borrow later used here
82
83 error[E0502]: cannot borrow `u` (via `u.b`) as immutable because it is also borrowed as mutable (via `u.a`)
84   --> $DIR/borrowck-union-borrow.rs:76:22
85    |
86 LL |             let rma = &mut u.a;
87    |                       -------- mutable borrow occurs here (via `u.a`)
88 LL |             let rb = &u.b;
89    |                      ^^^^ immutable borrow of `u.b` -- which overlaps with `u.a` -- occurs here
90 LL |             drop(rma);
91    |                  --- mutable borrow later used here
92    |
93    = note: `u.b` is a field of the union `U`, so it overlaps the field `u.a`
94
95 error[E0503]: cannot use `u.b` because it was mutably borrowed
96   --> $DIR/borrowck-union-borrow.rs:81:21
97    |
98 LL |             let ra = &mut u.a;
99    |                      -------- borrow of `u.a` occurs here
100 LL |             let b = u.b;
101    |                     ^^^ use of borrowed `u.a`
102 LL |
103 LL |             drop(ra);
104    |                  -- borrow later used here
105
106 error[E0499]: cannot borrow `u` (via `u.b`) as mutable more than once at a time
107   --> $DIR/borrowck-union-borrow.rs:87:24
108    |
109 LL |             let rma = &mut u.a;
110    |                       -------- first mutable borrow occurs here (via `u.a`)
111 LL |             let rmb2 = &mut u.b;
112    |                        ^^^^^^^^ second mutable borrow occurs here (via `u.b`)
113 LL |             drop(rma);
114    |                  --- first borrow later used here
115    |
116    = note: `u.b` is a field of the union `U`, so it overlaps the field `u.a`
117
118 error[E0506]: cannot assign to `u.b` because it is borrowed
119   --> $DIR/borrowck-union-borrow.rs:92:13
120    |
121 LL |             let rma = &mut u.a;
122    |                       -------- borrow of `u.b` occurs here
123 LL |             u.b = 1;
124    |             ^^^^^^^ assignment to borrowed `u.b` occurs here
125 LL |             drop(rma);
126    |                  --- borrow later used here
127
128 error: aborting due to 12 previous errors
129
130 Some errors have detailed explanations: E0499, E0502, E0503, E0506.
131 For more information about an error, try `rustc --explain E0499`.