diff --git a/alloc/src/rc.rs b/alloc/src/rc.rs index e6f27f5363999..e98ae7c31ad06 100644 --- a/alloc/src/rc.rs +++ b/alloc/src/rc.rs @@ -289,7 +289,7 @@ struct RcInner { } /// Calculate layout for `RcInner` using the inner value's layout -fn rcbox_layout_for_value_layout(layout: Layout) -> Layout { +fn rc_inner_layout_for_value_layout(layout: Layout) -> Layout { // Calculate layout using the given value layout. // Previously, layout was calculated on the expression // `&*(ptr as *const RcInner)`, but this created a misaligned @@ -2009,17 +2009,17 @@ impl Rc { /// Allocates an `RcInner` with sufficient space for /// a possibly-unsized inner value where the value has the layout provided. /// - /// The function `mem_to_rcbox` is called with the data pointer + /// The function `mem_to_rc_inner` is called with the data pointer /// and must return back a (potentially fat)-pointer for the `RcInner`. #[cfg(not(no_global_oom_handling))] unsafe fn allocate_for_layout( value_layout: Layout, allocate: impl FnOnce(Layout) -> Result, AllocError>, - mem_to_rcbox: impl FnOnce(*mut u8) -> *mut RcInner, + mem_to_rc_inner: impl FnOnce(*mut u8) -> *mut RcInner, ) -> *mut RcInner { - let layout = rcbox_layout_for_value_layout(value_layout); + let layout = rc_inner_layout_for_value_layout(value_layout); unsafe { - Rc::try_allocate_for_layout(value_layout, allocate, mem_to_rcbox) + Rc::try_allocate_for_layout(value_layout, allocate, mem_to_rc_inner) .unwrap_or_else(|_| handle_alloc_error(layout)) } } @@ -2028,21 +2028,21 @@ impl Rc { /// a possibly-unsized inner value where the value has the layout provided, /// returning an error if allocation fails. /// - /// The function `mem_to_rcbox` is called with the data pointer + /// The function `mem_to_rc_inner` is called with the data pointer /// and must return back a (potentially fat)-pointer for the `RcInner`. #[inline] unsafe fn try_allocate_for_layout( value_layout: Layout, allocate: impl FnOnce(Layout) -> Result, AllocError>, - mem_to_rcbox: impl FnOnce(*mut u8) -> *mut RcInner, + mem_to_rc_inner: impl FnOnce(*mut u8) -> *mut RcInner, ) -> Result<*mut RcInner, AllocError> { - let layout = rcbox_layout_for_value_layout(value_layout); + let layout = rc_inner_layout_for_value_layout(value_layout); // Allocate for the layout. let ptr = allocate(layout)?; // Initialize the RcInner - let inner = mem_to_rcbox(ptr.as_non_null_ptr().as_ptr()); + let inner = mem_to_rc_inner(ptr.as_non_null_ptr().as_ptr()); unsafe { debug_assert_eq!(Layout::for_value_raw(inner), layout); @@ -3784,7 +3784,7 @@ impl UniqueRcUninit { let ptr = unsafe { Rc::allocate_for_layout( layout, - |layout_for_rcbox| alloc.allocate(layout_for_rcbox), + |layout_for_rc_inner| alloc.allocate(layout_for_rc_inner), |mem| mem.with_metadata_of(ptr::from_ref(for_value) as *const RcInner), ) }; @@ -3820,10 +3820,10 @@ impl Drop for UniqueRcUninit { // * new() produced a pointer safe to deallocate. // * We own the pointer unless into_rc() was called, which forgets us. unsafe { - self.alloc - .take() - .unwrap() - .deallocate(self.ptr.cast(), rcbox_layout_for_value_layout(self.layout_for_value)); + self.alloc.take().unwrap().deallocate( + self.ptr.cast(), + rc_inner_layout_for_value_layout(self.layout_for_value), + ); } } }