]> git.lizzy.rs Git - rust.git/blob - tests/ui/suggestions/issue-105761-suggest-self-for-closure.stderr
Merge commit '598f0909568a51de8a2d1148f55a644fd8dffad0' into sync_cg_clif-2023-01-24
[rust.git] / tests / ui / suggestions / issue-105761-suggest-self-for-closure.stderr
1 error[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    |
4 LL |         let x = |v: i32| {
5    |                 -------- immutable borrow occurs here
6 LL |             self.bar();
7    |             ---- first borrow occurs due to use of `self` in closure
8 ...
9 LL |         self.qux();
10    |         ^^^^^^^^^^ mutable borrow occurs here
11 LL |         x(1);
12    |         - immutable borrow later used here
13    |
14 help: try explicitly pass `&Self` into the Closure as an argument
15    |
16 LL ~         let x = |this: &Self, v: i32| {
17 LL ~             this.bar();
18 LL ~             this.hel();
19 LL |         };
20 LL |         self.qux();
21 LL ~         x(self, 1);
22 LL ~         x(self, 3);
23    |
24
25 error[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    |
28 LL |         let y = || {
29    |                 -- immutable borrow occurs here
30 LL |             self.bar();
31    |             ---- first borrow occurs due to use of `self` in closure
32 LL |         };
33 LL |         self.qux();
34    |         ^^^^^^^^^^ mutable borrow occurs here
35 LL |         y();
36    |         - immutable borrow later used here
37    |
38 help: try explicitly pass `&Self` into the Closure as an argument
39    |
40 LL ~         let y = |this: &Self| {
41 LL ~             this.bar();
42 LL |         };
43 LL |         self.qux();
44 LL ~         y(self);
45    |
46
47 error: aborting due to 2 previous errors
48
49 For more information about this error, try `rustc --explain E0502`.