2018-08-08 12:28:26 +00:00
|
|
|
error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time
|
2019-04-22 07:40:08 +00:00
|
|
|
--> $DIR/borrowck-reborrow-from-mut.rs:13:17
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let _bar1 = &mut foo.bar1;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ------------- first mutable borrow occurs here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let _bar2 = &mut foo.bar1;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ^^^^^^^^^^^^^ second mutable borrow occurs here
|
2018-11-05 13:05:23 +00:00
|
|
|
LL | use_mut(_bar1);
|
2019-04-22 07:40:08 +00:00
|
|
|
| ----- first borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable
|
2019-04-22 07:40:08 +00:00
|
|
|
--> $DIR/borrowck-reborrow-from-mut.rs:18:17
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let _bar1 = &mut foo.bar1;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ------------- mutable borrow occurs here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let _bar2 = &foo.bar1;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ^^^^^^^^^ immutable borrow occurs here
|
2018-11-05 13:05:23 +00:00
|
|
|
LL | use_mut(_bar1);
|
2019-04-22 07:40:08 +00:00
|
|
|
| ----- mutable borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable
|
2019-04-22 07:40:08 +00:00
|
|
|
--> $DIR/borrowck-reborrow-from-mut.rs:23:17
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let _bar1 = &foo.bar1;
|
2019-04-22 07:40:08 +00:00
|
|
|
| --------- immutable borrow occurs here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let _bar2 = &mut foo.bar1;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ^^^^^^^^^^^^^ mutable borrow occurs here
|
2018-11-05 13:05:23 +00:00
|
|
|
LL | use_imm(_bar1);
|
2019-04-22 07:40:08 +00:00
|
|
|
| ----- immutable borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time
|
2018-12-25 15:56:47 +00:00
|
|
|
--> $DIR/borrowck-reborrow-from-mut.rs:45:21
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let _bar1 = &mut foo.bar1;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ------------- first mutable borrow occurs here
|
2018-08-08 12:28:26 +00:00
|
|
|
LL | match *foo {
|
|
|
|
LL | Foo { bar1: ref mut _bar1, bar2: _ } => {}
|
|
|
|
| ^^^^^^^^^^^^^ second mutable borrow occurs here
|
|
|
|
...
|
2019-04-22 07:40:08 +00:00
|
|
|
LL | use_mut(_bar1);
|
|
|
|
| ----- first borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
2019-04-22 07:40:08 +00:00
|
|
|
error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable
|
|
|
|
--> $DIR/borrowck-reborrow-from-mut.rs:52:17
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let _bar1 = &mut foo.bar1.int1;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ------------------ mutable borrow occurs here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let _foo1 = &foo.bar1;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ^^^^^^^^^ immutable borrow occurs here
|
|
|
|
LL | let _foo2 = &*foo;
|
|
|
|
LL | use_mut(_bar1);
|
|
|
|
| ----- mutable borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
2019-04-22 07:40:08 +00:00
|
|
|
error[E0502]: cannot borrow `*foo` as immutable because it is also borrowed as mutable
|
|
|
|
--> $DIR/borrowck-reborrow-from-mut.rs:53:17
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let _bar1 = &mut foo.bar1.int1;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ------------------ mutable borrow occurs here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let _foo1 = &foo.bar1;
|
|
|
|
LL | let _foo2 = &*foo;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ^^^^^ immutable borrow occurs here
|
2018-11-05 13:05:23 +00:00
|
|
|
LL | use_mut(_bar1);
|
2019-04-22 07:40:08 +00:00
|
|
|
| ----- mutable borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time
|
2019-04-22 07:40:08 +00:00
|
|
|
--> $DIR/borrowck-reborrow-from-mut.rs:58:17
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let _bar1 = &mut foo.bar1.int1;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ------------------ first mutable borrow occurs here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let _foo1 = &mut foo.bar1;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ^^^^^^^^^^^^^ second mutable borrow occurs here
|
2018-11-05 13:05:23 +00:00
|
|
|
LL | use_mut(_bar1);
|
2019-04-22 07:40:08 +00:00
|
|
|
| ----- first borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
error[E0499]: cannot borrow `*foo` as mutable more than once at a time
|
2019-04-22 07:40:08 +00:00
|
|
|
--> $DIR/borrowck-reborrow-from-mut.rs:63:17
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let _bar1 = &mut foo.bar1.int1;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ------------------ first mutable borrow occurs here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let _foo2 = &mut *foo;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ^^^^^^^^^ second mutable borrow occurs here
|
2018-11-05 13:05:23 +00:00
|
|
|
LL | use_mut(_bar1);
|
2019-04-22 07:40:08 +00:00
|
|
|
| ----- first borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
2019-04-22 07:40:08 +00:00
|
|
|
error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable
|
|
|
|
--> $DIR/borrowck-reborrow-from-mut.rs:68:17
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let _bar1 = &foo.bar1.int1;
|
2019-04-22 07:40:08 +00:00
|
|
|
| -------------- immutable borrow occurs here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let _foo1 = &mut foo.bar1;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ^^^^^^^^^^^^^ mutable borrow occurs here
|
2018-11-05 13:05:23 +00:00
|
|
|
LL | use_imm(_bar1);
|
2019-04-22 07:40:08 +00:00
|
|
|
| ----- immutable borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
2019-04-22 07:40:08 +00:00
|
|
|
error[E0502]: cannot borrow `*foo` as mutable because it is also borrowed as immutable
|
|
|
|
--> $DIR/borrowck-reborrow-from-mut.rs:73:17
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
|
LL | let _bar1 = &foo.bar1.int1;
|
2019-04-22 07:40:08 +00:00
|
|
|
| -------------- immutable borrow occurs here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let _foo2 = &mut *foo;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ^^^^^^^^^ mutable borrow occurs here
|
2018-11-05 13:05:23 +00:00
|
|
|
LL | use_imm(_bar1);
|
2019-04-22 07:40:08 +00:00
|
|
|
| ----- immutable borrow later used here
|
2018-08-08 12:28:26 +00:00
|
|
|
|
2019-04-22 07:40:08 +00:00
|
|
|
error[E0596]: cannot borrow `foo.bar1` as mutable, as it is behind a `&` reference
|
|
|
|
--> $DIR/borrowck-reborrow-from-mut.rs:88:17
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let _bar1 = &mut foo.bar1;
|
2019-04-22 07:40:08 +00:00
|
|
|
| ^^^^^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be borrowed as mutable
|
2022-12-29 05:52:57 +00:00
|
|
|
|
|
|
|
|
help: consider changing this to be a mutable reference
|
|
|
|
|
|
|
|
|
LL | fn borrow_mut_from_imm(foo: &mut Foo) {
|
2023-04-19 07:50:08 +00:00
|
|
|
| +++
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
|
|
error: aborting due to 11 previous errors
|
|
|
|
|
2019-04-17 17:26:38 +00:00
|
|
|
Some errors have detailed explanations: E0499, E0502, E0596.
|
2018-08-08 12:28:26 +00:00
|
|
|
For more information about an error, try `rustc --explain E0499`.
|