]> git.lizzy.rs Git - rust.git/commitdiff
Replace "Bad example" by a better sentence
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Fri, 19 Jun 2015 12:05:11 +0000 (14:05 +0200)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Fri, 19 Jun 2015 12:05:11 +0000 (14:05 +0200)
src/librustc/diagnostics.rs

index 124117ca80bcd7e8e4e52e831996c82151bc44c4..0f83cdff5372c95b797e4c3e2870c23b7e6bf6c1 100644 (file)
@@ -294,6 +294,42 @@ fn index<'a>(&'a self, idx: u8) -> &'a u8 { &self.a }
 ```
 "##,
 
+E0019: r##"
+A function call isn't allowed in the const's initialization expression
+because the expression's value must be known at compile-time. Example of
+erroneous code:
+
+```
+enum Test {
+    V1
+}
+
+impl Test {
+    fn test(&self) -> i32 {
+        12
+    }
+}
+
+fn main() {
+    const FOO: Test = Test::V1;
+
+    const A: i32 = FOO.test(); // You can't call Test::func() here !
+}
+```
+
+Remember: you can't use a function call inside a const's initialization
+expression! However, you can totally use it elsewhere you want:
+
+```
+fn main() {
+    const FOO: Test = Test::V1;
+
+    FOO.func(); // here is good
+    let x = FOO.func(); // or even here!
+}
+```
+"##,
+
 E0020: r##"
 This error indicates that an attempt was made to divide by zero (or take the
 remainder of a zero divisor) in a static or constant expression.
@@ -965,9 +1001,7 @@ fn bar(&self) -> i32 { self.0 }
 
 
 register_diagnostics! {
-    E0016,
     E0017,
-    E0019,
     E0022,
     E0038,
     E0109,