]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-21600.rs
Consider privacy more carefully when suggesting accessing fields
[rust.git] / src / test / ui / issues / issue-21600.rs
1 fn call_it<F>(f: F) where F: Fn() { f(); }
2
3 struct A;
4
5 impl A {
6     fn gen(&self) {}
7     fn gen_mut(&mut self) {}
8 }
9
10 fn main() {
11     let mut x = A;
12     call_it(|| {
13         call_it(|| x.gen());
14         call_it(|| x.gen_mut());
15         //~^ ERROR cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
16         //~| ERROR cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
17     });
18 }