From ea1110b62298a839fb58b65534fc8b0f816dc9fd Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Wed, 6 Sep 2023 14:50:23 -0700 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Ralf Jung --- src/types/pointer.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/types/pointer.md b/src/types/pointer.md index 723111cae..afb32ac60 100644 --- a/src/types/pointer.md +++ b/src/types/pointer.md @@ -56,6 +56,10 @@ Despite pointers and references being similar to `usize`s in the machine code em the semantics of transmuting a reference or pointer type to a non-pointer type is currently undecided. Thus, it may not be valid to transmute a pointer or reference type, `P`, to a `[u8; size_of::

()]`. +For thin raw pointers (i.e., for `::Metadata == ()` and `P = *const T` or `P = *mut T`), +the inverse direction (transmuting from an integer or array of integers to `P`) is always valid. +However, the pointer produced via such a transmutation may not be dereferenced (not even if `T` has size zero). + [`core::ptr::addr_of!`]: ../../core/ptr/macro.addr_of.html [`core::ptr::addr_of_mut!`]: ../../core/ptr/macro.addr_of_mut.html [Interior mutability]: ../interior-mutability.md