@@ -1324,10 +1324,8 @@ impl<T> Weak<T> {
1324
1324
1325
1325
/// Returns a raw pointer to the object `T` pointed to by this `Weak<T>`.
1326
1326
///
1327
- /// It is up to the caller to ensure that the object is still alive when accessing it through
1328
- /// the pointer.
1329
- ///
1330
- /// The pointer may be [`null`] or be dangling in case the object has already been destroyed.
1327
+ /// The pointer is valid only if there are some strong references. The pointer may be dangling
1328
+ /// or even [`null`] otherwise.
1331
1329
///
1332
1330
/// # Examples
1333
1331
///
@@ -1408,14 +1406,18 @@ impl<T> Weak<T> {
1408
1406
/// This can be used to safely get a strong reference (by calling [`upgrade`]
1409
1407
/// later) or to deallocate the weak count by dropping the `Weak<T>`.
1410
1408
///
1411
- /// It takes ownership of one weak count. In case a [`null`] is passed, a dangling [`Weak`] is
1412
- /// returned .
1409
+ /// It takes ownership of one weak count (with the exception of pointers created by [`new`],
1410
+ /// as these don't have any corresponding weak count) .
1413
1411
///
1414
1412
/// # Safety
1415
1413
///
1416
- /// The pointer must represent one valid weak count. In other words, it must point to `T` which
1417
- /// is or *was* managed by an [`Arc`] and the weak count of that [`Arc`] must not have reached
1418
- /// 0. It is allowed for the strong count to be 0.
1414
+ /// The pointer must have originated from the [`into_raw`] (or [`as_raw'], provided there was
1415
+ /// a corresponding [`forget`] on the `Weak<T>`) and must still own its potential weak reference
1416
+ /// count.
1417
+ ///
1418
+ /// It is allowed for the strong count to be 0 at the time of calling this, but the weak count
1419
+ /// must be non-zero or the pointer must have originated from a dangling `Weak<T>` (one created
1420
+ /// by [`new`]).
1419
1421
///
1420
1422
/// # Examples
1421
1423
///
@@ -1440,11 +1442,13 @@ impl<T> Weak<T> {
1440
1442
/// assert!(unsafe { Weak::from_raw(raw_2) }.upgrade().is_none());
1441
1443
/// ```
1442
1444
///
1443
- /// [`null`]: ../../std/ptr/fn.null.html
1445
+ /// [`as_raw`]: struct.Weak.html#method.as_raw
1446
+ /// [`new`]: struct.Weak.html#method.new
1444
1447
/// [`into_raw`]: struct.Weak.html#method.into_raw
1445
1448
/// [`upgrade`]: struct.Weak.html#method.upgrade
1446
1449
/// [`Weak`]: struct.Weak.html
1447
1450
/// [`Arc`]: struct.Arc.html
1451
+ /// [`forget`]: ../../std/mem/fn.forget.html
1448
1452
#[ unstable( feature = "weak_into_raw" , issue = "60728" ) ]
1449
1453
pub unsafe fn from_raw ( ptr : * const T ) -> Self {
1450
1454
if ptr. is_null ( ) {
0 commit comments