Skip to content

Commit fba9038

Browse files
committed
Fix parameter order for allocator
1 parent 8293713 commit fba9038

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

library/alloc/src/rc.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,12 @@ use crate::vec::Vec;
274274
#[cfg(test)]
275275
mod tests;
276276

277-
struct RcBoxMetadata {
277+
struct RcMetadata {
278278
strong: Cell<usize>,
279279
weak: Cell<usize>,
280280
}
281281

282-
impl RcBoxMetadata {
282+
impl RcMetadata {
283283
// There is an implicit weak pointer owned by all the strong
284284
// pointers, which ensures that the weak destructor never frees
285285
// the allocation while the strong destructor is running, even
@@ -300,7 +300,7 @@ impl RcBoxMetadata {
300300
// inner types.
301301
#[repr(C)]
302302
struct RcBox<T: ?Sized> {
303-
meta: RcBoxMetadata,
303+
meta: RcMetadata,
304304
value: T,
305305
}
306306

@@ -363,7 +363,7 @@ impl<T> Rc<T> {
363363
/// ```
364364
#[stable(feature = "rust1", since = "1.0.0")]
365365
pub fn new(value: T) -> Rc<T> {
366-
Self::from_inner(Box::leak(box RcBox { meta: RcBoxMetadata::new_strong(), value }).into())
366+
Self::from_inner(Box::leak(box RcBox { meta: RcMetadata::new_strong(), value }).into())
367367
}
368368

369369
/// Constructs a new `Rc<T>` using a weak reference to itself. Attempting
@@ -395,7 +395,7 @@ impl<T> Rc<T> {
395395
// Construct the inner in the "uninitialized" state with a single
396396
// weak reference.
397397
let uninit_ptr: NonNull<_> = Box::leak(box RcBox {
398-
meta: RcBoxMetadata::new_weak(),
398+
meta: RcMetadata::new_weak(),
399399
value: mem::MaybeUninit::<T>::uninit(),
400400
})
401401
.into();
@@ -510,7 +510,7 @@ impl<T> Rc<T> {
510510
// the allocation while the strong destructor is running, even
511511
// if the weak pointer is stored inside the strong one.
512512
Ok(Self::from_inner(
513-
Box::leak(Box::try_new(RcBox { meta: RcBoxMetadata::new_strong(), value })?).into(),
513+
Box::leak(Box::try_new(RcBox { meta: RcMetadata::new_strong(), value })?).into(),
514514
))
515515
}
516516

@@ -2479,7 +2479,7 @@ impl<T: ?Sized> AsRef<T> for Rc<T> {
24792479
#[stable(feature = "pin", since = "1.33.0")]
24802480
impl<T: ?Sized> Unpin for Rc<T> {}
24812481

2482-
type RcAllocator = PrefixAllocator<RcBoxMetadata, Global>;
2482+
type RcAllocator = PrefixAllocator<Global, RcMetadata>;
24832483

24842484
/// Get the offset within an `RcBox` for the payload behind a pointer.
24852485
///

library/alloc/src/sync.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ impl<T: ?Sized + fmt::Debug> fmt::Debug for Weak<T> {
297297
}
298298
}
299299

300-
struct ArcInnerMetadata {
300+
struct ArcMetadata {
301301
strong: atomic::AtomicUsize,
302302

303303
// the value usize::MAX acts as a sentinel for temporarily "locking" the
@@ -306,7 +306,7 @@ struct ArcInnerMetadata {
306306
weak: atomic::AtomicUsize,
307307
}
308308

309-
impl ArcInnerMetadata {
309+
impl ArcMetadata {
310310
#[inline]
311311
fn new_strong() -> Self {
312312
Self { strong: atomic::AtomicUsize::new(1), weak: atomic::AtomicUsize::new(1) }
@@ -323,7 +323,7 @@ impl ArcInnerMetadata {
323323
// inner types.
324324
#[repr(C)]
325325
struct ArcInner<T: ?Sized> {
326-
meta: ArcInnerMetadata,
326+
meta: ArcMetadata,
327327
data: T,
328328
}
329329

@@ -343,7 +343,7 @@ impl<T> Arc<T> {
343343
#[inline]
344344
#[stable(feature = "rust1", since = "1.0.0")]
345345
pub fn new(data: T) -> Arc<T> {
346-
let x: Box<_> = box ArcInner { meta: ArcInnerMetadata::new_strong(), data };
346+
let x: Box<_> = box ArcInner { meta: ArcMetadata::new_strong(), data };
347347
Self::from_inner(Box::leak(x).into())
348348
}
349349

@@ -373,7 +373,7 @@ impl<T> Arc<T> {
373373
// Construct the inner in the "uninitialized" state with a single
374374
// weak reference.
375375
let uninit_ptr: NonNull<_> = Box::leak(box ArcInner {
376-
meta: ArcInnerMetadata::new_weak(),
376+
meta: ArcMetadata::new_weak(),
377377
data: mem::MaybeUninit::<T>::uninit(),
378378
})
379379
.into();
@@ -503,7 +503,7 @@ impl<T> Arc<T> {
503503
#[unstable(feature = "allocator_api", issue = "32838")]
504504
#[inline]
505505
pub fn try_new(data: T) -> Result<Arc<T>, AllocError> {
506-
let x: Box<_> = Box::try_new(ArcInner { meta: ArcInnerMetadata::new_strong(), data })?;
506+
let x: Box<_> = Box::try_new(ArcInner { meta: ArcMetadata::new_strong(), data })?;
507507
Ok(Self::from_inner(Box::leak(x).into()))
508508
}
509509

@@ -2521,7 +2521,7 @@ impl<T: ?Sized> AsRef<T> for Arc<T> {
25212521
#[stable(feature = "pin", since = "1.33.0")]
25222522
impl<T: ?Sized> Unpin for Arc<T> {}
25232523

2524-
type ArcAllocator = PrefixAllocator<ArcInnerMetadata, Global>;
2524+
type ArcAllocator = PrefixAllocator<Global, ArcMetadata>;
25252525

25262526
/// Get the offset within an `ArcInner` for the payload behind a pointer.
25272527
///

0 commit comments

Comments
 (0)