@@ -2776,8 +2776,16 @@ impl<T: ?Sized> Weak<T> {
2776
2776
///
2777
2777
/// # Safety
2778
2778
///
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.
2781
2789
///
2782
2790
/// It is allowed for the strong count to be 0 at the time of calling this. Nevertheless, this
2783
2791
/// takes ownership of one weak reference currently represented as a raw pointer (the weak
@@ -2806,6 +2814,7 @@ impl<T: ?Sized> Weak<T> {
2806
2814
/// ```
2807
2815
///
2808
2816
/// [`into_raw`]: Weak::into_raw
2817
+ /// [`into_raw_and_alloc`]: Weak::into_raw_and_alloc
2809
2818
/// [`upgrade`]: Weak::upgrade
2810
2819
/// [`new`]: Weak::new
2811
2820
#[ inline]
@@ -2942,8 +2951,16 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
2942
2951
///
2943
2952
/// # Safety
2944
2953
///
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.
2947
2964
///
2948
2965
/// It is allowed for the strong count to be 0 at the time of calling this. Nevertheless, this
2949
2966
/// 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> {
2972
2989
/// ```
2973
2990
///
2974
2991
/// [`into_raw`]: Weak::into_raw
2992
+ /// [`into_raw_and_alloc`]: Weak::into_raw_and_alloc
2975
2993
/// [`upgrade`]: Weak::upgrade
2976
2994
/// [`new`]: Weak::new
2977
2995
#[ inline]
0 commit comments