From 5829560a68d4bf5e29edfed0f9545d24e87ac3f5 Mon Sep 17 00:00:00 2001 From: Jacob Hughes Date: Thu, 24 Sep 2020 18:10:56 -0400 Subject: Rename AllocErr to AllocError --- library/alloc/src/alloc.rs | 20 ++++++++++---------- library/alloc/src/raw_vec/tests.rs | 6 +++--- library/alloc/src/rc.rs | 4 ++-- library/alloc/src/sync.rs | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) (limited to 'library/alloc/src') diff --git a/library/alloc/src/alloc.rs b/library/alloc/src/alloc.rs index 8b8cdbf2525..75158eefcac 100644 --- a/library/alloc/src/alloc.rs +++ b/library/alloc/src/alloc.rs @@ -145,13 +145,13 @@ pub unsafe fn alloc_zeroed(layout: Layout) -> *mut u8 { impl Global { #[inline] - fn alloc_impl(&self, layout: Layout, zeroed: bool) -> Result, AllocErr> { + fn alloc_impl(&self, layout: Layout, zeroed: bool) -> Result, AllocError> { match layout.size() { 0 => Ok(NonNull::slice_from_raw_parts(layout.dangling(), 0)), // SAFETY: `layout` is non-zero in size, size => unsafe { let raw_ptr = if zeroed { alloc_zeroed(layout) } else { alloc(layout) }; - let ptr = NonNull::new(raw_ptr).ok_or(AllocErr)?; + let ptr = NonNull::new(raw_ptr).ok_or(AllocError)?; Ok(NonNull::slice_from_raw_parts(ptr, size)) }, } @@ -165,7 +165,7 @@ impl Global { old_layout: Layout, new_layout: Layout, zeroed: bool, - ) -> Result, AllocErr> { + ) -> Result, AllocError> { debug_assert!( new_layout.size() >= old_layout.size(), "`new_layout.size()` must be greater than or equal to `old_layout.size()`" @@ -183,7 +183,7 @@ impl Global { intrinsics::assume(new_size >= old_layout.size()); let raw_ptr = realloc(ptr.as_ptr(), old_layout, new_size); - let ptr = NonNull::new(raw_ptr).ok_or(AllocErr)?; + let ptr = NonNull::new(raw_ptr).ok_or(AllocError)?; if zeroed { raw_ptr.add(old_size).write_bytes(0, new_size - old_size); } @@ -208,12 +208,12 @@ impl Global { #[unstable(feature = "allocator_api", issue = "32838")] unsafe impl AllocRef for Global { #[inline] - fn alloc(&self, layout: Layout) -> Result, AllocErr> { + fn alloc(&self, layout: Layout) -> Result, AllocError> { self.alloc_impl(layout, false) } #[inline] - fn alloc_zeroed(&self, layout: Layout) -> Result, AllocErr> { + fn alloc_zeroed(&self, layout: Layout) -> Result, AllocError> { self.alloc_impl(layout, true) } @@ -232,7 +232,7 @@ unsafe impl AllocRef for Global { ptr: NonNull, old_layout: Layout, new_layout: Layout, - ) -> Result, AllocErr> { + ) -> Result, AllocError> { // SAFETY: all conditions must be upheld by the caller unsafe { self.grow_impl(ptr, old_layout, new_layout, false) } } @@ -243,7 +243,7 @@ unsafe impl AllocRef for Global { ptr: NonNull, old_layout: Layout, new_layout: Layout, - ) -> Result, AllocErr> { + ) -> Result, AllocError> { // SAFETY: all conditions must be upheld by the caller unsafe { self.grow_impl(ptr, old_layout, new_layout, true) } } @@ -254,7 +254,7 @@ unsafe impl AllocRef for Global { ptr: NonNull, old_layout: Layout, new_layout: Layout, - ) -> Result, AllocErr> { + ) -> Result, AllocError> { debug_assert!( new_layout.size() <= old_layout.size(), "`new_layout.size()` must be smaller than or equal to `old_layout.size()`" @@ -273,7 +273,7 @@ unsafe impl AllocRef for Global { intrinsics::assume(new_size <= old_layout.size()); let raw_ptr = realloc(ptr.as_ptr(), old_layout, new_size); - let ptr = NonNull::new(raw_ptr).ok_or(AllocErr)?; + let ptr = NonNull::new(raw_ptr).ok_or(AllocError)?; Ok(NonNull::slice_from_raw_parts(ptr, new_size)) }, diff --git a/library/alloc/src/raw_vec/tests.rs b/library/alloc/src/raw_vec/tests.rs index e4c8b3709df..cb4fe1b46cd 100644 --- a/library/alloc/src/raw_vec/tests.rs +++ b/library/alloc/src/raw_vec/tests.rs @@ -3,7 +3,7 @@ use std::cell::Cell; #[test] fn allocator_param() { - use crate::alloc::AllocErr; + use crate::alloc::AllocError; // Writing a test of integration between third-party // allocators and `RawVec` is a little tricky because the `RawVec` @@ -21,10 +21,10 @@ fn allocator_param() { fuel: Cell, } unsafe impl AllocRef for BoundedAlloc { - fn alloc(&self, layout: Layout) -> Result, AllocErr> { + fn alloc(&self, layout: Layout) -> Result, AllocError> { let size = layout.size(); if size > self.fuel.get() { - return Err(AllocErr); + return Err(AllocError); } match Global.alloc(layout) { ok @ Ok(_) => { diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index f998e49dcfc..5dbc42cc97d 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -247,7 +247,7 @@ use core::pin::Pin; use core::ptr::{self, NonNull}; use core::slice::from_raw_parts_mut; -use crate::alloc::{box_free, handle_alloc_error, AllocErr, AllocRef, Global, Layout}; +use crate::alloc::{box_free, handle_alloc_error, AllocError, AllocRef, Global, Layout}; use crate::borrow::{Cow, ToOwned}; use crate::string::String; use crate::vec::Vec; @@ -996,7 +996,7 @@ impl Rc { /// and must return back a (potentially fat)-pointer for the `RcBox`. unsafe fn allocate_for_layout( value_layout: Layout, - allocate: impl FnOnce(Layout) -> Result, AllocErr>, + allocate: impl FnOnce(Layout) -> Result, AllocError>, mem_to_rcbox: impl FnOnce(*mut u8) -> *mut RcBox, ) -> *mut RcBox { // Calculate layout using the given value layout. diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 6a240fbb42a..3d7411c79dc 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -21,7 +21,7 @@ use core::slice::from_raw_parts_mut; use core::sync::atomic; use core::sync::atomic::Ordering::{Acquire, Relaxed, Release, SeqCst}; -use crate::alloc::{box_free, handle_alloc_error, AllocErr, AllocRef, Global, Layout}; +use crate::alloc::{box_free, handle_alloc_error, AllocError, AllocRef, Global, Layout}; use crate::borrow::{Cow, ToOwned}; use crate::boxed::Box; use crate::rc::is_dangling; @@ -969,7 +969,7 @@ impl Arc { /// and must return back a (potentially fat)-pointer for the `ArcInner`. unsafe fn allocate_for_layout( value_layout: Layout, - allocate: impl FnOnce(Layout) -> Result, AllocErr>, + allocate: impl FnOnce(Layout) -> Result, AllocError>, mem_to_arcinner: impl FnOnce(*mut u8) -> *mut ArcInner, ) -> *mut ArcInner { // Calculate layout using the given value layout. -- cgit 1.4.1-3-g733a5