]> git.lizzy.rs Git - rust.git/blob - tests/ui/unboxed-closures/unboxed-closures-mutate-upvar.stderr
Rollup merge of #106670 - albertlarsan68:check-docs-in-pr-ci, r=Mark-Simulacrum
[rust.git] / tests / ui / unboxed-closures / unboxed-closures-mutate-upvar.stderr
1 error[E0594]: cannot assign to `n`, as it is not declared as mutable
2   --> $DIR/unboxed-closures-mutate-upvar.rs:15:9
3    |
4 LL |     let n = 0;
5    |         - help: consider changing this to be mutable: `mut n`
6 LL |     let mut f = to_fn_mut(|| {
7 LL |         n += 1;
8    |         ^^^^^^ cannot assign
9
10 error[E0594]: cannot assign to `n`, as it is not declared as mutable
11   --> $DIR/unboxed-closures-mutate-upvar.rs:32:9
12    |
13 LL |     let n = 0;
14    |         - help: consider changing this to be mutable: `mut n`
15 ...
16 LL |         n += 1;
17    |         ^^^^^^ cannot assign
18
19 error[E0594]: cannot assign to `n`, as it is not declared as mutable
20   --> $DIR/unboxed-closures-mutate-upvar.rs:46:9
21    |
22 LL |     let n = 0;
23    |         - help: consider changing this to be mutable: `mut n`
24 LL |     let mut f = to_fn(move || {
25 LL |         n += 1;
26    |         ^^^^^^ cannot assign
27
28 error[E0594]: cannot assign to `n`, as it is a captured variable in a `Fn` closure
29   --> $DIR/unboxed-closures-mutate-upvar.rs:53:9
30    |
31 LL | fn to_fn<A:std::marker::Tuple,F:Fn<A>>(f: F) -> F { f }
32    |                                           - change this to accept `FnMut` instead of `Fn`
33 ...
34 LL |     let mut f = to_fn(move || {
35    |                 ----- ------- in this closure
36    |                 |
37    |                 expects `Fn` instead of `FnMut`
38 LL |         n += 1;
39    |         ^^^^^^ cannot assign
40
41 error: aborting due to 4 previous errors
42
43 For more information about this error, try `rustc --explain E0594`.