]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0595.md
Rollup merge of #92310 - ehuss:rustdoc-ice, r=estebank
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0595.md
1 #### Note: this error code is no longer emitted by the compiler.
2
3 Closures cannot mutate immutable captured variables.
4
5 Erroneous code example:
6
7 ```compile_fail,E0594
8 let x = 3; // error: closure cannot assign to immutable local variable `x`
9 let mut c = || { x += 1 };
10 ```
11
12 Make the variable binding mutable:
13
14 ```
15 let mut x = 3; // ok!
16 let mut c = || { x += 1 };
17 ```