summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_error_codes/src/error_codes/E0697.md
blob: ab63d2e73f7d1ae803aced4a051787a0ef99cd40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
A closure has been used as `static`.

Erroneous code example:

```compile_fail,E0697
fn main() {
    static || {}; // used as `static`
}
```

Closures cannot be used as `static`. They "save" the environment,
and as such a static closure would save only a static environment
which would consist only of variables with a static lifetime. Given
this it would be better to use a proper function. The easiest fix
is to remove the `static` keyword.