@@ -1295,10 +1295,8 @@ impl<T> Weak<T> {
1295
1295
1296
1296
/// Returns a raw pointer to the object `T` pointed to by this `Weak<T>`.
1297
1297
///
1298
- /// It is up to the caller to ensure that the object is still alive when accessing it through
1299
- /// the pointer.
1300
- ///
1301
- /// The pointer may be [`null`] or be dangling in case the object has already been destroyed.
1298
+ /// The pointer is valid only if there are some strong references. The pointer may be dangling
1299
+ /// or even [`null`] otherwise.
1302
1300
///
1303
1301
/// # Examples
1304
1302
///
@@ -1379,14 +1377,18 @@ impl<T> Weak<T> {
1379
1377
/// This can be used to safely get a strong reference (by calling [`upgrade`]
1380
1378
/// later) or to deallocate the weak count by dropping the `Weak<T>`.
1381
1379
///
1382
- /// It takes ownership of one weak count. In case a [`null`] is passed, a dangling [`Weak`] is
1383
- /// returned .
1380
+ /// It takes ownership of one weak count (with the exception of pointers created by [`new`],
1381
+ /// as these don't have any corresponding weak count) .
1384
1382
///
1385
1383
/// # Safety
1386
1384
///
1387
- /// The pointer must represent one valid weak count. In other words, it must point to `T` which
1388
- /// is or *was* managed by an [`Arc`] and the weak count of that [`Arc`] must not have reached
1389
- /// 0. It is allowed for the strong count to be 0.
1385
+ /// The pointer must have originated from the [`into_raw`] (or [`as_raw'], provided there was
1386
+ /// a corresponding [`forget`] on the `Weak<T>`) and must still own its potential weak reference
1387
+ /// count.
1388
+ ///
1389
+ /// It is allowed for the strong count to be 0 at the time of calling this, but the weak count
1390
+ /// must be non-zero or the pointer must have originated from a dangling `Weak<T>` (one created
1391
+ /// by [`new`]).
1390
1392
///
1391
1393
/// # Examples
1392
1394
///
@@ -1411,11 +1413,13 @@ impl<T> Weak<T> {
1411
1413
/// assert!(unsafe { Weak::from_raw(raw_2) }.upgrade().is_none());
1412
1414
/// ```
1413
1415
///
1414
- /// [`null`]: ../../std/ptr/fn.null.html
1416
+ /// [`as_raw`]: struct.Weak.html#method.as_raw
1417
+ /// [`new`]: struct.Weak.html#method.new
1415
1418
/// [`into_raw`]: struct.Weak.html#method.into_raw
1416
1419
/// [`upgrade`]: struct.Weak.html#method.upgrade
1417
1420
/// [`Weak`]: struct.Weak.html
1418
1421
/// [`Arc`]: struct.Arc.html
1422
+ /// [`forget`]: ../../std/mem/fn.forget.html
1419
1423
#[ unstable( feature = "weak_into_raw" , issue = "60728" ) ]
1420
1424
pub unsafe fn from_raw ( ptr : * const T ) -> Self {
1421
1425
if ptr. is_null ( ) {
0 commit comments