about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-12-04 20:07:04 +0000
committerbors <bors@rust-lang.org>2020-12-04 20:07:04 +0000
commit3ff10e74a74ed093fcabac1de27fe1cd65bbbb4a (patch)
tree13efed968ba1fcd1ca8a4ceeb2fdd3c5297863ae /library/std/src
parent2218520b8adf8b8e64b817537d9eb0a84840e2f1 (diff)
parent9274b37d99f608e5fde569788ee79bd72fc3cf13 (diff)
Auto merge of #79286 - TimDiekmann:rename-allocref, r=Lokathor,Wodann,m-ou-se
Rename `AllocRef` to `Allocator` and `(de)alloc` to `(de)allocate`

Calling `Box::alloc_ref` and `Vec::alloc_ref` sounds like allocating a reference. To solve this ambiguity, this renames `AllocRef` to `Allocator` and `alloc` to `allocate`. For a more detailed explaination see https://github.com/rust-lang/wg-allocators/issues/76.

closes https://github.com/rust-lang/wg-allocators/issues/76

r? `@KodrAus`
`@rustbot` modify labels: +A-allocators +T-libs
`@rustbot` ping wg-allocators
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/alloc.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/library/std/src/alloc.rs b/library/std/src/alloc.rs
index 375b015ccc8..819d57a934d 100644
--- a/library/std/src/alloc.rs
+++ b/library/std/src/alloc.rs
@@ -149,7 +149,7 @@ impl System {
         }
     }
 
-    // SAFETY: Same as `AllocRef::grow`
+    // SAFETY: Same as `Allocator::grow`
     #[inline]
     unsafe fn grow_impl(
         &self,
@@ -190,29 +190,29 @@ impl System {
             old_size => unsafe {
                 let new_ptr = self.alloc_impl(new_layout, zeroed)?;
                 ptr::copy_nonoverlapping(ptr.as_ptr(), new_ptr.as_mut_ptr(), old_size);
-                AllocRef::dealloc(&self, ptr, old_layout);
+                Allocator::deallocate(&self, ptr, old_layout);
                 Ok(new_ptr)
             },
         }
     }
 }
 
-// The AllocRef impl checks the layout size to be non-zero and forwards to the GlobalAlloc impl,
+// The Allocator impl checks the layout size to be non-zero and forwards to the GlobalAlloc impl,
 // which is in `std::sys::*::alloc`.
 #[unstable(feature = "allocator_api", issue = "32838")]
-unsafe impl AllocRef for System {
+unsafe impl Allocator for System {
     #[inline]
-    fn alloc(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
+    fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
         self.alloc_impl(layout, false)
     }
 
     #[inline]
-    fn alloc_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
+    fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
         self.alloc_impl(layout, true)
     }
 
     #[inline]
-    unsafe fn dealloc(&self, ptr: NonNull<u8>, layout: Layout) {
+    unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) {
         if layout.size() != 0 {
             // SAFETY: `layout` is non-zero in size,
             // other conditions must be upheld by the caller
@@ -257,7 +257,7 @@ unsafe impl AllocRef for System {
         match new_layout.size() {
             // SAFETY: conditions must be upheld by the caller
             0 => unsafe {
-                AllocRef::dealloc(&self, ptr, old_layout);
+                Allocator::deallocate(&self, ptr, old_layout);
                 Ok(NonNull::slice_from_raw_parts(new_layout.dangling(), 0))
             },
 
@@ -277,9 +277,9 @@ unsafe impl AllocRef for System {
             // `new_ptr`. Thus, the call to `copy_nonoverlapping` is safe. The safety contract
             // for `dealloc` must be upheld by the caller.
             new_size => unsafe {
-                let new_ptr = AllocRef::alloc(&self, new_layout)?;
+                let new_ptr = Allocator::allocate(&self, new_layout)?;
                 ptr::copy_nonoverlapping(ptr.as_ptr(), new_ptr.as_mut_ptr(), new_size);
-                AllocRef::dealloc(&self, ptr, old_layout);
+                Allocator::deallocate(&self, ptr, old_layout);
                 Ok(new_ptr)
             },
         }