]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0697.md
Rollup merge of #92310 - ehuss:rustdoc-ice, r=estebank
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0697.md
1 A closure has been used as `static`.
2
3 Erroneous code example:
4
5 ```compile_fail,E0697
6 fn main() {
7     static || {}; // used as `static`
8 }
9 ```
10
11 Closures cannot be used as `static`. They "save" the environment,
12 and as such a static closure would save only a static environment
13 which would consist only of variables with a static lifetime. Given
14 this it would be better to use a proper function. The easiest fix
15 is to remove the `static` keyword.