1 // Test that we are able to infer a suitable kind for this closure
2 // that is just called (`FnMut`).
3
main()4 fn main() {
5 let mut counter = 0;
6
7 // Here this must be inferred to FnMut so that it can mutate counter,
8 // but we forgot the mut.
9 let tick1 = || {
10 counter += 1;
11 };
12
13 // In turn, tick2 must be inferred to FnMut so that it can call
14 // tick1, but we forgot the mut.
15 let tick2 = || {
16 tick1(); //~ ERROR cannot borrow `tick1` as mutable
17 };
18
19 tick2(); //~ ERROR cannot borrow
20 }
21