I suppose you're referring to the simultaneous ManuallyDrop<&mut i32>
and returned &mut i32
in transmute
. But as I understand it, creating the second reference only makes the reference in the ManuallyDrop
an invalid value. Since we destruct the ManuallyDrop
without touching it again, we never have to assert the first reference's validity; otherwise, methods like ManuallyDrop::drop()
would be wildly unsafe. I've depended on this property myself for dropping a ManuallyDrop<Box<_>>
within a Drop
impl, and Ralf Jung seemed to tentatively agree with the reasoning.