Skip to content

Commit 218e94f

Browse files
Add error explanation for E0014
1 parent 86a821e commit 218e94f

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/librustc/diagnostics.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,23 @@ const Y: i32 = A;
195195
```
196196
"##,
197197

198+
E0014: r##"
199+
Constant variables' value can only be a constant value or a function. Bad
200+
example:
201+
202+
```
203+
const FOO: i32 = { let x = 0; x }; // 'x' isn't a constant nor a function!
204+
```
205+
206+
To avoid it, you have to replace the non-constant value:
207+
208+
```
209+
const FOO: i32 = { const X : i32 = 0; X };
210+
// or even:
211+
const FOO: i32 = { 0 }; // but brackets are useless here
212+
```
213+
"##,
214+
198215
E0015: r##"
199216
The only function calls allowed in static or constant expressions are enum
200217
variant constructors or struct constructors (for unit or tuple structs). This
@@ -801,7 +818,6 @@ struct Foo<T: 'static> {
801818

802819
register_diagnostics! {
803820
E0011,
804-
E0014,
805821
E0016,
806822
E0017,
807823
E0019,

0 commit comments

Comments
 (0)