Skip to content

Commit e26acf4

Browse files
---
yaml --- r: 225980 b: refs/heads/stable c: 2015eb8 h: refs/heads/master v: v3
1 parent 41900c1 commit e26acf4

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ refs/heads/tmp: e5d90d98402475b6e154ce216f9efcb80da1a747
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: 1fe32ca12c51afcd761d9962f51a74ff0d07a591
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 6471dccd3b3a5b83b4fccecffc94047e1086ca2f
32+
refs/heads/stable: 2015eb881e8d9e82c1a889595c5b7b33440b2ae7
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b

branches/stable/src/librustc/diagnostics.rs

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,42 @@ println!("{}", Y);
294294
```
295295
"##,
296296

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+
297333
E0020: r##"
298334
This error indicates that an attempt was made to divide by zero (or take the
299335
remainder of a zero divisor) in a static or constant expression.
@@ -965,9 +1001,7 @@ static mut BAR: Option<Vec<i32>> = None;
9651001

9661002

9671003
register_diagnostics! {
968-
E0016,
9691004
E0017,
970-
E0019,
9711005
E0022,
9721006
E0038,
9731007
E0109,

0 commit comments

Comments
 (0)