File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -367,13 +367,14 @@ impl<T: ?Sized> NonNull<T> {
367367 ///
368368 /// [the module documentation]: crate::ptr#safety
369369 #[ stable( feature = "nonnull" , since = "1.25.0" ) ]
370- #[ rustc_const_unstable ( feature = "const_ptr_as_ref " , issue = "91822 " ) ]
370+ #[ rustc_const_stable ( feature = "const_nonnull_as_ref " , since = "CURRENT_RUSTC_VERSION " ) ]
371371 #[ must_use]
372372 #[ inline( always) ]
373373 pub const unsafe fn as_ref < ' a > ( & self ) -> & ' a T {
374374 // SAFETY: the caller must guarantee that `self` meets all the
375375 // requirements for a reference.
376- unsafe { & * self . as_ptr ( ) }
376+ // `cast_const` avoids a mutable raw pointer deref.
377+ unsafe { & * self . as_ptr ( ) . cast_const ( ) }
377378 }
378379
379380 /// Returns a unique reference to the value. If the value may be uninitialized, [`as_uninit_mut`]
You can’t perform that action at this time.
0 commit comments