diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index e1c5ab15bb5ce..ba3b3dfbfc2e1 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -819,6 +819,8 @@ impl Vec { #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn set_len(&mut self, new_len: usize) { + debug_assert!(new_len <= self.capacity()); + self.len = new_len; }