@@ -122,7 +122,8 @@ impl<T: Sized> NonNull<T> {
122122 #[ inline]
123123 #[ must_use]
124124 #[ unstable( feature = "ptr_as_uninit" , issue = "75402" ) ]
125- pub unsafe fn as_uninit_ref < ' a > ( & self ) -> & ' a MaybeUninit < T > {
125+ #[ rustc_const_unstable( feature = "const_ptr_as_ref" , issue = "91822" ) ]
126+ pub const unsafe fn as_uninit_ref < ' a > ( & self ) -> & ' a MaybeUninit < T > {
126127 // SAFETY: the caller must guarantee that `self` meets all the
127128 // requirements for a reference.
128129 unsafe { & * self . cast ( ) . as_ptr ( ) }
@@ -155,7 +156,8 @@ impl<T: Sized> NonNull<T> {
155156 #[ inline]
156157 #[ must_use]
157158 #[ unstable( feature = "ptr_as_uninit" , issue = "75402" ) ]
158- pub unsafe fn as_uninit_mut < ' a > ( & mut self ) -> & ' a mut MaybeUninit < T > {
159+ #[ rustc_const_unstable( feature = "const_ptr_as_ref" , issue = "91822" ) ]
160+ pub const unsafe fn as_uninit_mut < ' a > ( & mut self ) -> & ' a mut MaybeUninit < T > {
159161 // SAFETY: the caller must guarantee that `self` meets all the
160162 // requirements for a reference.
161163 unsafe { & mut * self . cast ( ) . as_ptr ( ) }
@@ -316,9 +318,10 @@ impl<T: ?Sized> NonNull<T> {
316318 ///
317319 /// [the module documentation]: crate::ptr#safety
318320 #[ stable( feature = "nonnull" , since = "1.25.0" ) ]
321+ #[ rustc_const_unstable( feature = "const_ptr_as_ref" , issue = "91822" ) ]
319322 #[ must_use]
320323 #[ inline]
321- pub unsafe fn as_ref < ' a > ( & self ) -> & ' a T {
324+ pub const unsafe fn as_ref < ' a > ( & self ) -> & ' a T {
322325 // SAFETY: the caller must guarantee that `self` meets all the
323326 // requirements for a reference.
324327 unsafe { & * self . as_ptr ( ) }
@@ -366,9 +369,10 @@ impl<T: ?Sized> NonNull<T> {
366369 ///
367370 /// [the module documentation]: crate::ptr#safety
368371 #[ stable( feature = "nonnull" , since = "1.25.0" ) ]
372+ #[ rustc_const_unstable( feature = "const_ptr_as_ref" , issue = "91822" ) ]
369373 #[ must_use]
370374 #[ inline]
371- pub unsafe fn as_mut < ' a > ( & mut self ) -> & ' a mut T {
375+ pub const unsafe fn as_mut < ' a > ( & mut self ) -> & ' a mut T {
372376 // SAFETY: the caller must guarantee that `self` meets all the
373377 // requirements for a mutable reference.
374378 unsafe { & mut * self . as_ptr ( ) }
@@ -534,7 +538,8 @@ impl<T> NonNull<[T]> {
534538 #[ inline]
535539 #[ must_use]
536540 #[ unstable( feature = "ptr_as_uninit" , issue = "75402" ) ]
537- pub unsafe fn as_uninit_slice < ' a > ( & self ) -> & ' a [ MaybeUninit < T > ] {
541+ #[ rustc_const_unstable( feature = "const_ptr_as_ref" , issue = "91822" ) ]
542+ pub const unsafe fn as_uninit_slice < ' a > ( & self ) -> & ' a [ MaybeUninit < T > ] {
538543 // SAFETY: the caller must uphold the safety contract for `as_uninit_slice`.
539544 unsafe { slice:: from_raw_parts ( self . cast ( ) . as_ptr ( ) , self . len ( ) ) }
540545 }
@@ -596,7 +601,8 @@ impl<T> NonNull<[T]> {
596601 #[ inline]
597602 #[ must_use]
598603 #[ unstable( feature = "ptr_as_uninit" , issue = "75402" ) ]
599- pub unsafe fn as_uninit_slice_mut < ' a > ( & self ) -> & ' a mut [ MaybeUninit < T > ] {
604+ #[ rustc_const_unstable( feature = "const_ptr_as_ref" , issue = "91822" ) ]
605+ pub const unsafe fn as_uninit_slice_mut < ' a > ( & self ) -> & ' a mut [ MaybeUninit < T > ] {
600606 // SAFETY: the caller must uphold the safety contract for `as_uninit_slice_mut`.
601607 unsafe { slice:: from_raw_parts_mut ( self . cast ( ) . as_ptr ( ) , self . len ( ) ) }
602608 }
0 commit comments