]> git.lizzy.rs Git - rust.git/commitdiff
Add E0512 error explanation
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Thu, 8 Oct 2015 10:01:16 +0000 (12:01 +0200)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Thu, 8 Oct 2015 17:39:26 +0000 (19:39 +0200)
src/librustc_trans/diagnostics.rs

index 05236a7a6fb2823fffee6d1b20ea2105953d4edb..b1854d998a2e4d4bdb65c8ec0acd88618123032f 100644 (file)
 
 register_long_diagnostics! {
 
+E0512: r##"
+A transmute was called on types with different sizes. Erroneous code example:
+
+```
+extern "rust-intrinsic" {
+    pub fn ctpop8(x: u8) -> u8;
+}
+
+fn main() {
+    unsafe { ctpop8(::std::mem::transmute(0u16)); }
+    // error: transmute called on types with different sizes
+}
+```
+
+Please use types with same size or use the awaited type directly. Example:
+
+```
+extern "rust-intrinsic" {
+    pub fn ctpop8(x: u8) -> u8;
+}
+
+fn main() {
+    unsafe { ctpop8(::std::mem::transmute(0i8)); } // ok!
+    // or:
+    unsafe { ctpop8(0u8); } // ok!
+}
+```
+"##,
+
 E0515: r##"
 A constant index expression was out of bounds. Erroneous code example:
 
@@ -23,7 +52,7 @@
 Example:
 
 ```
-let x = &[0, 1, 2][2]; // ok!
+let x = &[0, 1, 2][2]; // ok
 ```
 "##,
 
@@ -32,5 +61,4 @@
 register_diagnostics! {
     E0510, // invalid use of `return_address` intrinsic: function does not use out pointer
     E0511, // invalid monomorphization of `{}` intrinsic
-    E0512, // transmute called on types with potentially different sizes...
 }