Rollup merge of #57589 - scottmcm:vec-set_len-debug_assert, r=alexcrichton

Add a debug_assert to Vec::set_len

Following the precedent of https://github.com/rust-lang/rust/pull/52972, which found https://github.com/llogiq/bytecount/pull/42.

(This may well make a test fail; let's see what Travis says.)
This commit is contained in:
Mazdak Farrokhzad 2019-01-14 20:31:59 +01:00 committed by GitHub
commit 8a62e393b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -819,6 +819,8 @@ impl<T> Vec<T> {
#[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;
}