]> git.lizzy.rs Git - rust.git/blob - src/librustc_error_codes/error_codes/E0512.md
Auto merge of #66396 - smmalis37:pythontest, r=alexcrichton
[rust.git] / src / librustc_error_codes / error_codes / E0512.md
1 Transmute with two differently sized types was attempted. Erroneous code
2 example:
3
4 ```compile_fail,E0512
5 fn takes_u8(_: u8) {}
6
7 fn main() {
8     unsafe { takes_u8(::std::mem::transmute(0u16)); }
9     // error: cannot transmute between types of different sizes,
10     //        or dependently-sized types
11 }
12 ```
13
14 Please use types with same size or use the expected type directly. Example:
15
16 ```
17 fn takes_u8(_: u8) {}
18
19 fn main() {
20     unsafe { takes_u8(::std::mem::transmute(0i8)); } // ok!
21     // or:
22     unsafe { takes_u8(0u8); } // ok!
23 }
24 ```