In my "allocator"/"storage" for my untyped vector, I use NonNull::dangling
for unallocted heap pointer
any_vec/heap.rs at main · tower120/any_vec · GitHub .
The problem is - allocator work with Layout, and without concrete type (very much like std::alloc::Allocator
). Memory represented as heap with NonNull pointer to it. So when I call NonNull::dangling - it create pointer with 1 byte align (u8 size). When I create empty slice of concrete type from it - I have message from MIRI that pointer align is mismatch with concrete type. Which is technically true.
So, if NonNull::dangling could be constructed with align or Layout - that would solve my problem.
Or maybe some other way to create pointer to uninitialized memory with specific Layout.
P.S. I can construct pointer with address = Layout.align()
, but I have filling that there is also some black compiler magic for NonNull::dangling
.