2018-08-08 12:28:26 +00:00
|
|
|
error[E0502]: cannot borrow `u.a` as mutable because it is also borrowed as immutable
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-union-borrow.rs:23:23
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let ra = &u.a;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ---- immutable borrow occurs here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let rma = &mut u.a;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ^^^^^^^^ mutable borrow occurs here
|
2018-12-24 19:22:25 +00:00
|
|
|
LL | drop(ra);
|
2019-04-22 07:40:08 +00:00
|
|
|
| -- immutable borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
error[E0506]: cannot assign to `u.a` because it is borrowed
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-union-borrow.rs:28:13
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let ra = &u.a;
|
2023-01-15 03:06:44 +00:00
|
|
|
| ---- `u.a` is borrowed here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | u.a = 1;
|
2023-01-15 03:06:44 +00:00
|
|
|
| ^^^^^^^ `u.a` is assigned to here but it was already borrowed
|
2019-04-22 07:40:08 +00:00
|
|
|
LL | drop(ra);
|
|
|
|
| -- borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
2019-04-22 07:40:08 +00:00
|
|
|
error[E0502]: cannot borrow `u` (via `u.b`) as mutable because it is also borrowed as immutable (via `u.a`)
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-union-borrow.rs:44:23
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let ra = &u.a;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ---- immutable borrow occurs here (via `u.a`)
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let rmb = &mut u.b;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ^^^^^^^^ mutable borrow of `u.b` -- which overlaps with `u.a` -- occurs here
|
2018-12-24 19:22:25 +00:00
|
|
|
LL | drop(ra);
|
2019-04-22 07:40:08 +00:00
|
|
|
| -- immutable borrow later used here
|
|
|
|
|
|
|
|
|
= note: `u.b` is a field of the union `U`, so it overlaps the field `u.a`
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
error[E0506]: cannot assign to `u.b` because it is borrowed
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-union-borrow.rs:49:13
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let ra = &u.a;
|
2023-01-15 03:06:44 +00:00
|
|
|
| ---- `u.b` is borrowed here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | u.b = 1;
|
2023-01-15 03:06:44 +00:00
|
|
|
| ^^^^^^^ `u.b` is assigned to here but it was already borrowed
|
2019-04-22 07:40:08 +00:00
|
|
|
LL | drop(ra);
|
|
|
|
| -- borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
error[E0502]: cannot borrow `u.a` as immutable because it is also borrowed as mutable
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-union-borrow.rs:55:22
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let rma = &mut u.a;
|
2019-04-22 07:40:08 +00:00
|
|
|
| -------- mutable borrow occurs here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let ra = &u.a;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ^^^^ immutable borrow occurs here
|
2018-12-24 19:22:25 +00:00
|
|
|
LL | drop(rma);
|
2019-04-22 07:40:08 +00:00
|
|
|
| --- mutable borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
error[E0503]: cannot use `u.a` because it was mutably borrowed
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-union-borrow.rs:60:21
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let ra = &mut u.a;
|
2023-01-15 03:06:44 +00:00
|
|
|
| -------- `u.a` is borrowed here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let a = u.a;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ^^^ use of borrowed `u.a`
|
|
|
|
LL | drop(ra);
|
|
|
|
| -- borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
error[E0499]: cannot borrow `u.a` as mutable more than once at a time
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-union-borrow.rs:65:24
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let rma = &mut u.a;
|
2019-04-22 07:40:08 +00:00
|
|
|
| -------- first mutable borrow occurs here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let rma2 = &mut u.a;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ^^^^^^^^ second mutable borrow occurs here
|
2018-12-24 19:22:25 +00:00
|
|
|
LL | drop(rma);
|
2019-04-22 07:40:08 +00:00
|
|
|
| --- first borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
error[E0506]: cannot assign to `u.a` because it is borrowed
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-union-borrow.rs:70:13
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let rma = &mut u.a;
|
2023-01-15 03:06:44 +00:00
|
|
|
| -------- `u.a` is borrowed here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | u.a = 1;
|
2023-01-15 03:06:44 +00:00
|
|
|
| ^^^^^^^ `u.a` is assigned to here but it was already borrowed
|
2019-04-22 07:40:08 +00:00
|
|
|
LL | drop(rma);
|
|
|
|
| --- borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
2019-04-22 07:40:08 +00:00
|
|
|
error[E0502]: cannot borrow `u` (via `u.b`) as immutable because it is also borrowed as mutable (via `u.a`)
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-union-borrow.rs:76:22
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let rma = &mut u.a;
|
2019-04-22 07:40:08 +00:00
|
|
|
| -------- mutable borrow occurs here (via `u.a`)
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let rb = &u.b;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ^^^^ immutable borrow of `u.b` -- which overlaps with `u.a` -- occurs here
|
2018-12-24 19:22:25 +00:00
|
|
|
LL | drop(rma);
|
2019-04-22 07:40:08 +00:00
|
|
|
| --- mutable borrow later used here
|
|
|
|
|
|
|
|
|
= note: `u.b` is a field of the union `U`, so it overlaps the field `u.a`
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
error[E0503]: cannot use `u.b` because it was mutably borrowed
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-union-borrow.rs:81:21
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let ra = &mut u.a;
|
2023-01-15 03:06:44 +00:00
|
|
|
| -------- `u.a` is borrowed here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let b = u.b;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ^^^ use of borrowed `u.a`
|
2022-06-08 18:07:59 +00:00
|
|
|
LL |
|
2019-04-22 07:40:08 +00:00
|
|
|
LL | drop(ra);
|
|
|
|
| -- borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
error[E0499]: cannot borrow `u` (via `u.b`) as mutable more than once at a time
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-union-borrow.rs:87:24
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let rma = &mut u.a;
|
2019-04-22 07:40:08 +00:00
|
|
|
| -------- first mutable borrow occurs here (via `u.a`)
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let rmb2 = &mut u.b;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ^^^^^^^^ second mutable borrow occurs here (via `u.b`)
|
2018-12-24 19:22:25 +00:00
|
|
|
LL | drop(rma);
|
2019-04-22 07:40:08 +00:00
|
|
|
| --- first borrow later used here
|
|
|
|
|
|
|
|
|
= note: `u.b` is a field of the union `U`, so it overlaps the field `u.a`
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
error[E0506]: cannot assign to `u.b` because it is borrowed
|
2021-04-03 11:05:11 +00:00
|
|
|
--> $DIR/borrowck-union-borrow.rs:92:13
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let rma = &mut u.a;
|
2023-01-15 03:06:44 +00:00
|
|
|
| -------- `u.b` is borrowed here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | u.b = 1;
|
2023-01-15 03:06:44 +00:00
|
|
|
| ^^^^^^^ `u.b` is assigned to here but it was already borrowed
|
2019-04-22 07:40:08 +00:00
|
|
|
LL | drop(rma);
|
|
|
|
| --- borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
error: aborting due to 12 previous errors
|
|
|
|
|
2019-04-17 17:26:38 +00:00
|
|
|
Some errors have detailed explanations: E0499, E0502, E0503, E0506.
|
2018-08-08 12:28:26 +00:00
|
|
|
For more information about an error, try `rustc --explain E0499`.
|