fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #71365 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum4fb7144ed15

1.43.0
1.1 KiB34 linesraw
1error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
2  --> $DIR/issue-21600.rs:14:20
3   |
4LL | fn call_it<F>(f: F) where F: Fn() { f(); }
5   |                  - change this to accept `FnMut` instead of `Fn`
6...
7LL |         call_it(|| x.gen_mut());
8   |         -------    ^ cannot borrow as mutable
9   |         |
10   |         expects `Fn` instead of `FnMut`
11
12error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure
13  --> $DIR/issue-21600.rs:14:17
14   |
15LL |   fn call_it<F>(f: F) where F: Fn() { f(); }
16   |                    - change this to accept `FnMut` instead of `Fn`
17...
18LL |       call_it(|| {
19   |  _____-------_-
20   | |     |
21   | |     expects `Fn` instead of `FnMut`
22LL | |         call_it(|| x.gen());
23LL | |         call_it(|| x.gen_mut());
24   | |                 ^^ - mutable borrow occurs due to use of `x` in closure
25   | |                 |
26   | |                 cannot borrow as mutable
27LL | |
28LL | |
29LL | |     });
30   | |_____- in this closure
31
32error: aborting due to 2 previous errors
33
34For more information about this error, try `rustc --explain E0596`.