rust/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.stderr

54 lines
1.8 KiB
Plaintext
Raw Normal View History

2018-08-08 07:28:26 -05:00
error[E0595]: closure cannot assign to immutable local variable `n`
2018-12-25 09:56:47 -06:00
--> $DIR/unboxed-closures-mutate-upvar.rs:14:27
2018-08-08 07:28:26 -05:00
|
LL | let n = 0;
| - help: make this binding mutable: `mut n`
2018-08-08 07:28:26 -05:00
LL | let mut f = to_fn_mut(|| { //~ ERROR closure cannot assign
| ^^ cannot borrow mutably
error[E0594]: cannot assign to captured outer variable in an `FnMut` closure
2018-12-25 09:56:47 -06:00
--> $DIR/unboxed-closures-mutate-upvar.rs:32:9
2018-08-08 07:28:26 -05:00
|
LL | let n = 0;
| - help: consider making `n` mutable: `mut n`
...
LL | n += 1; //~ ERROR cannot assign
| ^^^^^^
error[E0594]: cannot assign to captured outer variable in an `Fn` closure
2018-12-25 09:56:47 -06:00
--> $DIR/unboxed-closures-mutate-upvar.rs:46:9
2018-08-08 07:28:26 -05:00
|
LL | n += 1; //~ ERROR cannot assign
| ^^^^^^
|
= note: `Fn` closures cannot capture their enclosing environment for modifications
help: consider changing this closure to take self by mutable reference
2018-12-25 09:56:47 -06:00
--> $DIR/unboxed-closures-mutate-upvar.rs:45:23
2018-08-08 07:28:26 -05:00
|
LL | let mut f = to_fn(move || {
| _______________________^
LL | | n += 1; //~ ERROR cannot assign
LL | | });
| |_____^
error[E0594]: cannot assign to captured outer variable in an `Fn` closure
2018-12-25 09:56:47 -06:00
--> $DIR/unboxed-closures-mutate-upvar.rs:53:9
2018-08-08 07:28:26 -05:00
|
LL | n += 1; //~ ERROR cannot assign
| ^^^^^^
|
= note: `Fn` closures cannot capture their enclosing environment for modifications
help: consider changing this closure to take self by mutable reference
2018-12-25 09:56:47 -06:00
--> $DIR/unboxed-closures-mutate-upvar.rs:52:23
2018-08-08 07:28:26 -05:00
|
LL | let mut f = to_fn(move || {
| _______________________^
LL | | n += 1; //~ ERROR cannot assign
LL | | });
| |_____^
error: aborting due to 4 previous errors
Some errors occurred: E0594, E0595.
For more information about an error, try `rustc --explain E0594`.