@@ -233,25 +233,30 @@ impl<T: ?Sized> *mut T {
233233 }
234234
235235 /// Returns `None` if the pointer is null, or else returns a shared reference to
236- /// the value wrapped in `Some`. If the value may be uninitialized, [`as_uninit_ref`]
237- /// must be used instead.
236+ /// the value wrapped in `Some`.
238237 ///
239238 /// For the mutable counterpart see [`as_mut`].
240239 ///
241- /// [`as_uninit_ref`]: pointer#method.as_uninit_ref-1
242240 /// [`as_mut`]: #method.as_mut
243241 ///
244242 /// # Safety
245243 ///
246- /// When calling this method, you have to ensure that *either* the pointer is null *or*
247- /// the pointer is [convertible to a reference](crate::ptr#pointer-to-reference-conversion).
244+ /// When calling this method, you have to ensure that:
245+ ///
246+ /// * *Either* the pointer is null *or* the pointer is [convertible to a reference](crate::ptr#pointer-to-reference-conversion).
247+ ///
248+ /// * The value of memory pointed by the ptr must be initialized. If not, [`as_uninit_ref`] must be used instead.
249+ ///
250+ /// * Note that after obtaining the reference, the original pointer must not
251+ /// be mutated until the reference's lifetime ends (except inside `UnsafeCell`).
248252 ///
249253 /// # Panics during const evaluation
250254 ///
251255 /// This method will panic during const evaluation if the pointer cannot be
252256 /// determined to be null or not. See [`is_null`] for more information.
253257 ///
254258 /// [`is_null`]: #method.is_null-1
259+ /// [`as_uninit_ref`]: pointer#method.as_uninit_ref-1
255260 ///
256261 /// # Examples
257262 ///
@@ -289,18 +294,25 @@ impl<T: ?Sized> *mut T {
289294 }
290295
291296 /// Returns a shared reference to the value behind the pointer.
292- /// If the pointer may be null or the value may be uninitialized, [`as_uninit_ref`] must be used instead.
293- /// If the pointer may be null, but the value is known to have been initialized, [`as_ref`] must be used instead.
294297 ///
295298 /// For the mutable counterpart see [`as_mut_unchecked`].
296299 ///
297- /// [`as_ref`]: #method.as_ref
298- /// [`as_uninit_ref`]: #method.as_uninit_ref
299300 /// [`as_mut_unchecked`]: #method.as_mut_unchecked
300301 ///
301302 /// # Safety
302303 ///
303- /// When calling this method, you have to ensure that the pointer is [convertible to a reference](crate::ptr#pointer-to-reference-conversion).
304+ /// When calling this method, you have to ensure that:
305+ ///
306+ /// * The pointer is [convertible to a reference](crate::ptr#pointer-to-reference-conversion).
307+ ///
308+ /// * If the pointer may be null or the value may be uninitialized, [`as_uninit_ref`] must be used instead.
309+ /// If the pointer may be null, but the value is known to have been initialized, [`as_ref`] must be used instead.
310+ ///
311+ /// * Note that after obtaining the reference, the original pointer must not
312+ /// be mutated until the reference's lifetime ends (except inside `UnsafeCell`).
313+ ///
314+ /// [`as_ref`]: #method.as_ref
315+ /// [`as_uninit_ref`]: #method.as_uninit_ref
304316 ///
305317 /// # Examples
306318 ///
@@ -332,10 +344,10 @@ impl<T: ?Sized> *mut T {
332344 ///
333345 /// # Safety
334346 ///
335- /// When calling this method, you have to ensure that *either* the pointer is null *or*
336- /// the pointer is [convertible to a reference](crate::ptr#pointer-to-reference-conversion).
337- /// Note that because the created reference is to `MaybeUninit<T>`, the
338- /// source pointer can point to uninitialized memory .
347+ /// * The pointer is [convertible to a reference](crate::ptr# pointer-to-reference-conversion).
348+ ///
349+ /// * Note that after obtaining the reference, the original pointer must not
350+ /// be mutated until the reference's lifetime ends (except inside `UnsafeCell`) .
339351 ///
340352 /// # Panics during const evaluation
341353 ///
@@ -607,7 +619,8 @@ impl<T: ?Sized> *mut T {
607619 ///
608620 /// * The value of memory pointed by the ptr must be initialized. If not, [`as_uninit_mut`] must be used instead.
609621 ///
610- /// * Note that multiple calls to this API may create multiple mutable references simultaneously, violating the exclusive mutable reference principle.
622+ /// * Note that after obtaining the mutable reference, the original pointer
623+ /// must not be used to access the data until the reference's lifetime ends.
611624 ///
612625 /// # Panics during const evaluation
613626 ///
@@ -653,19 +666,25 @@ impl<T: ?Sized> *mut T {
653666 }
654667
655668 /// Returns a unique reference to the value behind the pointer.
656- /// If the pointer may be null or the value may be uninitialized, [`as_uninit_mut`] must be used instead.
657- /// If the pointer may be null, but the value is known to have been initialized, [`as_mut`] must be used instead.
658669 ///
659670 /// For the shared counterpart see [`as_ref_unchecked`].
660671 ///
661- /// [`as_mut`]: #method.as_mut
662- /// [`as_uninit_mut`]: #method.as_uninit_mut
663672 /// [`as_ref_unchecked`]: #method.as_mut_unchecked
664673 ///
665674 /// # Safety
666675 ///
667- /// When calling this method, you have to ensure that
668- /// the pointer is [convertible to a reference](crate::ptr#pointer-to-reference-conversion).
676+ /// When calling this method, you have to ensure that:
677+ ///
678+ /// * The pointer is [convertible to a reference](crate::ptr#pointer-to-reference-conversion).
679+ ///
680+ /// * If the pointer may be null or the value may be uninitialized, [`as_uninit_mut`] must be used instead.
681+ /// If the pointer may be null, but the value is known to have been initialized, [`as_mut`] must be used instead.
682+ ///
683+ /// * Note that after obtaining the mutable reference, the original pointer
684+ /// must not be used to access the data until the reference's lifetime ends.
685+ ///
686+ /// [`as_mut`]: #method.as_mut
687+ /// [`as_uninit_mut`]: #method.as_uninit_mut
669688 ///
670689 /// # Examples
671690 ///
@@ -698,8 +717,10 @@ impl<T: ?Sized> *mut T {
698717 ///
699718 /// # Safety
700719 ///
701- /// When calling this method, you have to ensure that *either* the pointer is null *or*
702- /// the pointer is [convertible to a reference](crate::ptr#pointer-to-reference-conversion).
720+ /// * The pointer is [convertible to a reference](crate::ptr#pointer-to-reference-conversion).
721+ ///
722+ /// * Note that after obtaining the mutable reference, the original pointer must not
723+ /// be used to access the data until the reference's lifetime ends.
703724 ///
704725 /// # Panics during const evaluation
705726 ///
0 commit comments