about summary refs log tree commit diff
path: root/library/alloc/src/raw_vec.rs
diff options
context:
space:
mode:
Diffstat (limited to 'library/alloc/src/raw_vec.rs')
-rw-r--r--library/alloc/src/raw_vec.rs32
1 files changed, 13 insertions, 19 deletions
diff --git a/library/alloc/src/raw_vec.rs b/library/alloc/src/raw_vec.rs
index fdf6884794a..36b7efc33a8 100644
--- a/library/alloc/src/raw_vec.rs
+++ b/library/alloc/src/raw_vec.rs
@@ -9,7 +9,7 @@ use core::ops::Drop;
 use core::ptr::{self, NonNull, Unique};
 use core::slice;
 
-use crate::alloc::{handle_alloc_error, AllocRef, Global, Layout};
+use crate::alloc::{handle_alloc_error, Allocator, Global, Layout};
 use crate::boxed::Box;
 use crate::collections::TryReserveError::{self, *};
 
@@ -46,7 +46,7 @@ enum AllocInit {
 /// `usize::MAX`. This means that you need to be careful when round-tripping this type with a
 /// `Box<[T]>`, since `capacity()` won't yield the length.
 #[allow(missing_debug_implementations)]
-pub struct RawVec<T, A: AllocRef = Global> {
+pub struct RawVec<T, A: Allocator = Global> {
     ptr: Unique<T>,
     cap: usize,
     alloc: A,
@@ -113,11 +113,10 @@ impl<T> RawVec<T, Global> {
     }
 }
 
-impl<T, A: AllocRef> RawVec<T, A> {
+impl<T, A: Allocator> RawVec<T, A> {
     /// Like `new`, but parameterized over the choice of allocator for
     /// the returned `RawVec`.
-    #[cfg_attr(not(bootstrap), rustc_allow_const_fn_unstable(const_fn))]
-    #[cfg_attr(bootstrap, allow_internal_unstable(const_fn))]
+    #[rustc_allow_const_fn_unstable(const_fn)]
     pub const fn new_in(alloc: A) -> Self {
         // `cap: 0` means "unallocated". zero-sized types are ignored.
         Self { ptr: Unique::dangling(), cap: 0, alloc }
@@ -140,7 +139,7 @@ impl<T, A: AllocRef> RawVec<T, A> {
     /// Converts a `Box<[T]>` into a `RawVec<T>`.
     pub fn from_box(slice: Box<[T], A>) -> Self {
         unsafe {
-            let (slice, alloc) = Box::into_raw_with_alloc(slice);
+            let (slice, alloc) = Box::into_raw_with_allocator(slice);
             RawVec::from_raw_parts_in(slice.as_mut_ptr(), slice.len(), alloc)
         }
     }
@@ -186,8 +185,8 @@ impl<T, A: AllocRef> RawVec<T, A> {
                 Err(_) => capacity_overflow(),
             }
             let result = match init {
-                AllocInit::Uninitialized => alloc.alloc(layout),
-                AllocInit::Zeroed => alloc.alloc_zeroed(layout),
+                AllocInit::Uninitialized => alloc.allocate(layout),
+                AllocInit::Zeroed => alloc.allocate_zeroed(layout),
             };
             let ptr = match result {
                 Ok(ptr) => ptr,
@@ -233,15 +232,10 @@ impl<T, A: AllocRef> RawVec<T, A> {
     }
 
     /// Returns a shared reference to the allocator backing this `RawVec`.
-    pub fn alloc(&self) -> &A {
+    pub fn allocator(&self) -> &A {
         &self.alloc
     }
 
-    /// Returns a mutable reference to the allocator backing this `RawVec`.
-    pub fn alloc_mut(&mut self) -> &mut A {
-        &mut self.alloc
-    }
-
     fn current_memory(&self) -> Option<(NonNull<u8>, Layout)> {
         if mem::size_of::<T>() == 0 || self.cap == 0 {
             None
@@ -365,7 +359,7 @@ impl<T, A: AllocRef> RawVec<T, A> {
     }
 }
 
-impl<T, A: AllocRef> RawVec<T, A> {
+impl<T, A: Allocator> RawVec<T, A> {
     /// Returns if the buffer needs to grow to fulfill the needed extra capacity.
     /// Mainly used to make inlining reserve-calls possible without inlining `grow`.
     fn needs_to_grow(&self, len: usize, additional: usize) -> bool {
@@ -478,7 +472,7 @@ fn finish_grow<A>(
     alloc: &mut A,
 ) -> Result<NonNull<[u8]>, TryReserveError>
 where
-    A: AllocRef,
+    A: Allocator,
 {
     // Check for the error here to minimize the size of `RawVec::grow_*`.
     let new_layout = new_layout.map_err(|_| CapacityOverflow)?;
@@ -493,17 +487,17 @@ where
             alloc.grow(ptr, old_layout, new_layout)
         }
     } else {
-        alloc.alloc(new_layout)
+        alloc.allocate(new_layout)
     };
 
     memory.map_err(|_| AllocError { layout: new_layout, non_exhaustive: () })
 }
 
-unsafe impl<#[may_dangle] T, A: AllocRef> Drop for RawVec<T, A> {
+unsafe impl<#[may_dangle] T, A: Allocator> Drop for RawVec<T, A> {
     /// Frees the memory owned by the `RawVec` *without* trying to drop its contents.
     fn drop(&mut self) {
         if let Some((ptr, layout)) = self.current_memory() {
-            unsafe { self.alloc.dealloc(ptr, layout) }
+            unsafe { self.alloc.deallocate(ptr, layout) }
         }
     }
 }