about summary refs log tree commit diff
diff options
context:
space:
mode:
authorwoppopo <woppopo@protonmail.com>2022-01-23 23:04:39 +0900
committerwoppopo <woppopo@protonmail.com>2022-01-23 23:04:39 +0900
commit5e97fc9aa265cb523a16cbe035c638eb35257cf5 (patch)
treefd388791ac7f8136f42e8870c9f195c987ddc385
parent16c1a9dd7cd497b050bc957cdfa54f8d3d6e97f2 (diff)
downloadrust-5e97fc9aa265cb523a16cbe035c638eb35257cf5.tar.gz
rust-5e97fc9aa265cb523a16cbe035c638eb35257cf5.zip
Make `NonNull::new` `const`
-rw-r--r--library/core/src/ptr/non_null.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs
index 3a7e99faccf..3f5d3f62c96 100644
--- a/library/core/src/ptr/non_null.rs
+++ b/library/core/src/ptr/non_null.rs
@@ -211,8 +211,9 @@ impl<T: ?Sized> NonNull<T> {
     /// }
     /// ```
     #[stable(feature = "nonnull", since = "1.25.0")]
+    #[rustc_const_unstable(feature = "const_nonnull_new", issue = "93235")]
     #[inline]
-    pub fn new(ptr: *mut T) -> Option<Self> {
+    pub const fn new(ptr: *mut T) -> Option<Self> {
         if !ptr.is_null() {
             // SAFETY: The pointer is already checked and is not null
             Some(unsafe { Self::new_unchecked(ptr) })