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

error[E0502]: cannot borrow `*self` as mutable because it is also borrowed as immutable
  --> $DIR/issue-105761-suggest-self-for-closure.rs:23:9
   |
LL |         let y = || {
   |                 -- immutable borrow occurs here
LL |             self.bar();
   |             ---- first borrow occurs due to use of `self` in closure
LL |         };
LL |         self.qux();
   |         ^^^^^^^^^^ mutable borrow occurs here
LL |         y();
   |         - immutable borrow later used here
   |
help: try explicitly pass `&Self` into the Closure as an argument
   |
LL ~         let y = |this: &Self| {
LL ~             this.bar();
LL |         };
LL |         self.qux();
LL ~         y(self);
   |

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0502`.