]> git.proxmox.com Git - rustc.git/blob - src/librustc_error_codes/error_codes/E0606.md
New upstream version 1.41.1+dfsg1
[rustc.git] / src / librustc_error_codes / error_codes / E0606.md
1 An incompatible cast was attempted.
2
3 Erroneous code example:
4
5 ```compile_fail,E0606
6 let x = &0u8; // Here, `x` is a `&u8`.
7 let y: u32 = x as u32; // error: casting `&u8` as `u32` is invalid
8 ```
9
10 When casting, keep in mind that only primitive types can be cast into each
11 other. Example:
12
13 ```
14 let x = &0u8;
15 let y: u32 = *x as u32; // We dereference it first and then cast it.
16 ```
17
18 For more information about casts, take a look at the Type cast section in
19 [The Reference Book][1].
20
21 [1]: https://doc.rust-lang.org/reference/expressions/operator-expr.html#type-cast-expressions