@@ -12,14 +12,17 @@ impl<T: ?Sized> *mut T {
12
12
/// Therefore, two pointers that are null may still not compare equal to
13
13
/// each other.
14
14
///
15
- /// ## Behavior during const evaluation
15
+ /// # Panics during const evaluation
16
16
///
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.
23
26
///
24
27
/// # Examples
25
28
///
@@ -243,6 +246,13 @@ impl<T: ?Sized> *mut T {
243
246
/// When calling this method, you have to ensure that *either* the pointer is null *or*
244
247
/// the pointer is [convertible to a reference](crate::ptr#pointer-to-reference-conversion).
245
248
///
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
+ ///
246
256
/// # Examples
247
257
///
248
258
/// ```
@@ -327,6 +337,13 @@ impl<T: ?Sized> *mut T {
327
337
/// Note that because the created reference is to `MaybeUninit<T>`, the
328
338
/// source pointer can point to uninitialized memory.
329
339
///
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
+ ///
330
347
/// # Examples
331
348
///
332
349
/// ```
@@ -590,6 +607,12 @@ impl<T: ?Sized> *mut T {
590
607
/// the pointer is null *or*
591
608
/// the pointer is [convertible to a reference](crate::ptr#pointer-to-reference-conversion).
592
609
///
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
593
616
///
594
617
/// # Examples
595
618
///
@@ -673,6 +696,13 @@ impl<T: ?Sized> *mut T {
673
696
///
674
697
/// When calling this method, you have to ensure that *either* the pointer is null *or*
675
698
/// 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
676
706
#[ inline]
677
707
#[ unstable( feature = "ptr_as_uninit" , issue = "75402" ) ]
678
708
pub const unsafe fn as_uninit_mut < ' a > ( self ) -> Option < & ' a mut MaybeUninit < T > >
@@ -1949,6 +1979,13 @@ impl<T> *mut [T] {
1949
1979
///
1950
1980
/// [valid]: crate::ptr#safety
1951
1981
/// [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
1952
1989
#[ inline]
1953
1990
#[ unstable( feature = "ptr_as_uninit" , issue = "75402" ) ]
1954
1991
pub const unsafe fn as_uninit_slice < ' a > ( self ) -> Option < & ' a [ MaybeUninit < T > ] > {
@@ -2000,6 +2037,13 @@ impl<T> *mut [T] {
2000
2037
///
2001
2038
/// [valid]: crate::ptr#safety
2002
2039
/// [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
2003
2047
#[ inline]
2004
2048
#[ unstable( feature = "ptr_as_uninit" , issue = "75402" ) ]
2005
2049
pub const unsafe fn as_uninit_slice_mut < ' a > ( self ) -> Option < & ' a mut [ MaybeUninit < T > ] > {
0 commit comments