From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- .../rustc_error_codes/src/error_codes/E0607.md | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 compiler/rustc_error_codes/src/error_codes/E0607.md (limited to 'compiler/rustc_error_codes/src/error_codes/E0607.md') diff --git a/compiler/rustc_error_codes/src/error_codes/E0607.md b/compiler/rustc_error_codes/src/error_codes/E0607.md new file mode 100644 index 000000000..054524692 --- /dev/null +++ b/compiler/rustc_error_codes/src/error_codes/E0607.md @@ -0,0 +1,26 @@ +A cast between a thin and a fat pointer was attempted. + +Erroneous code example: + +```compile_fail,E0607 +let v = core::ptr::null::(); +v as *const [u8]; +``` + +First: what are thin and fat pointers? + +Thin pointers are "simple" pointers: they are purely a reference to a memory +address. + +Fat pointers are pointers referencing Dynamically Sized Types (also called +DSTs). DSTs don't have a statically known size, therefore they can only exist +behind some kind of pointer that contains additional information. For example, +slices and trait objects are DSTs. In the case of slices, the additional +information the fat pointer holds is their size. + +To fix this error, don't try to cast directly between thin and fat pointers. + +For more information about type casts, take a look at the section of the +[The Rust Reference][1] on type cast expressions. + +[1]: https://doc.rust-lang.org/reference/expressions/operator-expr.html#type-cast-expressions -- cgit v1.2.3