Skip to content

Commit 0a9c87b

Browse files
committed
rename RcBox in other places too
1 parent 159e67d commit 0a9c87b

File tree

9 files changed

+25
-26
lines changed

9 files changed

+25
-26
lines changed

compiler/rustc_codegen_ssa/src/mir/block.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -992,10 +992,10 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
992992
match op.val {
993993
Pair(data_ptr, meta) => {
994994
// In the case of Rc<Self>, we need to explicitly pass a
995-
// *mut RcBox<Self> with a Scalar (not ScalarPair) ABI. This is a hack
995+
// *mut RcInner<Self> with a Scalar (not ScalarPair) ABI. This is a hack
996996
// that is understood elsewhere in the compiler as a method on
997997
// `dyn Trait`.
998-
// To get a `*mut RcBox<Self>`, we just keep unwrapping newtypes until
998+
// To get a `*mut RcInner<Self>`, we just keep unwrapping newtypes until
999999
// we get a value of a built-in pointer type.
10001000
//
10011001
// This is also relevant for `Pin<&mut Self>`, where we need to peel the

compiler/rustc_ty_utils/src/abi.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -822,10 +822,10 @@ fn make_thin_self_ptr<'tcx>(
822822
_ => bug!("receiver type has unsupported layout: {:?}", layout),
823823
}
824824

825-
// In the case of Rc<Self>, we need to explicitly pass a *mut RcBox<Self>
825+
// In the case of Rc<Self>, we need to explicitly pass a *mut RcInner<Self>
826826
// with a Scalar (not ScalarPair) ABI. This is a hack that is understood
827827
// elsewhere in the compiler as a method on a `dyn Trait`.
828-
// To get the type `*mut RcBox<Self>`, we just keep unwrapping newtypes until we
828+
// To get the type `*mut RcInner<Self>`, we just keep unwrapping newtypes until we
829829
// get a built-in pointer type
830830
let mut wide_pointer_layout = layout;
831831
while !wide_pointer_layout.ty.is_unsafe_ptr() && !wide_pointer_layout.ty.is_ref() {
@@ -838,7 +838,7 @@ fn make_thin_self_ptr<'tcx>(
838838
wide_pointer_layout.ty
839839
};
840840

841-
// we now have a type like `*mut RcBox<dyn Trait>`
841+
// we now have a type like `*mut RcInner<dyn Trait>`
842842
// change its layout to that of `*mut ()`, a thin pointer, but keep the same type
843843
// this is understood as a special case elsewhere in the compiler
844844
let unit_ptr_ty = Ty::new_mut_ptr(tcx, tcx.types.unit);

library/alloc/src/sync.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ pub struct Weak<
319319
// but it is not necessarily a valid pointer.
320320
// `Weak::new` sets this to `usize::MAX` so that it doesn’t need
321321
// to allocate space on the heap. That's not a value a real pointer
322-
// will ever have because RcBox has alignment at least 2.
322+
// will ever have because RcInner has alignment at least 2.
323323
// This is only possible when `T: Sized`; unsized `T` never dangle.
324324
ptr: NonNull<ArcInner<T>>,
325325
alloc: A,
@@ -1581,7 +1581,7 @@ impl<T: ?Sized, A: Allocator> Arc<T, A> {
15811581
pub fn as_ptr(this: &Self) -> *const T {
15821582
let ptr: *mut ArcInner<T> = NonNull::as_ptr(this.ptr);
15831583

1584-
// SAFETY: This cannot go through Deref::deref or RcBoxPtr::inner because
1584+
// SAFETY: This cannot go through Deref::deref or RcInnerPtr::inner because
15851585
// this is required to retain raw/mut provenance such that e.g. `get_mut` can
15861586
// write through the pointer after the Rc is recovered through `from_raw`.
15871587
unsafe { &raw mut (*ptr).data }
@@ -2936,7 +2936,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
29362936
// Otherwise, we're guaranteed the pointer came from a nondangling Weak.
29372937
// SAFETY: data_offset is safe to call, as ptr references a real (potentially dropped) T.
29382938
let offset = unsafe { data_offset(ptr) };
2939-
// Thus, we reverse the offset to get the whole RcBox.
2939+
// Thus, we reverse the offset to get the whole RcInner.
29402940
// SAFETY: the pointer originated from a Weak, so this offset is safe.
29412941
unsafe { ptr.byte_sub(offset) as *mut ArcInner<T> }
29422942
};
@@ -3861,7 +3861,7 @@ impl<T: ?Sized, A: Allocator> Unpin for Arc<T, A> {}
38613861
/// valid instance of T, but the T is allowed to be dropped.
38623862
unsafe fn data_offset<T: ?Sized>(ptr: *const T) -> usize {
38633863
// Align the unsized value to the end of the ArcInner.
3864-
// Because RcBox is repr(C), it will always be the last field in memory.
3864+
// Because RcInner is repr(C), it will always be the last field in memory.
38653865
// SAFETY: since the only unsized types possible are slices, trait objects,
38663866
// and extern types, the input safety requirement is currently enough to
38673867
// satisfy the requirements of align_of_val_raw; this is an implementation

library/core/src/cell.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,11 @@
193193
//! use std::marker::PhantomData;
194194
//!
195195
//! struct Rc<T: ?Sized> {
196-
//! ptr: NonNull<RcBox<T>>,
197-
//! phantom: PhantomData<RcBox<T>>,
196+
//! ptr: NonNull<RcInner<T>>,
197+
//! phantom: PhantomData<RcInner<T>>,
198198
//! }
199199
//!
200-
//! struct RcBox<T: ?Sized> {
200+
//! struct RcInner<T: ?Sized> {
201201
//! strong: Cell<usize>,
202202
//! refcount: Cell<usize>,
203203
//! value: T,
@@ -213,9 +213,9 @@
213213
//! }
214214
//! }
215215
//!
216-
//! trait RcBoxPtr<T: ?Sized> {
216+
//! trait RcInnerPtr<T: ?Sized> {
217217
//!
218-
//! fn inner(&self) -> &RcBox<T>;
218+
//! fn inner(&self) -> &RcInner<T>;
219219
//!
220220
//! fn strong(&self) -> usize {
221221
//! self.inner().strong.get()
@@ -230,8 +230,8 @@
230230
//! }
231231
//! }
232232
//!
233-
//! impl<T: ?Sized> RcBoxPtr<T> for Rc<T> {
234-
//! fn inner(&self) -> &RcBox<T> {
233+
//! impl<T: ?Sized> RcInnerPtr<T> for Rc<T> {
234+
//! fn inner(&self) -> &RcInner<T> {
235235
//! unsafe {
236236
//! self.ptr.as_ref()
237237
//! }

src/etc/lldb_providers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -670,11 +670,11 @@ def StdRcSummaryProvider(valobj, dict):
670670
class StdRcSyntheticProvider:
671671
"""Pretty-printer for alloc::rc::Rc<T> and alloc::sync::Arc<T>
672672
673-
struct Rc<T> { ptr: NonNull<RcBox<T>>, ... }
673+
struct Rc<T> { ptr: NonNull<RcInner<T>>, ... }
674674
rust 1.31.1: struct NonNull<T> { pointer: NonZero<*const T> }
675675
rust 1.33.0: struct NonNull<T> { pointer: *const T }
676676
struct NonZero<T>(T)
677-
struct RcBox<T> { strong: Cell<usize>, weak: Cell<usize>, value: T }
677+
struct RcInner<T> { strong: Cell<usize>, weak: Cell<usize>, value: T }
678678
struct Cell<T> { value: UnsafeCell<T> }
679679
struct UnsafeCell<T> { value: T }
680680

src/etc/natvis/liballoc.natvis

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
<Item Name="[Weak reference count]">ptr.pointer.data_ptr->weak</Item>
9696
<ArrayItems>
9797
<Size>ptr.pointer.length</Size>
98-
<!-- We add +2 to the data_ptr in order to skip the ref count fields in the RcBox -->
98+
<!-- We add +2 to the data_ptr in order to skip the ref count fields in the RcInner -->
9999
<ValuePointer>($T1*)(((size_t*)ptr.pointer.data_ptr) + 2)</ValuePointer>
100100
</ArrayItems>
101101
</Expand>

src/tools/miri/tests/fail/memleak_rc.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: memory leaked: ALLOC (Rust heap, SIZE, ALIGN), allocated here:
22
--> RUSTLIB/alloc/src/rc.rs:LL:CC
33
|
4-
LL | Box::leak(Box::new(RcBox { strong: Cell::new(1), weak: Cell::new(1), value }))
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4+
LL | Box::leak(Box::new(RcInner { strong: Cell::new(1), weak: Cell::new(1), value }))
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: BACKTRACE:
88
= note: inside `std::rc::Rc::<std::cell::RefCell<std::option::Option<Dummy>>>::new` at RUSTLIB/alloc/src/rc.rs:LL:CC

tests/debuginfo/strings-and-strs.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
// gdb-check:$4 = ("Hello", "World")
2020

2121
// gdb-command:print str_in_rc
22-
// gdb-check:$5 = alloc::rc::Rc<&str, alloc::alloc::Global> {ptr: core::ptr::non_null::NonNull<alloc::rc::RcBox<&str>> {pointer: 0x[...]}, phantom: core::marker::PhantomData<alloc::rc::RcBox<&str>>, alloc: alloc::alloc::Global}
23-
22+
// gdb-check:$5 = alloc::rc::Rc<&str, alloc::alloc::Global> {ptr: core::ptr::non_null::NonNull<alloc::rc::RcInner<&str>> {pointer: 0x[...]}, phantom: core::marker::PhantomData<alloc::rc::RcInner<&str>>, alloc: alloc::alloc::Global}
2423

2524
// === LLDB TESTS ==================================================================================
2625
// lldb-command:run

tests/ui/abi/compatibility.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,14 @@ mod prelude {
160160
pub struct Box<T: ?Sized, A = Global>(Unique<T>, A);
161161

162162
#[repr(C)]
163-
struct RcBox<T: ?Sized> {
163+
struct RcInner<T: ?Sized> {
164164
strong: UnsafeCell<usize>,
165165
weak: UnsafeCell<usize>,
166166
value: T,
167167
}
168168
pub struct Rc<T: ?Sized, A = Global> {
169-
ptr: NonNull<RcBox<T>>,
170-
phantom: PhantomData<RcBox<T>>,
169+
ptr: NonNull<RcInner<T>>,
170+
phantom: PhantomData<RcInner<T>>,
171171
alloc: A,
172172
}
173173

0 commit comments

Comments
 (0)