File tree 1 file changed +3
-2
lines changed
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> {
367
367
///
368
368
/// [the module documentation]: crate::ptr#safety
369
369
#[ 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 " ) ]
371
371
#[ must_use]
372
372
#[ inline( always) ]
373
373
pub const unsafe fn as_ref < ' a > ( & self ) -> & ' a T {
374
374
// SAFETY: the caller must guarantee that `self` meets all the
375
375
// 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 ( ) }
377
378
}
378
379
379
380
/// 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