diff options
| author | Zachary S <zasample18+github@gmail.com> | 2022-09-02 01:34:34 -0500 |
|---|---|---|
| committer | Zachary S <zasample18+github@gmail.com> | 2022-11-18 12:50:41 -0600 |
| commit | 96650fc7143dbacdbb3711e2d60f06401e727cea (patch) | |
| tree | 7836f2927ccdb8cd7fcfc857f9dc56beac4778ac | |
| parent | fd3bfb35511cbcff59ce1454d3db627b576d7e92 (diff) | |
| download | rust-96650fc7143dbacdbb3711e2d60f06401e727cea.tar.gz rust-96650fc7143dbacdbb3711e2d60f06401e727cea.zip | |
Clarify and restrict when `{Arc,Rc}::get_mut_unchecked` is allowed.
| -rw-r--r-- | library/alloc/src/rc.rs | 9 | ||||
| -rw-r--r-- | library/alloc/src/sync.rs | 9 |
2 files changed, 10 insertions, 8 deletions
diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index f3cbfe27b3e..1e9ed3889e8 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -1091,10 +1091,11 @@ impl<T: ?Sized> Rc<T> { /// /// # Safety /// - /// Any other `Rc` or [`Weak`] pointers to the same allocation must not be dereferenced - /// for the duration of the returned borrow. - /// This is trivially the case if no such pointers exist, - /// for example immediately after `Rc::new`. + /// If any other `Rc` or [`Weak`] pointers to the same allocation exist, then + /// they must be must not be dereferenced or have active borrows for the duration + /// of the returned borrow, and their inner type must be exactly the same as the + /// inner type of this Rc (including lifetimes). This is trivially the case if no + /// such pointers exist, for example immediately after `Rc::new`. /// /// # Examples /// diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 37e07eb5998..2bb5030c51e 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -1630,10 +1630,11 @@ impl<T: ?Sized> Arc<T> { /// /// # Safety /// - /// Any other `Arc` or [`Weak`] pointers to the same allocation must not be dereferenced - /// for the duration of the returned borrow. - /// This is trivially the case if no such pointers exist, - /// for example immediately after `Arc::new`. + /// If any other `Arc` or [`Weak`] pointers to the same allocation exist, then + /// they must be must not be dereferenced or have active borrows for the duration + /// of the returned borrow, and their inner type must be exactly the same as the + /// inner type of this Rc (including lifetimes). This is trivially the case if no + /// such pointers exist, for example immediately after `Arc::new`. /// /// # Examples /// |
