@@ -12,14 +12,17 @@ impl<T: ?Sized> *mut T {
1212 /// Therefore, two pointers that are null may still not compare equal to
1313 /// each other.
1414 ///
15- /// ## Behavior during const evaluation
15+ /// # Panics during const evaluation
1616 ///
17- /// When this function is used during const evaluation, it may return `false` for pointers
18- /// that turn out to be null at runtime. Specifically, when a pointer to some memory
19- /// is offset beyond its bounds in such a way that the resulting pointer is null,
20- /// the function will still return `false`. There is no way for CTFE to know
21- /// the absolute position of that memory, so we cannot tell if the pointer is
22- /// null or not.
17+ /// If this method is used during const evaluation, and `self` is a pointer
18+ /// that is offset beyond the bounds of the memory it initially pointed to,
19+ /// then there might not be enough information to determine whether the
20+ /// pointer is null. This is because the absolute address in memory is not
21+ /// known at compile time. If the nullness of the pointer cannot be
22+ /// determined, this method will panic.
23+ ///
24+ /// In-bounds pointers are never null, so the method will never panic for
25+ /// such pointers.
2326 ///
2427 /// # Examples
2528 ///
@@ -243,6 +246,13 @@ impl<T: ?Sized> *mut T {
243246 /// When calling this method, you have to ensure that *either* the pointer is null *or*
244247 /// the pointer is [convertible to a reference](crate::ptr#pointer-to-reference-conversion).
245248 ///
249+ /// # Panics during const evaluation
250+ ///
251+ /// This method will panic during const evaluation if the pointer cannot be
252+ /// determined to be null or not. See [`is_null`] for more information.
253+ ///
254+ /// [`is_null`]: #method.is_null-1
255+ ///
246256 /// # Examples
247257 ///
248258 /// ```
@@ -327,6 +337,13 @@ impl<T: ?Sized> *mut T {
327337 /// Note that because the created reference is to `MaybeUninit<T>`, the
328338 /// source pointer can point to uninitialized memory.
329339 ///
340+ /// # Panics during const evaluation
341+ ///
342+ /// This method will panic during const evaluation if the pointer cannot be
343+ /// determined to be null or not. See [`is_null`] for more information.
344+ ///
345+ /// [`is_null`]: #method.is_null-1
346+ ///
330347 /// # Examples
331348 ///
332349 /// ```
@@ -590,6 +607,12 @@ impl<T: ?Sized> *mut T {
590607 /// the pointer is null *or*
591608 /// the pointer is [convertible to a reference](crate::ptr#pointer-to-reference-conversion).
592609 ///
610+ /// # Panics during const evaluation
611+ ///
612+ /// This method will panic during const evaluation if the pointer cannot be
613+ /// determined to be null or not. See [`is_null`] for more information.
614+ ///
615+ /// [`is_null`]: #method.is_null-1
593616 ///
594617 /// # Examples
595618 ///
@@ -673,6 +696,13 @@ impl<T: ?Sized> *mut T {
673696 ///
674697 /// When calling this method, you have to ensure that *either* the pointer is null *or*
675698 /// the pointer is [convertible to a reference](crate::ptr#pointer-to-reference-conversion).
699+ ///
700+ /// # Panics during const evaluation
701+ ///
702+ /// This method will panic during const evaluation if the pointer cannot be
703+ /// determined to be null or not. See [`is_null`] for more information.
704+ ///
705+ /// [`is_null`]: #method.is_null-1
676706 #[ inline]
677707 #[ unstable( feature = "ptr_as_uninit" , issue = "75402" ) ]
678708 pub const unsafe fn as_uninit_mut < ' a > ( self ) -> Option < & ' a mut MaybeUninit < T > >
@@ -1949,6 +1979,13 @@ impl<T> *mut [T] {
19491979 ///
19501980 /// [valid]: crate::ptr#safety
19511981 /// [allocated object]: crate::ptr#allocated-object
1982+ ///
1983+ /// # Panics during const evaluation
1984+ ///
1985+ /// This method will panic during const evaluation if the pointer cannot be
1986+ /// determined to be null or not. See [`is_null`] for more information.
1987+ ///
1988+ /// [`is_null`]: #method.is_null-1
19521989 #[ inline]
19531990 #[ unstable( feature = "ptr_as_uninit" , issue = "75402" ) ]
19541991 pub const unsafe fn as_uninit_slice < ' a > ( self ) -> Option < & ' a [ MaybeUninit < T > ] > {
@@ -2000,6 +2037,13 @@ impl<T> *mut [T] {
20002037 ///
20012038 /// [valid]: crate::ptr#safety
20022039 /// [allocated object]: crate::ptr#allocated-object
2040+ ///
2041+ /// # Panics during const evaluation
2042+ ///
2043+ /// This method will panic during const evaluation if the pointer cannot be
2044+ /// determined to be null or not. See [`is_null`] for more information.
2045+ ///
2046+ /// [`is_null`]: #method.is_null-1
20032047 #[ inline]
20042048 #[ unstable( feature = "ptr_as_uninit" , issue = "75402" ) ]
20052049 pub const unsafe fn as_uninit_slice_mut < ' a > ( self ) -> Option < & ' a mut [ MaybeUninit < T > ] > {
0 commit comments