Pointee not on the heap?
Pointee not on the heap?
Posted Apr 23, 2026 17:21 UTC (Thu) by tialaramex (subscriber, #21167)In reply to: Pointee not on the heap? by pbonzini
Parent article: One Sized trait does not fit all
I think Rust is already comfortable with pointers where we know nothing whatsoever about the thing pointed to. Indeed unlike C++ Rust is comfortable with raw pointers which are not valid, so e.g. if you want to store the integer 5, or the text 'CLOWNS' in this 64-bit CPU register which has the type of a raw pointer to a Doodad, Rust is OK with that existing *so long* as you have ensured you will never try to dereference the pointer in the Rust. If you dereference a nonsense pointer that's UB, which is why dereferencing raw pointers is one of the handful of named unsafe "super powers" - it's on the programmer to make sure they only do this to valid pointers.
I think the idea with Pointee is that we know that there is something pointed to, but Rust doesn't know what and so will never know (not at compile time, not at execution start, not even at runtime) how big Pointee is. So I think Pointee in some sense isn't a new addition to the model, but the current status quo for "We don't know the size".
