From 5e97fc9aa265cb523a16cbe035c638eb35257cf5 Mon Sep 17 00:00:00 2001 From: woppopo Date: Sun, 23 Jan 2022 23:04:39 +0900 Subject: [PATCH] Make `NonNull::new` `const` --- library/core/src/ptr/non_null.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 NonNull { /// } /// ``` #[stable(feature = "nonnull", since = "1.25.0")] + #[rustc_const_unstable(feature = "const_nonnull_new", issue = "93235")] #[inline] - pub fn new(ptr: *mut T) -> Option { + pub const fn new(ptr: *mut T) -> Option { if !ptr.is_null() { // SAFETY: The pointer is already checked and is not null Some(unsafe { Self::new_unchecked(ptr) })