Description
Reading the documentation for the #![feature(layout_for_ptr)]
functions, it doesn't mention if it accepts invalid data pointer values (e.g. a pointer created with core::ptr::null()
), but seems to suggest that it does:
If
T
isSized
, this function is always safe to call.
but there's a comment mentioning that the pointer must be valid inside the functions, e.g.:
rust/library/core/src/mem/mod.rs
Lines 375 to 378 in 456a032
I would think that the answer is yes since its operating on the metadata of the pointer and not the pointer value itself (and with my limited testing, this seems like the current behavior). However, in either case I think its worth explicitly mentioning the validity of the pointer in the documentation for the functions.