fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
1.5 KiB49 linesraw
1error[E0502]: cannot borrow `*self` as mutable because it is also borrowed as immutable
2  --> $DIR/issue-105761-suggest-self-for-closure.rs:11:9
3   |
4LL |         let x = |v: i32| {
5   |                 -------- immutable borrow occurs here
6LL |             self.bar();
7   |             ---- first borrow occurs due to use of `self` in closure
8...
9LL |         self.qux();
10   |         ^^^^^^^^^^ mutable borrow occurs here
11LL |         x(1);
12   |         - immutable borrow later used here
13   |
14help: try explicitly pass `&Self` into the Closure as an argument
15   |
16LL ~         let x = |this: &Self, v: i32| {
17LL ~             this.bar();
18LL ~             this.hel();
19LL |         };
20LL |         self.qux();
21LL ~         x(self, 1);
22LL ~         x(self, 3);
23   |
24
25error[E0502]: cannot borrow `*self` as mutable because it is also borrowed as immutable
26  --> $DIR/issue-105761-suggest-self-for-closure.rs:23:9
27   |
28LL |         let y = || {
29   |                 -- immutable borrow occurs here
30LL |             self.bar();
31   |             ---- first borrow occurs due to use of `self` in closure
32LL |         };
33LL |         self.qux();
34   |         ^^^^^^^^^^ mutable borrow occurs here
35LL |         y();
36   |         - immutable borrow later used here
37   |
38help: try explicitly pass `&Self` into the Closure as an argument
39   |
40LL ~         let y = |this: &Self| {
41LL ~             this.bar();
42LL |         };
43LL |         self.qux();
44LL ~         y(self);
45   |
46
47error: aborting due to 2 previous errors
48
49For more information about this error, try `rustc --explain E0502`.