Closed
Description
With #[derive(Clone)]
on ManuallyDrop<T>
, x.clone_from(&y)
will not drop the T
inside x
, just like x = y.clone();
does not drop the original x
before overwriting it.
However, a manual implementation of clone_from
can only make use of the efficiency of a overriden clone_from
on T
(e.g. memory reuse by a Vec::clone_from
) by simply forwarding to it, which means that x.clone_from(&y)
will not forget the old value.
This new (forwarding, so (potentially) dropping) behaviour was added in #85176, and (for now) reverted in #85758.
So question for @rust-lang/libs: What behaviour would be correct? There are arguments for both. Whatever the decision, we should document it and add a test for it.