Open
Description
Right now, we specify here that:
The size of
&[T]
is two words.
However, if T
is a ZST, we actually only need to store the length of the slice, and can make &[T]
one word wide.
When coercing &[T]
to a *const T
, we can materialize the pointer out of thin air using: std::mem::align_of::<T>() as *const T
.
The current specification would prevent such a layout optimization.
Is this an optimization worth supporting?
EDIT: some issues
(ptr, len) != [T]::from_raw_parts(ptr, len).into_raw()
, sinceptr
does not necessarily need to bealign_of::<T>()
, yet if we don't store it, the address is lost