rust/src/test/ui/borrowck/borrowck-union-borrow.stderr

132 lines
5.2 KiB
Plaintext
Raw Normal View History

2018-08-08 07:28:26 -05:00
error[E0502]: cannot borrow `u.a` as mutable because it is also borrowed as immutable
--> $DIR/borrowck-union-borrow.rs:25:23
2018-08-08 07:28:26 -05:00
|
LL | let ra = &u.a;
| ---- immutable borrow occurs here
2019-03-09 06:03:44 -06:00
LL | let rma = &mut u.a;
| ^^^^^^^^ mutable borrow occurs here
LL | drop(ra);
| -- immutable borrow later used here
2018-08-08 07:28:26 -05:00
error[E0506]: cannot assign to `u.a` because it is borrowed
--> $DIR/borrowck-union-borrow.rs:30:13
2018-08-08 07:28:26 -05:00
|
LL | let ra = &u.a;
| ---- borrow of `u.a` occurs here
2019-03-09 06:03:44 -06:00
LL | u.a = 1;
2018-08-08 07:28:26 -05:00
| ^^^^^^^ assignment to borrowed `u.a` occurs here
LL | drop(ra);
| -- borrow later used here
2018-08-08 07:28:26 -05:00
error[E0502]: cannot borrow `u` (via `u.b`) as mutable because it is also borrowed as immutable (via `u.a`)
--> $DIR/borrowck-union-borrow.rs:46:23
2018-08-08 07:28:26 -05:00
|
LL | let ra = &u.a;
| ---- immutable borrow occurs here (via `u.a`)
2019-03-09 06:03:44 -06:00
LL | let rmb = &mut u.b;
| ^^^^^^^^ mutable borrow of `u.b` -- which overlaps with `u.a` -- occurs here
LL | drop(ra);
| -- 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 07:28:26 -05:00
error[E0506]: cannot assign to `u.b` because it is borrowed
--> $DIR/borrowck-union-borrow.rs:51:13
2018-08-08 07:28:26 -05:00
|
LL | let ra = &u.a;
| ---- borrow of `u.b` occurs here
2019-03-09 06:03:44 -06:00
LL | u.b = 1;
2018-08-08 07:28:26 -05:00
| ^^^^^^^ assignment to borrowed `u.b` occurs here
LL | drop(ra);
| -- borrow later used here
2018-08-08 07:28:26 -05:00
error[E0502]: cannot borrow `u.a` as immutable because it is also borrowed as mutable
--> $DIR/borrowck-union-borrow.rs:57:22
2018-08-08 07:28:26 -05:00
|
LL | let rma = &mut u.a;
| -------- mutable borrow occurs here
2019-03-09 06:03:44 -06:00
LL | let ra = &u.a;
| ^^^^ immutable borrow occurs here
LL | drop(rma);
| --- mutable borrow later used here
2018-08-08 07:28:26 -05:00
error[E0503]: cannot use `u.a` because it was mutably borrowed
--> $DIR/borrowck-union-borrow.rs:62:21
2018-08-08 07:28:26 -05:00
|
LL | let ra = &mut u.a;
| -------- borrow of `u.a` occurs here
2019-03-09 06:03:44 -06:00
LL | let a = u.a;
| ^^^ use of borrowed `u.a`
LL | drop(ra);
| -- borrow later used here
2018-08-08 07:28:26 -05:00
error[E0499]: cannot borrow `u.a` as mutable more than once at a time
--> $DIR/borrowck-union-borrow.rs:67:24
2018-08-08 07:28:26 -05:00
|
LL | let rma = &mut u.a;
| -------- first mutable borrow occurs here
2019-03-09 06:03:44 -06:00
LL | let rma2 = &mut u.a;
| ^^^^^^^^ second mutable borrow occurs here
LL | drop(rma);
| --- first borrow later used here
2018-08-08 07:28:26 -05:00
error[E0506]: cannot assign to `u.a` because it is borrowed
--> $DIR/borrowck-union-borrow.rs:72:13
2018-08-08 07:28:26 -05:00
|
LL | let rma = &mut u.a;
| -------- borrow of `u.a` occurs here
2019-03-09 06:03:44 -06:00
LL | u.a = 1;
2018-08-08 07:28:26 -05:00
| ^^^^^^^ assignment to borrowed `u.a` occurs here
LL | drop(rma);
| --- borrow later used here
2018-08-08 07:28:26 -05:00
error[E0502]: cannot borrow `u` (via `u.b`) as immutable because it is also borrowed as mutable (via `u.a`)
--> $DIR/borrowck-union-borrow.rs:78:22
2018-08-08 07:28:26 -05:00
|
LL | let rma = &mut u.a;
| -------- mutable borrow occurs here (via `u.a`)
2019-03-09 06:03:44 -06:00
LL | let rb = &u.b;
| ^^^^ immutable borrow of `u.b` -- which overlaps with `u.a` -- occurs here
LL | drop(rma);
| --- 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 07:28:26 -05:00
error[E0503]: cannot use `u.b` because it was mutably borrowed
--> $DIR/borrowck-union-borrow.rs:83:21
2018-08-08 07:28:26 -05:00
|
LL | let ra = &mut u.a;
| -------- borrow of `u.a` occurs here
2019-03-09 06:03:44 -06:00
LL | let b = u.b;
| ^^^ use of borrowed `u.a`
LL |
LL | drop(ra);
| -- borrow later used here
2018-08-08 07:28:26 -05:00
error[E0499]: cannot borrow `u` (via `u.b`) as mutable more than once at a time
--> $DIR/borrowck-union-borrow.rs:89:24
2018-08-08 07:28:26 -05:00
|
LL | let rma = &mut u.a;
| -------- first mutable borrow occurs here (via `u.a`)
2019-03-09 06:03:44 -06:00
LL | let rmb2 = &mut u.b;
| ^^^^^^^^ second mutable borrow occurs here (via `u.b`)
LL | drop(rma);
| --- 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 07:28:26 -05:00
error[E0506]: cannot assign to `u.b` because it is borrowed
--> $DIR/borrowck-union-borrow.rs:94:13
2018-08-08 07:28:26 -05:00
|
LL | let rma = &mut u.a;
| -------- borrow of `u.b` occurs here
2019-03-09 06:03:44 -06:00
LL | u.b = 1;
2018-08-08 07:28:26 -05:00
| ^^^^^^^ assignment to borrowed `u.b` occurs here
LL | drop(rma);
| --- borrow later used here
2018-08-08 07:28:26 -05:00
error: aborting due to 12 previous errors
Some errors have detailed explanations: E0499, E0502, E0503, E0506.
2018-08-08 07:28:26 -05:00
For more information about an error, try `rustc --explain E0499`.