2019-04-22 02:40:08 -05:00
|
|
|
error[E0502]: cannot borrow `t0` as mutable because it is also borrowed as immutable
|
|
|
|
--> $DIR/borrowck-mut-borrow-of-mut-base-ptr.rs:11:18
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
|
LL | let p: &isize = &*t0; // Freezes `*t0`
|
2019-04-22 02:40:08 -05:00
|
|
|
| ---- immutable borrow occurs here
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | let mut t2 = &mut t0;
|
2019-04-22 02:40:08 -05:00
|
|
|
| ^^^^^^^ mutable borrow occurs here
|
|
|
|
LL | **t2 += 1; // Mutates `*t0`
|
|
|
|
LL | p.use_ref();
|
2023-06-22 15:30:23 -05:00
|
|
|
| - immutable borrow later used here
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
error[E0499]: cannot borrow `t0` as mutable more than once at a time
|
2019-04-22 02:40:08 -05:00
|
|
|
--> $DIR/borrowck-mut-borrow-of-mut-base-ptr.rs:19:18
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
|
LL | let p: &mut isize = &mut *t0; // Claims `*t0`
|
2019-04-22 02:40:08 -05:00
|
|
|
| -------- first mutable borrow occurs here
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | let mut t2 = &mut t0;
|
2019-04-22 02:40:08 -05:00
|
|
|
| ^^^^^^^ second mutable borrow occurs here
|
|
|
|
LL | **t2 += 1; // Mutates `*t0` but not through `*p`
|
|
|
|
LL | p.use_mut();
|
2023-06-22 15:30:23 -05:00
|
|
|
| - first borrow later used here
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
error: aborting due to 2 previous errors
|
|
|
|
|
2019-04-17 12:26:38 -05:00
|
|
|
Some errors have detailed explanations: E0499, E0502.
|
2018-08-08 07:28:26 -05:00
|
|
|
For more information about an error, try `rustc --explain E0499`.
|