diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index e010c32f8ea..efcb5d2ceb3 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -497,10 +497,11 @@ impl Vec { unsafe { // drop any extra elements while len < self.len { - // decrement len before the read(), so a panic on Drop doesn't - // re-drop the just-failed value. + // decrement len before the drop_in_place(), so a panic on Drop + // doesn't re-drop the just-failed value. self.len -= 1; - ptr::read(self.get_unchecked(self.len)); + let len = self.len; + ptr::drop_in_place(self.get_unchecked_mut(len)); } } }