Skip to content

Commit 8a62e39

Browse files
authored
Rollup merge of #57589 - scottmcm:vec-set_len-debug_assert, r=alexcrichton
Add a debug_assert to Vec::set_len Following the precedent of #52972, which found llogiq/bytecount#42. (This may well make a test fail; let's see what Travis says.)
2 parents b03d414 + 1fd971c commit 8a62e39

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/liballoc/vec.rs

+2
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,8 @@ impl<T> Vec<T> {
819819
#[inline]
820820
#[stable(feature = "rust1", since = "1.0.0")]
821821
pub unsafe fn set_len(&mut self, new_len: usize) {
822+
debug_assert!(new_len <= self.capacity());
823+
822824
self.len = new_len;
823825
}
824826

0 commit comments

Comments
 (0)