Skip to content

Commit 52a31f7

Browse files
committed
some more Rc tweaks
1 parent 696cba6 commit 52a31f7

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/liballoc/rc.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
//! to an [`Rc`], but this will return [`None`] if the value stored in the allocation has
2626
//! already been dropped. In other words, `Weak` pointers do not keep the value
2727
//! inside the allocation alive; however, they *do* keep the allocation
28-
//! (the backing store for the value) alive.
28+
//! (the backing store for the inner value) alive.
2929
//!
3030
//! A cycle between [`Rc`] pointers will never be deallocated. For this reason,
3131
//! [`Weak`] is used to break cycles. For example, a tree could have strong
@@ -44,8 +44,8 @@
4444
//! Rc::downgrade(&my_rc);
4545
//! ```
4646
//!
47-
//! [`Weak<T>`][`Weak`] does not auto-dereference to `T`, because the allocation may have
48-
//! already been destroyed.
47+
//! [`Weak<T>`][`Weak`] does not auto-dereference to `T`, because the inner value may have
48+
//! already been dropped.
4949
//!
5050
//! # Cloning references
5151
//!
@@ -449,7 +449,7 @@ impl<T> Rc<mem::MaybeUninit<T>> {
449449
/// # Safety
450450
///
451451
/// As with [`MaybeUninit::assume_init`],
452-
/// it is up to the caller to guarantee that the value
452+
/// it is up to the caller to guarantee that the inner value
453453
/// really is in an initialized state.
454454
/// Calling this when the content is not yet fully initialized
455455
/// causes immediate undefined behavior.
@@ -488,7 +488,7 @@ impl<T> Rc<[mem::MaybeUninit<T>]> {
488488
/// # Safety
489489
///
490490
/// As with [`MaybeUninit::assume_init`],
491-
/// it is up to the caller to guarantee that the value
491+
/// it is up to the caller to guarantee that the inner value
492492
/// really is in an initialized state.
493493
/// Calling this when the content is not yet fully initialized
494494
/// causes immediate undefined behavior.
@@ -883,7 +883,7 @@ impl Rc<dyn Any> {
883883

884884
impl<T: ?Sized> Rc<T> {
885885
/// Allocates an `RcBox<T>` with sufficient space for
886-
/// a possibly-unsized value where the value has the layout provided.
886+
/// a possibly-unsized inner value where the value has the layout provided.
887887
///
888888
/// The function `mem_to_rcbox` is called with the data pointer
889889
/// and must return back a (potentially fat)-pointer for the `RcBox<T>`.
@@ -913,7 +913,7 @@ impl<T: ?Sized> Rc<T> {
913913
inner
914914
}
915915

916-
/// Allocates an `RcBox<T>` with sufficient space for an unsized value
916+
/// Allocates an `RcBox<T>` with sufficient space for an unsized inner value
917917
unsafe fn allocate_for_ptr(ptr: *const T) -> *mut RcBox<T> {
918918
// Allocate for the `RcBox<T>` using the given value.
919919
Self::allocate_for_layout(
@@ -1177,6 +1177,8 @@ impl<T: ?Sized + PartialEq> RcEqIdent<T> for Rc<T> {
11771177
/// store large values, that are slow to clone, but also heavy to check for equality, causing this
11781178
/// cost to pay off more easily. It's also more likely to have two `Rc` clones, that point to
11791179
/// the same value, than two `&T`s.
1180+
///
1181+
/// We can only do this when `T: Eq` as a `PartialEq` might be deliberately irreflexive.
11801182
#[stable(feature = "rust1", since = "1.0.0")]
11811183
impl<T: ?Sized + Eq> RcEqIdent<T> for Rc<T> {
11821184
#[inline]
@@ -1759,10 +1761,10 @@ pub(crate) fn is_dangling<T: ?Sized>(ptr: NonNull<T>) -> bool {
17591761
}
17601762

17611763
impl<T: ?Sized> Weak<T> {
1762-
/// Attempts to upgrade the `Weak` pointer to an [`Rc`], extending
1763-
/// the lifetime of the allocation if successful.
1764+
/// Attempts to upgrade the `Weak` pointer to an [`Rc`], delaying
1765+
/// dropping of the inner value if successful.
17641766
///
1765-
/// Returns [`None`] if the value stored in the allocation has since been dropped.
1767+
/// Returns [`None`] if the inner value has since been dropped.
17661768
///
17671769
/// [`Rc`]: struct.Rc.html
17681770
/// [`None`]: ../../std/option/enum.Option.html

0 commit comments

Comments
 (0)