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