File tree Expand file tree Collapse file tree 2 files changed +37
-3
lines changed
branches/stable/src/librustc Expand file tree Collapse file tree 2 files changed +37
-3
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,6 @@ refs/heads/tmp: e5d90d98402475b6e154ce216f9efcb80da1a747
29
29
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
30
30
refs/tags/homu-tmp: 1fe32ca12c51afcd761d9962f51a74ff0d07a591
31
31
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32
- refs/heads/stable: 6471dccd3b3a5b83b4fccecffc94047e1086ca2f
32
+ refs/heads/stable: 2015eb881e8d9e82c1a889595c5b7b33440b2ae7
33
33
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
34
34
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
Original file line number Diff line number Diff line change @@ -294,6 +294,42 @@ println!("{}", Y);
294
294
```
295
295
"## ,
296
296
297
+ E0019 : r##"
298
+ A function call isn't allowed in the const's initialization expression
299
+ because the expression's value must be known at compile-time. Example of
300
+ erroneous code:
301
+
302
+ ```
303
+ enum Test {
304
+ V1
305
+ }
306
+
307
+ impl Test {
308
+ fn test(&self) -> i32 {
309
+ 12
310
+ }
311
+ }
312
+
313
+ fn main() {
314
+ const FOO: Test = Test::V1;
315
+
316
+ const A: i32 = FOO.test(); // You can't call Test::func() here !
317
+ }
318
+ ```
319
+
320
+ Remember: you can't use a function call inside a const's initialization
321
+ expression! However, you can totally use it elsewhere you want:
322
+
323
+ ```
324
+ fn main() {
325
+ const FOO: Test = Test::V1;
326
+
327
+ FOO.func(); // here is good
328
+ let x = FOO.func(); // or even here!
329
+ }
330
+ ```
331
+ "## ,
332
+
297
333
E0020 : r##"
298
334
This error indicates that an attempt was made to divide by zero (or take the
299
335
remainder of a zero divisor) in a static or constant expression.
@@ -965,9 +1001,7 @@ static mut BAR: Option<Vec<i32>> = None;
965
1001
966
1002
967
1003
register_diagnostics ! {
968
- E0016 ,
969
1004
E0017 ,
970
- E0019 ,
971
1005
E0022 ,
972
1006
E0038 ,
973
1007
E0109 ,
You can’t perform that action at this time.
0 commit comments