Skip to content

Commit

Permalink
rename RcBox in other places too
Browse files Browse the repository at this point in the history
  • Loading branch information
jdonszelmann committed Oct 11, 2024
1 parent cd0a8f5 commit 34f7831
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions alloc/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ pub struct Weak<
// but it is not necessarily a valid pointer.
// `Weak::new` sets this to `usize::MAX` so that it doesn’t need
// to allocate space on the heap. That's not a value a real pointer
// will ever have because RcBox has alignment at least 2.
// will ever have because RcInner has alignment at least 2.
// This is only possible when `T: Sized`; unsized `T` never dangle.
ptr: NonNull<ArcInner<T>>,
alloc: A,
Expand Down Expand Up @@ -1581,7 +1581,7 @@ impl<T: ?Sized, A: Allocator> Arc<T, A> {
pub fn as_ptr(this: &Self) -> *const T {
let ptr: *mut ArcInner<T> = NonNull::as_ptr(this.ptr);

// SAFETY: This cannot go through Deref::deref or RcBoxPtr::inner because
// SAFETY: This cannot go through Deref::deref or RcInnerPtr::inner because
// this is required to retain raw/mut provenance such that e.g. `get_mut` can
// write through the pointer after the Rc is recovered through `from_raw`.
unsafe { &raw mut (*ptr).data }
Expand Down Expand Up @@ -2936,7 +2936,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
// Otherwise, we're guaranteed the pointer came from a nondangling Weak.
// SAFETY: data_offset is safe to call, as ptr references a real (potentially dropped) T.
let offset = unsafe { data_offset(ptr) };
// Thus, we reverse the offset to get the whole RcBox.
// Thus, we reverse the offset to get the whole RcInner.
// SAFETY: the pointer originated from a Weak, so this offset is safe.
unsafe { ptr.byte_sub(offset) as *mut ArcInner<T> }
};
Expand Down Expand Up @@ -3861,7 +3861,7 @@ impl<T: ?Sized, A: Allocator> Unpin for Arc<T, A> {}
/// valid instance of T, but the T is allowed to be dropped.
unsafe fn data_offset<T: ?Sized>(ptr: *const T) -> usize {
// Align the unsized value to the end of the ArcInner.
// Because RcBox is repr(C), it will always be the last field in memory.
// Because RcInner is repr(C), it will always be the last field in memory.
// SAFETY: since the only unsized types possible are slices, trait objects,
// and extern types, the input safety requirement is currently enough to
// satisfy the requirements of align_of_val_raw; this is an implementation
Expand Down
14 changes: 7 additions & 7 deletions core/src/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,11 @@
//! use std::marker::PhantomData;
//!
//! struct Rc<T: ?Sized> {
//! ptr: NonNull<RcBox<T>>,
//! phantom: PhantomData<RcBox<T>>,
//! ptr: NonNull<RcInner<T>>,
//! phantom: PhantomData<RcInner<T>>,
//! }
//!
//! struct RcBox<T: ?Sized> {
//! struct RcInner<T: ?Sized> {
//! strong: Cell<usize>,
//! refcount: Cell<usize>,
//! value: T,
Expand All @@ -213,9 +213,9 @@
//! }
//! }
//!
//! trait RcBoxPtr<T: ?Sized> {
//! trait RcInnerPtr<T: ?Sized> {
//!
//! fn inner(&self) -> &RcBox<T>;
//! fn inner(&self) -> &RcInner<T>;
//!
//! fn strong(&self) -> usize {
//! self.inner().strong.get()
Expand All @@ -230,8 +230,8 @@
//! }
//! }
//!
//! impl<T: ?Sized> RcBoxPtr<T> for Rc<T> {
//! fn inner(&self) -> &RcBox<T> {
//! impl<T: ?Sized> RcInnerPtr<T> for Rc<T> {
//! fn inner(&self) -> &RcInner<T> {
//! unsafe {
//! self.ptr.as_ref()
//! }
Expand Down

0 comments on commit 34f7831

Please sign in to comment.