about summary refs log tree commit diff
path: root/library/core
diff options
context:
space:
mode:
Diffstat (limited to 'library/core')
-rw-r--r--library/core/src/alloc/layout.rs2
-rw-r--r--library/core/src/alloc/mod.rs64
-rw-r--r--library/core/src/ptr/non_null.rs4
3 files changed, 35 insertions, 35 deletions
diff --git a/library/core/src/alloc/layout.rs b/library/core/src/alloc/layout.rs
index 339d85902b8..57c6624b64f 100644
--- a/library/core/src/alloc/layout.rs
+++ b/library/core/src/alloc/layout.rs
@@ -19,7 +19,7 @@ const fn size_align<T>() -> (usize, usize) {
 /// even though `GlobalAlloc` requires that all memory requests
 /// be non-zero in size. A caller must either ensure that conditions
 /// like this are met, use specific allocators with looser
-/// requirements, or use the more lenient `AllocRef` interface.)
+/// requirements, or use the more lenient `Allocator` interface.)
 #[stable(feature = "alloc_layout", since = "1.28.0")]
 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
 #[lang = "alloc_layout"]
diff --git a/library/core/src/alloc/mod.rs b/library/core/src/alloc/mod.rs
index bc874e2e522..045eb58d013 100644
--- a/library/core/src/alloc/mod.rs
+++ b/library/core/src/alloc/mod.rs
@@ -40,14 +40,14 @@ impl fmt::Display for AllocError {
     }
 }
 
-/// An implementation of `AllocRef` can allocate, grow, shrink, and deallocate arbitrary blocks of
+/// An implementation of `Allocator` can allocate, grow, shrink, and deallocate arbitrary blocks of
 /// data described via [`Layout`][].
 ///
-/// `AllocRef` is designed to be implemented on ZSTs, references, or smart pointers because having
+/// `Allocator` is designed to be implemented on ZSTs, references, or smart pointers because having
 /// an allocator like `MyAlloc([u8; N])` cannot be moved, without updating the pointers to the
 /// allocated memory.
 ///
-/// Unlike [`GlobalAlloc`][], zero-sized allocations are allowed in `AllocRef`. If an underlying
+/// Unlike [`GlobalAlloc`][], zero-sized allocations are allowed in `Allocator`. If an underlying
 /// allocator does not support this (like jemalloc) or return a null pointer (such as
 /// `libc::malloc`), this must be caught by the implementation.
 ///
@@ -56,18 +56,18 @@ impl fmt::Display for AllocError {
 /// Some of the methods require that a memory block be *currently allocated* via an allocator. This
 /// means that:
 ///
-/// * the starting address for that memory block was previously returned by [`alloc`], [`grow`], or
+/// * the starting address for that memory block was previously returned by [`allocate`], [`grow`], or
 ///   [`shrink`], and
 ///
 /// * the memory block has not been subsequently deallocated, where blocks are either deallocated
-///   directly by being passed to [`dealloc`] or were changed by being passed to [`grow`] or
+///   directly by being passed to [`deallocate`] or were changed by being passed to [`grow`] or
 ///   [`shrink`] that returns `Ok`. If `grow` or `shrink` have returned `Err`, the passed pointer
 ///   remains valid.
 ///
-/// [`alloc`]: AllocRef::alloc
-/// [`grow`]: AllocRef::grow
-/// [`shrink`]: AllocRef::shrink
-/// [`dealloc`]: AllocRef::dealloc
+/// [`allocate`]: Allocator::allocate
+/// [`grow`]: Allocator::grow
+/// [`shrink`]: Allocator::shrink
+/// [`deallocate`]: Allocator::deallocate
 ///
 /// ### Memory fitting
 ///
@@ -79,7 +79,7 @@ impl fmt::Display for AllocError {
 ///
 /// * The provided [`layout.size()`] must fall in the range `min ..= max`, where:
 ///   - `min` is the size of the layout most recently used to allocate the block, and
-///   - `max` is the latest actual size returned from [`alloc`], [`grow`], or [`shrink`].
+///   - `max` is the latest actual size returned from [`allocate`], [`grow`], or [`shrink`].
 ///
 /// [`layout.align()`]: Layout::align
 /// [`layout.size()`]: Layout::size
@@ -97,7 +97,7 @@ impl fmt::Display for AllocError {
 ///
 /// [*currently allocated*]: #currently-allocated-memory
 #[unstable(feature = "allocator_api", issue = "32838")]
-pub unsafe trait AllocRef {
+pub unsafe trait Allocator {
     /// Attempts to allocate a block of memory.
     ///
     /// On success, returns a [`NonNull<[u8]>`][NonNull] meeting the size and alignment guarantees of `layout`.
@@ -118,9 +118,9 @@ pub unsafe trait AllocRef {
     /// call the [`handle_alloc_error`] function, rather than directly invoking `panic!` or similar.
     ///
     /// [`handle_alloc_error`]: ../../alloc/alloc/fn.handle_alloc_error.html
-    fn alloc(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>;
+    fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>;
 
-    /// Behaves like `alloc`, but also ensures that the returned memory is zero-initialized.
+    /// Behaves like `allocate`, but also ensures that the returned memory is zero-initialized.
     ///
     /// # Errors
     ///
@@ -135,8 +135,8 @@ pub unsafe trait AllocRef {
     /// call the [`handle_alloc_error`] function, rather than directly invoking `panic!` or similar.
     ///
     /// [`handle_alloc_error`]: ../../alloc/alloc/fn.handle_alloc_error.html
-    fn alloc_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
-        let ptr = self.alloc(layout)?;
+    fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
+        let ptr = self.allocate(layout)?;
         // SAFETY: `alloc` returns a valid memory block
         unsafe { ptr.as_non_null_ptr().as_ptr().write_bytes(0, ptr.len()) }
         Ok(ptr)
@@ -151,7 +151,7 @@ pub unsafe trait AllocRef {
     ///
     /// [*currently allocated*]: #currently-allocated-memory
     /// [*fit*]: #memory-fitting
-    unsafe fn dealloc(&self, ptr: NonNull<u8>, layout: Layout);
+    unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout);
 
     /// Attempts to extend the memory block.
     ///
@@ -200,7 +200,7 @@ pub unsafe trait AllocRef {
             "`new_layout.size()` must be greater than or equal to `old_layout.size()`"
         );
 
-        let new_ptr = self.alloc(new_layout)?;
+        let new_ptr = self.allocate(new_layout)?;
 
         // SAFETY: because `new_layout.size()` must be greater than or equal to
         // `old_layout.size()`, both the old and new memory allocation are valid for reads and
@@ -209,7 +209,7 @@ pub unsafe trait AllocRef {
         // safe. The safety contract for `dealloc` must be upheld by the caller.
         unsafe {
             ptr::copy_nonoverlapping(ptr.as_ptr(), new_ptr.as_mut_ptr(), old_layout.size());
-            self.dealloc(ptr, old_layout);
+            self.deallocate(ptr, old_layout);
         }
 
         Ok(new_ptr)
@@ -261,7 +261,7 @@ pub unsafe trait AllocRef {
             "`new_layout.size()` must be greater than or equal to `old_layout.size()`"
         );
 
-        let new_ptr = self.alloc_zeroed(new_layout)?;
+        let new_ptr = self.allocate_zeroed(new_layout)?;
 
         // SAFETY: because `new_layout.size()` must be greater than or equal to
         // `old_layout.size()`, both the old and new memory allocation are valid for reads and
@@ -270,7 +270,7 @@ pub unsafe trait AllocRef {
         // safe. The safety contract for `dealloc` must be upheld by the caller.
         unsafe {
             ptr::copy_nonoverlapping(ptr.as_ptr(), new_ptr.as_mut_ptr(), old_layout.size());
-            self.dealloc(ptr, old_layout);
+            self.deallocate(ptr, old_layout);
         }
 
         Ok(new_ptr)
@@ -323,7 +323,7 @@ pub unsafe trait AllocRef {
             "`new_layout.size()` must be smaller than or equal to `old_layout.size()`"
         );
 
-        let new_ptr = self.alloc(new_layout)?;
+        let new_ptr = self.allocate(new_layout)?;
 
         // SAFETY: because `new_layout.size()` must be lower than or equal to
         // `old_layout.size()`, both the old and new memory allocation are valid for reads and
@@ -332,15 +332,15 @@ pub unsafe trait AllocRef {
         // safe. The safety contract for `dealloc` must be upheld by the caller.
         unsafe {
             ptr::copy_nonoverlapping(ptr.as_ptr(), new_ptr.as_mut_ptr(), new_layout.size());
-            self.dealloc(ptr, old_layout);
+            self.deallocate(ptr, old_layout);
         }
 
         Ok(new_ptr)
     }
 
-    /// Creates a "by reference" adaptor for this instance of `AllocRef`.
+    /// Creates a "by reference" adaptor for this instance of `Allocator`.
     ///
-    /// The returned adaptor also implements `AllocRef` and will simply borrow this.
+    /// The returned adaptor also implements `Allocator` and will simply borrow this.
     #[inline(always)]
     fn by_ref(&self) -> &Self {
         self
@@ -348,24 +348,24 @@ pub unsafe trait AllocRef {
 }
 
 #[unstable(feature = "allocator_api", issue = "32838")]
-unsafe impl<A> AllocRef for &A
+unsafe impl<A> Allocator for &A
 where
-    A: AllocRef + ?Sized,
+    A: Allocator + ?Sized,
 {
     #[inline]
-    fn alloc(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
-        (**self).alloc(layout)
+    fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
+        (**self).allocate(layout)
     }
 
     #[inline]
-    fn alloc_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
-        (**self).alloc_zeroed(layout)
+    fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
+        (**self).allocate_zeroed(layout)
     }
 
     #[inline]
-    unsafe fn dealloc(&self, ptr: NonNull<u8>, layout: Layout) {
+    unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) {
         // SAFETY: the safety contract must be upheld by the caller
-        unsafe { (**self).dealloc(ptr, layout) }
+        unsafe { (**self).deallocate(ptr, layout) }
     }
 
     #[inline]
diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs
index 5dc7171a7dc..d849008b880 100644
--- a/library/core/src/ptr/non_null.rs
+++ b/library/core/src/ptr/non_null.rs
@@ -439,11 +439,11 @@ impl<T> NonNull<[T]> {
     /// ```rust
     /// #![feature(allocator_api, ptr_as_uninit)]
     ///
-    /// use std::alloc::{AllocRef, Layout, Global};
+    /// use std::alloc::{Allocator, Layout, Global};
     /// use std::mem::MaybeUninit;
     /// use std::ptr::NonNull;
     ///
-    /// let memory: NonNull<[u8]> = Global.alloc(Layout::new::<[u8; 32]>())?;
+    /// let memory: NonNull<[u8]> = Global.allocate(Layout::new::<[u8; 32]>())?;
     /// // This is safe as `memory` is valid for reads and writes for `memory.len()` many bytes.
     /// // Note that calling `memory.as_mut()` is not allowed here as the content may be uninitialized.
     /// # #[allow(unused_variables)]