about summary refs log tree commit diff
path: root/src/librustc/error_codes.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-10-14 10:00:51 +0000
committerbors <bors@rust-lang.org>2019-10-14 10:00:51 +0000
commit446e5e57b667c841ba3ebb4b41b44fb98bd3af4b (patch)
treeb6cc0036da62d65162168901c85cf368d8ed440d /src/librustc/error_codes.rs
parentd28a9c38fe14396e86ae274c7847e20ee0f78ca9 (diff)
parenta73e0731f45577bb6b760fe5d8d328de2021a74f (diff)
Auto merge of #65399 - Centril:rollup-6lzj0w5, r=Centril
Rollup of 7 pull requests

Successful merges:

 - #65215 (Add long error explanation for E0697)
 - #65292 (Print lifetimes with backticks)
 - #65362 (syntax: consolidate function parsing in item.rs)
 - #65363 (Remove implicit dependencies on syntax::pprust)
 - #65379 (refactor session::config::build_session_options_and_crate_config)
 - #65392 (Move `Nonterminal::to_tokenstream` to parser & don't rely directly on parser in lowering)
 - #65395 (Add some tests for fixed ICEs)

Failed merges:

r? @ghost
Diffstat (limited to 'src/librustc/error_codes.rs')
-rw-r--r--src/librustc/error_codes.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/librustc/error_codes.rs b/src/librustc/error_codes.rs
index 50b6ef57b55..3d501cacf6f 100644
--- a/src/librustc/error_codes.rs
+++ b/src/librustc/error_codes.rs
@@ -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