Skip to content

Commit b79ce1b

Browse files
committed
Rename private helper method allocate_for_unsized to allocate_for_layout
1 parent ba03283 commit b79ce1b

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/liballoc/rc.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ impl<T> Rc<T> {
351351
#[unstable(feature = "new_uninit", issue = "63291")]
352352
pub fn new_uninit() -> Rc<mem::MaybeUninit<T>> {
353353
unsafe {
354-
Rc::from_ptr(Rc::allocate_for_unsized(
354+
Rc::from_ptr(Rc::allocate_for_layout(
355355
Layout::new::<T>(),
356356
|mem| mem as *mut RcBox<mem::MaybeUninit<T>>,
357357
))
@@ -880,11 +880,11 @@ impl Rc<dyn Any> {
880880

881881
impl<T: ?Sized> Rc<T> {
882882
/// Allocates an `RcBox<T>` with sufficient space for
883-
/// an unsized value where the value has the layout provided.
883+
/// a possibly-unsized value where the value has the layout provided.
884884
///
885885
/// The function `mem_to_rcbox` is called with the data pointer
886886
/// and must return back a (potentially fat)-pointer for the `RcBox<T>`.
887-
unsafe fn allocate_for_unsized(
887+
unsafe fn allocate_for_layout(
888888
value_layout: Layout,
889889
mem_to_rcbox: impl FnOnce(*mut u8) -> *mut RcBox<T>
890890
) -> *mut RcBox<T> {
@@ -913,7 +913,7 @@ impl<T: ?Sized> Rc<T> {
913913
/// Allocates an `RcBox<T>` with sufficient space for an unsized value
914914
unsafe fn allocate_for_ptr(ptr: *const T) -> *mut RcBox<T> {
915915
// Allocate for the `RcBox<T>` using the given value.
916-
Self::allocate_for_unsized(
916+
Self::allocate_for_layout(
917917
Layout::for_value(&*ptr),
918918
|mem| set_data_ptr(ptr as *mut T, mem) as *mut RcBox<T>,
919919
)
@@ -944,7 +944,7 @@ impl<T: ?Sized> Rc<T> {
944944
impl<T> Rc<[T]> {
945945
/// Allocates an `RcBox<[T]>` with the given length.
946946
unsafe fn allocate_for_slice(len: usize) -> *mut RcBox<[T]> {
947-
Self::allocate_for_unsized(
947+
Self::allocate_for_layout(
948948
Layout::array::<T>(len).unwrap(),
949949
|mem| ptr::slice_from_raw_parts_mut(mem as *mut T, len) as *mut RcBox<[T]>,
950950
)

src/liballoc/sync.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ impl<T> Arc<T> {
335335
#[unstable(feature = "new_uninit", issue = "63291")]
336336
pub fn new_uninit() -> Arc<mem::MaybeUninit<T>> {
337337
unsafe {
338-
Arc::from_ptr(Arc::allocate_for_unsized(
338+
Arc::from_ptr(Arc::allocate_for_layout(
339339
Layout::new::<T>(),
340340
|mem| mem as *mut ArcInner<mem::MaybeUninit<T>>,
341341
))
@@ -736,11 +736,11 @@ impl<T: ?Sized> Arc<T> {
736736

737737
impl<T: ?Sized> Arc<T> {
738738
/// Allocates an `ArcInner<T>` with sufficient space for
739-
/// an unsized value where the value has the layout provided.
739+
/// a possibly-unsized value where the value has the layout provided.
740740
///
741741
/// The function `mem_to_arcinner` is called with the data pointer
742742
/// and must return back a (potentially fat)-pointer for the `ArcInner<T>`.
743-
unsafe fn allocate_for_unsized(
743+
unsafe fn allocate_for_layout(
744744
value_layout: Layout,
745745
mem_to_arcinner: impl FnOnce(*mut u8) -> *mut ArcInner<T>
746746
) -> *mut ArcInner<T> {
@@ -768,7 +768,7 @@ impl<T: ?Sized> Arc<T> {
768768
/// Allocates an `ArcInner<T>` with sufficient space for an unsized value.
769769
unsafe fn allocate_for_ptr(ptr: *const T) -> *mut ArcInner<T> {
770770
// Allocate for the `ArcInner<T>` using the given value.
771-
Self::allocate_for_unsized(
771+
Self::allocate_for_layout(
772772
Layout::for_value(&*ptr),
773773
|mem| set_data_ptr(ptr as *mut T, mem) as *mut ArcInner<T>,
774774
)
@@ -799,7 +799,7 @@ impl<T: ?Sized> Arc<T> {
799799
impl<T> Arc<[T]> {
800800
/// Allocates an `ArcInner<[T]>` with the given length.
801801
unsafe fn allocate_for_slice(len: usize) -> *mut ArcInner<[T]> {
802-
Self::allocate_for_unsized(
802+
Self::allocate_for_layout(
803803
Layout::array::<T>(len).unwrap(),
804804
|mem| ptr::slice_from_raw_parts_mut(mem as *mut T, len) as *mut ArcInner<[T]>,
805805
)

0 commit comments

Comments
 (0)