2023-04-07 12:23:03 -05:00
|
|
|
error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable
|
2023-04-19 13:19:55 -05:00
|
|
|
--> $DIR/issue-109271-pass-self-into-closure.rs:19:5
|
2023-04-07 12:23:03 -05:00
|
|
|
|
|
|
|
|
LL | v.call(|(), this: &mut S| v.get());
|
|
|
|
| ^^----^------------------^-^^^^^^^
|
|
|
|
| | | | |
|
|
|
|
| | | | first borrow occurs due to use of `v` in closure
|
2023-04-19 13:19:55 -05:00
|
|
|
| | | | help: try using the closure argument: `this`
|
2023-04-07 12:23:03 -05:00
|
|
|
| | | immutable borrow occurs here
|
|
|
|
| | immutable borrow later used by call
|
|
|
|
| mutable borrow occurs here
|
|
|
|
|
|
|
|
error[E0499]: cannot borrow `v` as mutable more than once at a time
|
2023-04-19 13:19:55 -05:00
|
|
|
--> $DIR/issue-109271-pass-self-into-closure.rs:21:5
|
2023-04-07 12:23:03 -05:00
|
|
|
|
|
|
|
|
LL | v.call(|(), this: &mut S| v.set());
|
|
|
|
| ^^----^------------------^-^^^^^^^
|
|
|
|
| | | | |
|
|
|
|
| | | | first borrow occurs due to use of `v` in closure
|
2023-04-19 13:19:55 -05:00
|
|
|
| | | | help: try using the closure argument: `this`
|
2023-04-07 12:23:03 -05:00
|
|
|
| | | first mutable borrow occurs here
|
|
|
|
| | first borrow later used by call
|
|
|
|
| second mutable borrow occurs here
|
|
|
|
|
|
|
|
error[E0499]: cannot borrow `v` as mutable more than once at a time
|
2023-04-19 13:19:55 -05:00
|
|
|
--> $DIR/issue-109271-pass-self-into-closure.rs:21:12
|
2023-04-07 12:23:03 -05:00
|
|
|
|
|
|
|
|
LL | v.call(|(), this: &mut S| v.set());
|
2023-06-22 15:30:23 -05:00
|
|
|
| - ---- ^^^^^^^^^^^^^^^^^^ - second borrow occurs due to use of `v` in closure
|
|
|
|
| | | |
|
2023-04-07 12:23:03 -05:00
|
|
|
| | | second mutable borrow occurs here
|
|
|
|
| | first borrow later used by call
|
|
|
|
| first mutable borrow occurs here
|
|
|
|
|
|
|
|
error[E0499]: cannot borrow `v` as mutable more than once at a time
|
2023-04-19 13:19:55 -05:00
|
|
|
--> $DIR/issue-109271-pass-self-into-closure.rs:25:5
|
2023-04-07 12:23:03 -05:00
|
|
|
|
|
|
|
|
LL | v.call(|(), this: &mut S| {
|
|
|
|
| ^ ---- ------------------ first mutable borrow occurs here
|
|
|
|
| | |
|
|
|
|
| _____| first borrow later used by call
|
|
|
|
| |
|
|
|
|
LL | |
|
|
|
|
LL | |
|
2024-03-05 10:24:30 -06:00
|
|
|
... |
|
2023-04-07 12:23:03 -05:00
|
|
|
LL | | v.set();
|
|
|
|
| | - first borrow occurs due to use of `v` in closure
|
|
|
|
... |
|
|
|
|
LL | | _ = v.add(3);
|
|
|
|
LL | | });
|
|
|
|
| |______^ second mutable borrow occurs here
|
2023-04-19 13:19:55 -05:00
|
|
|
|
|
|
|
|
help: try using the closure argument
|
|
|
|
|
|
|
|
|
LL ~ _ = this;
|
|
|
|
LL ~ this.set();
|
|
|
|
LL ~ this.get();
|
|
|
|
LL ~ S::get(&this);
|
|
|
|
|
|
2023-04-07 12:23:03 -05:00
|
|
|
|
|
|
|
error[E0499]: cannot borrow `v` as mutable more than once at a time
|
2023-04-19 13:19:55 -05:00
|
|
|
--> $DIR/issue-109271-pass-self-into-closure.rs:25:12
|
2023-04-07 12:23:03 -05:00
|
|
|
|
|
2023-06-22 15:30:23 -05:00
|
|
|
LL | v.call(|(), this: &mut S| {
|
|
|
|
| - ---- ^^^^^^^^^^^^^^^^^^ second mutable borrow occurs here
|
|
|
|
| | |
|
|
|
|
| | first borrow later used by call
|
|
|
|
| first mutable borrow occurs here
|
|
|
|
...
|
|
|
|
LL | v.set();
|
|
|
|
| - second borrow occurs due to use of `v` in closure
|
2023-04-07 12:23:03 -05:00
|
|
|
|
|
|
|
error: aborting due to 5 previous errors
|
|
|
|
|
|
|
|
Some errors have detailed explanations: E0499, E0502.
|
|
|
|
For more information about an error, try `rustc --explain E0499`.
|