The align_first function of the maligned crate manually allocates with an alignment larger than T, and then uses Vec::from_raw_parts on that allocation to get a Vec<T>.
As per the stdlib documentation this violates the GlobalAlloc::dealloc safety contract and causes undefined behaviour, since the allocation has to have the exact same allocation as T.
The
align_firstfunction of themalignedcrate manually allocates with an alignment larger thanT, and then usesVec::from_raw_partson that allocation to get aVec<T>.As per the stdlib documentation this violates the
GlobalAlloc::deallocsafety contract and causes undefined behaviour, since the allocation has to have the exact same allocation asT.