diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 0e3799ed9ac37..4a3418986064d 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -1661,7 +1661,10 @@ impl Vec { // Create a `Vec` from our `PartialVecZeroSized` and make sure the // destructor of the latter will not run. None of this can panic. let mut result = Vec::new(); - unsafe { result.set_len(pv.num_u); } + unsafe { + result.set_len(pv.num_u); + mem::forget(pv); + } result } }