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