@@ -2776,8 +2776,16 @@ impl<T: ?Sized> Weak<T> {
27762776 ///
27772777 /// # Safety
27782778 ///
2779- /// The pointer must have originated from the [`into_raw`] and must still own its potential
2780- /// weak reference, and `ptr` must point to a block of memory allocated by the global allocator.
2779+ /// The pointer must have originated from the [`into_raw`] or [`into_raw_and_alloc`] functions
2780+ /// and must still own its potential weak reference, and `ptr` must point to a block of
2781+ /// memory allocated by `alloc`.
2782+ ///
2783+ /// Note that `from_raw` expects values that actually originated from a call to one of these
2784+ /// functions and have not been used with `from_raw` yet, not what these functions can maybe
2785+ /// return, or are documented to potentially return.
2786+ /// For example, [`into_raw`] can return dangling pointers, but this doesn't allow you to create
2787+ /// a dangling pointer yourself and pass it to `from_raw`. Even if it has the same address
2788+ /// as a pointer created by [`into_raw`], use [`Weak::new`] instead.
27812789 ///
27822790 /// It is allowed for the strong count to be 0 at the time of calling this. Nevertheless, this
27832791 /// takes ownership of one weak reference currently represented as a raw pointer (the weak
@@ -2806,6 +2814,7 @@ impl<T: ?Sized> Weak<T> {
28062814 /// ```
28072815 ///
28082816 /// [`into_raw`]: Weak::into_raw
2817+ /// [`into_raw_and_alloc`]: Weak::into_raw_and_alloc
28092818 /// [`upgrade`]: Weak::upgrade
28102819 /// [`new`]: Weak::new
28112820 #[ inline]
@@ -2942,8 +2951,16 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
29422951 ///
29432952 /// # Safety
29442953 ///
2945- /// The pointer must have originated from the [`into_raw`] and must still own its potential
2946- /// weak reference, and `ptr` must point to a block of memory allocated by `alloc`.
2954+ /// The pointer must have originated from the [`into_raw`] or [`into_raw_and_alloc`] functions
2955+ /// and must still own its potential weak reference, and `ptr` must point to a block of
2956+ /// memory allocated by `alloc`.
2957+ ///
2958+ /// Note that `from_raw` expects values that actually originated from a call to one of these
2959+ /// functions and have not been used with `from_raw` yet, not what these functions can maybe
2960+ /// return, or are documented to potentially return.
2961+ /// For example, [`into_raw`] can return dangling pointers, but this doesn't allow you to create
2962+ /// a dangling pointer yourself and pass it to `from_raw`. Even if it has the same address
2963+ /// as a pointer created by [`into_raw`], use [`Weak::new`] instead.
29472964 ///
29482965 /// It is allowed for the strong count to be 0 at the time of calling this. Nevertheless, this
29492966 /// takes ownership of one weak reference currently represented as a raw pointer (the weak
@@ -2972,6 +2989,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
29722989 /// ```
29732990 ///
29742991 /// [`into_raw`]: Weak::into_raw
2992+ /// [`into_raw_and_alloc`]: Weak::into_raw_and_alloc
29752993 /// [`upgrade`]: Weak::upgrade
29762994 /// [`new`]: Weak::new
29772995 #[ inline]
0 commit comments