about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorScott McMurray <scottmcm@users.noreply.github.com>2018-12-14 21:41:18 -0800
committerScott McMurray <scottmcm@users.noreply.github.com>2019-01-13 22:40:25 -0800
commit1fd971c3b97bc1f01740a552aeb3d23b6ed194f5 (patch)
tree11cac072b2ee22aa81c4096bbc8f5fe2cee4ede6 /src/liballoc
parenta16e1a781de15f276d558f542ee40b45a0eab143 (diff)
downloadrust-1fd971c3b97bc1f01740a552aeb3d23b6ed194f5.tar.gz
rust-1fd971c3b97bc1f01740a552aeb3d23b6ed194f5.zip
Add a debug_assert to Vec::set_len
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/vec.rs2
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;
     }