rust/src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr

30 lines
1.1 KiB
Plaintext
Raw Normal View History

2018-08-08 07:28:26 -05:00
error[E0389]: cannot assign to data in a `&` reference
2018-12-25 09:56:47 -06:00
--> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:9:5
2018-08-08 07:28:26 -05:00
|
LL | **t1 = 22; //~ ERROR cannot assign
| ^^^^^^^^^ assignment into an immutable reference
error[E0502]: cannot borrow `**t0` as immutable because `*t0` is also borrowed as mutable
2018-12-25 09:56:47 -06:00
--> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:14:22
2018-08-08 07:28:26 -05:00
|
LL | let t1 = &mut *t0;
| --- mutable borrow occurs here
LL | let p: &isize = &**t0; //~ ERROR cannot borrow
| ^^^^ immutable borrow occurs here
LL | **t1 = 22;
LL | }
| - mutable borrow ends here
error[E0389]: cannot borrow data mutably in a `&` reference
2018-12-25 09:56:47 -06:00
--> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:19:31
2018-08-08 07:28:26 -05:00
|
LL | fn foo4(t0: & &mut isize) {
| ------------ use `&mut &mut isize` here to make mutable
LL | let x: &mut isize = &mut **t0; //~ ERROR cannot borrow
| ^^^^ assignment into an immutable reference
error: aborting due to 3 previous errors
Some errors occurred: E0389, E0502.
For more information about an error, try `rustc --explain E0389`.