about summary refs log tree commit diff
path: root/library/alloc
diff options
context:
space:
mode:
authorThe Miri Cronjob Bot <miri@cron.bot>2024-03-30 05:23:38 +0000
committerThe Miri Cronjob Bot <miri@cron.bot>2024-03-30 05:23:38 +0000
commit28521fd2eb40339a20e10c124e60b5efbc31e17b (patch)
tree90d2cf40dac38eaa763ff4df5c514b0f86b4b40e /library/alloc
parentfee9a8eab8f1ae85135f2de7bf8bee815e364665 (diff)
parent69fa40cb48384fad7930dce2d9a20d18fe4d1b51 (diff)
Merge from rustc
Diffstat (limited to 'library/alloc')
-rw-r--r--library/alloc/src/collections/vec_deque/mod.rs2
-rw-r--r--library/alloc/src/lib.rs1
-rw-r--r--library/alloc/src/raw_vec.rs8
-rw-r--r--library/alloc/src/vec/mod.rs4
4 files changed, 7 insertions, 8 deletions
diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs
index 41adc2e79dc..5ff7f184a6d 100644
--- a/library/alloc/src/collections/vec_deque/mod.rs
+++ b/library/alloc/src/collections/vec_deque/mod.rs
@@ -2087,7 +2087,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
         // buffer without it being full emerge
         debug_assert!(self.is_full());
         let old_cap = self.capacity();
-        self.buf.reserve_for_push(old_cap);
+        self.buf.grow_one();
         unsafe {
             self.handle_capacity_increase(old_cap);
         }
diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs
index 26d238154a3..b6a9d6005d4 100644
--- a/library/alloc/src/lib.rs
+++ b/library/alloc/src/lib.rs
@@ -166,7 +166,6 @@
 #![feature(try_trait_v2)]
 #![feature(try_with_capacity)]
 #![feature(tuple_trait)]
-#![feature(unchecked_math)]
 #![feature(unicode_internals)]
 #![feature(unsize)]
 #![feature(utf8_chunks)]
diff --git a/library/alloc/src/raw_vec.rs b/library/alloc/src/raw_vec.rs
index 175e23b543c..0883080d735 100644
--- a/library/alloc/src/raw_vec.rs
+++ b/library/alloc/src/raw_vec.rs
@@ -345,12 +345,12 @@ impl<T, A: Allocator> RawVec<T, A> {
         }
     }
 
-    /// A specialized version of `reserve()` used only by the hot and
-    /// oft-instantiated `Vec::push()`, which does its own capacity check.
+    /// A specialized version of `self.reserve(len, 1)` which requires the
+    /// caller to ensure `len == self.capacity()`.
     #[cfg(not(no_global_oom_handling))]
     #[inline(never)]
-    pub fn reserve_for_push(&mut self, len: usize) {
-        if let Err(err) = self.grow_amortized(len, 1) {
+    pub fn grow_one(&mut self) {
+        if let Err(err) = self.grow_amortized(self.cap.0, 1) {
             handle_error(err);
         }
     }
diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs
index 8ca8046dac5..7e3463bc082 100644
--- a/library/alloc/src/vec/mod.rs
+++ b/library/alloc/src/vec/mod.rs
@@ -1547,7 +1547,7 @@ impl<T, A: Allocator> Vec<T, A> {
 
         // space for the new element
         if len == self.buf.capacity() {
-            self.reserve(1);
+            self.buf.grow_one();
         }
 
         unsafe {
@@ -1967,7 +1967,7 @@ impl<T, A: Allocator> Vec<T, A> {
         // This will panic or abort if we would allocate > isize::MAX bytes
         // or if the length increment would overflow for zero-sized types.
         if self.len == self.buf.capacity() {
-            self.buf.reserve_for_push(self.len);
+            self.buf.grow_one();
         }
         unsafe {
             let end = self.as_mut_ptr().add(self.len);