Skip to content

Commit 96650fc

Browse files
committed
Clarify and restrict when {Arc,Rc}::get_mut_unchecked is allowed.
1 parent fd3bfb3 commit 96650fc

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

library/alloc/src/rc.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1091,10 +1091,11 @@ impl<T: ?Sized> Rc<T> {
10911091
///
10921092
/// # Safety
10931093
///
1094-
/// Any other `Rc` or [`Weak`] pointers to the same allocation must not be dereferenced
1095-
/// for the duration of the returned borrow.
1096-
/// This is trivially the case if no such pointers exist,
1097-
/// for example immediately after `Rc::new`.
1094+
/// If any other `Rc` or [`Weak`] pointers to the same allocation exist, then
1095+
/// they must be must not be dereferenced or have active borrows for the duration
1096+
/// of the returned borrow, and their inner type must be exactly the same as the
1097+
/// inner type of this Rc (including lifetimes). This is trivially the case if no
1098+
/// such pointers exist, for example immediately after `Rc::new`.
10981099
///
10991100
/// # Examples
11001101
///

library/alloc/src/sync.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1630,10 +1630,11 @@ impl<T: ?Sized> Arc<T> {
16301630
///
16311631
/// # Safety
16321632
///
1633-
/// Any other `Arc` or [`Weak`] pointers to the same allocation must not be dereferenced
1634-
/// for the duration of the returned borrow.
1635-
/// This is trivially the case if no such pointers exist,
1636-
/// for example immediately after `Arc::new`.
1633+
/// If any other `Arc` or [`Weak`] pointers to the same allocation exist, then
1634+
/// they must be must not be dereferenced or have active borrows for the duration
1635+
/// of the returned borrow, and their inner type must be exactly the same as the
1636+
/// inner type of this Rc (including lifetimes). This is trivially the case if no
1637+
/// such pointers exist, for example immediately after `Arc::new`.
16371638
///
16381639
/// # Examples
16391640
///

0 commit comments

Comments
 (0)