]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrowck-mut-borrow-of-mut-base-ptr.stderr
Rollup merge of #106644 - alexcrichton:update-wasi-toolchain, r=cuviper
[rust.git] / tests / ui / borrowck / borrowck-mut-borrow-of-mut-base-ptr.stderr
1 error[E0502]: cannot borrow `t0` as mutable because it is also borrowed as immutable
2   --> $DIR/borrowck-mut-borrow-of-mut-base-ptr.rs:11:18
3    |
4 LL |     let p: &isize = &*t0;     // Freezes `*t0`
5    |                     ---- immutable borrow occurs here
6 LL |     let mut t2 = &mut t0;
7    |                  ^^^^^^^ mutable borrow occurs here
8 LL |     **t2 += 1;              // Mutates `*t0`
9 LL |     p.use_ref();
10    |     ----------- immutable borrow later used here
11
12 error[E0499]: cannot borrow `t0` as mutable more than once at a time
13   --> $DIR/borrowck-mut-borrow-of-mut-base-ptr.rs:19:18
14    |
15 LL |     let p: &mut isize = &mut *t0; // Claims `*t0`
16    |                         -------- first mutable borrow occurs here
17 LL |     let mut t2 = &mut t0;
18    |                  ^^^^^^^ second mutable borrow occurs here
19 LL |     **t2 += 1;                  // Mutates `*t0` but not through `*p`
20 LL |     p.use_mut();
21    |     ----------- first borrow later used here
22
23 error: aborting due to 2 previous errors
24
25 Some errors have detailed explanations: E0499, E0502.
26 For more information about an error, try `rustc --explain E0499`.