about summary refs log tree commit diff
path: root/tests/ui/suggestions/issue-105761-suggest-self-for-closure.rs
blob: 90d5f3c5c5f174b6fd78bb463ab86c668e51b064 (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
//@run-rustfix
#![allow(unused)]

struct S;
impl S {
    fn foo(&mut self) {
        let x = |v: i32| {
            self.bar();
            self.hel();
        };
        self.qux(); //~ ERROR cannot borrow `*self` as mutable because it is also borrowed as immutable
        x(1);
        x(3);
    }
    fn bar(&self) {}
    fn hel(&self) {}
    fn qux(&mut self) {}

    fn hello(&mut self) {
        let y = || {
            self.bar();
        };
        self.qux(); //~ ERROR cannot borrow `*self` as mutable because it is also borrowed as immutable
        y();
    }
}

fn main() {}