Description
The ManuallyDrop
docs say
ManuallyDrop is subject to the same layout optimizations as T. As a consequence, it has no effect on the assumptions that the compiler makes about its contents.
In particular, this means that a ManuallyDrop<Box<T>>
must not dangle. But that means that after calling drop
on a ManuallDrop<Box<T>>
, that value violates the validity invariant and must not be used or passed around any more! I don't think that is the behavior we want.
We want ManuallyDrop
to preserve niches, so we cannot really relax what it says about validity. But what we could relax is validity of Box
-- we could say that validity is purely about the pointer value itself (it must be non-NULL and properly aligned). We could specify that the "dereferencability" only comes in through the aliasing model, and we could make that model stop looking into ManuallyDrop
.