1
Fork 0

Rollup merge of #65215 - JohnTitor:long-explanation-e0697, r=GuillaumeGomez

Add long error explanation for E0697

Part of #61137

r? @GuillaumeGomez
This commit is contained in:
Mazdak Farrokhzad 2019-10-14 07:36:52 +02:00 committed by GitHub
commit 1ac00287af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View file

@ -2005,6 +2005,24 @@ a (non-transparent) struct containing a single float, while `Grams` is a
transparent wrapper around a float. This can make a difference for the ABI.
"##,
E0697: r##"
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.
"##,
E0698: r##"
When using generators (or async) all type variables must be bound so a
generator can be constructed.
@ -2191,7 +2209,6 @@ See [RFC 2091] for details on this and other limitations.
E0657, // `impl Trait` can only capture lifetimes bound at the fn level
E0687, // in-band lifetimes cannot be used in `fn`/`Fn` syntax
E0688, // in-band lifetimes cannot be mixed with explicit lifetime binders
E0697, // closures cannot be static
// E0707, // multiple elided lifetimes used in arguments of `async fn`
E0708, // `async` non-`move` closures with parameters are not currently
// supported

View file

@ -6,3 +6,4 @@ LL | static || {};
error: aborting due to previous error
For more information about this error, try `rustc --explain E0697`.