File tree 1 file changed +17
-1
lines changed
1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -195,6 +195,23 @@ const Y: i32 = A;
195
195
```
196
196
"## ,
197
197
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
+
198
215
E0015 : r##"
199
216
The only function calls allowed in static or constant expressions are enum
200
217
variant constructors or struct constructors (for unit or tuple structs). This
@@ -801,7 +818,6 @@ struct Foo<T: 'static> {
801
818
802
819
register_diagnostics ! {
803
820
E0011 ,
804
- E0014 ,
805
821
E0016 ,
806
822
E0017 ,
807
823
E0019 ,
You can’t perform that action at this time.
0 commit comments