about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc_error_codes/error_codes/E0015.md36
1 files changed, 27 insertions, 9 deletions
diff --git a/src/librustc_error_codes/error_codes/E0015.md b/src/librustc_error_codes/error_codes/E0015.md
index 2bf59983fa9..361cb425809 100644
--- a/src/librustc_error_codes/error_codes/E0015.md
+++ b/src/librustc_error_codes/error_codes/E0015.md
@@ -1,14 +1,32 @@
-The only functions that can be called in static or constant expressions are
-`const` functions, and struct/enum constructors. `const` functions are only
-available on a nightly compiler. Rust currently does not support more general
-compile-time function execution.
+A constant item was initialized with something that is not a constant expression.
+
+Erroneous code example:
+
+```compile_fail,E0015
+fn create_some() -> Option<u8> {
+    Some(1)
+}
 
+const FOO: Option<u8> = create_some(); // error!
 ```
-const FOO: Option<u8> = Some(1); // enum constructor
-struct Bar {x: u8}
-const BAR: Bar = Bar {x: 1}; // struct constructor
+
+The only functions that can be called in static or constant expressions are
+`const` functions, and struct/enum constructors.
+
+To fix this error, you can declare `create_some` as a constant function:
+
 ```
+const fn create_some() -> Option<u8> { // declared as a const function
+    Some(1)
+}
 
-See [RFC 911] for more details on the design of `const fn`s.
+const FOO: Option<u8> = create_some(); // ok!
 
-[RFC 911]: https://github.com/rust-lang/rfcs/blob/master/text/0911-const-fn.md
+// These are also working:
+struct Bar {
+    x: u8,
+}
+
+const OTHER_FOO: Option<u8> = Some(1);
+const BAR: Bar = Bar {x: 1};
+```