rust/tests/ui/borrowck/issue-109271-pass-self-into-closure.stderr

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

77 lines
2.7 KiB
Plaintext
Raw Permalink Normal View History

2023-04-07 12:23:03 -05:00
error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable
--> $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
| | | | 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
--> $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
| | | | 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
--> $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());
| - ---- ^^^^^^^^^^^^^^^^^^ - 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
--> $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 | |
... |
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
|
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
--> $DIR/issue-109271-pass-self-into-closure.rs:25:12
2023-04-07 12:23:03 -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`.