diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-01-14 20:31:59 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-14 20:31:59 +0100 |
| commit | 8a62e393b8fba95e989020f2efbf846ca02113f9 (patch) | |
| tree | 2aa2f0658dadf106b332587148395d9b3087faac /src/liballoc | |
| parent | b03d414e3c222a7f29259526fcdf95189e61fd0c (diff) | |
| parent | 1fd971c3b97bc1f01740a552aeb3d23b6ed194f5 (diff) | |
| download | rust-8a62e393b8fba95e989020f2efbf846ca02113f9.tar.gz rust-8a62e393b8fba95e989020f2efbf846ca02113f9.zip | |
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.)
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/vec.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index e1c5ab15bb5..ba3b3dfbfc2 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -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; } |
