]> git.proxmox.com Git - rustc.git/blob - src/librustc_error_codes/error_codes/E0607.md
New upstream version 1.41.1+dfsg1
[rustc.git] / src / librustc_error_codes / error_codes / E0607.md
1 A cast between a thin and a fat pointer was attempted.
2
3 Erroneous code example:
4
5 ```compile_fail,E0607
6 let v = core::ptr::null::<u8>();
7 v as *const [u8];
8 ```
9
10 First: what are thin and fat pointers?
11
12 Thin pointers are "simple" pointers: they are purely a reference to a memory
13 address.
14
15 Fat pointers are pointers referencing Dynamically Sized Types (also called DST).
16 DST don't have a statically known size, therefore they can only exist behind
17 some kind of pointers that contain additional information. Slices and trait
18 objects are DSTs. In the case of slices, the additional information the fat
19 pointer holds is their size.
20
21 To fix this error, don't try to cast directly between thin and fat pointers.
22
23 For more information about casts, take a look at the Type cast section in
24 [The Reference Book][1].
25
26 [1]: https://doc.rust-lang.org/reference/expressions/operator-expr.html#type-cast-expressions