Auto merge of #60244 - SimonSapin:dangling, r=oli-obk
const-stabilize NonNull::dangling and NonNull::cast
This commit is contained in:
commit
0df1e57991
@ -2970,7 +2970,6 @@ impl<T: Sized> NonNull<T> {
|
||||
/// some other means.
|
||||
#[stable(feature = "nonnull", since = "1.25.0")]
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "const_ptr_nonnull")]
|
||||
pub const fn dangling() -> Self {
|
||||
unsafe {
|
||||
let ptr = mem::align_of::<T>() as *mut T;
|
||||
@ -3034,7 +3033,6 @@ impl<T: ?Sized> NonNull<T> {
|
||||
/// Cast to a pointer of another type
|
||||
#[stable(feature = "nonnull_cast", since = "1.27.0")]
|
||||
#[inline]
|
||||
#[rustc_const_unstable(feature = "const_ptr_nonnull")]
|
||||
pub const fn cast<U>(self) -> NonNull<U> {
|
||||
unsafe {
|
||||
NonNull::new_unchecked(self.as_ptr() as *mut U)
|
||||
|
@ -1,7 +1,5 @@
|
||||
// run-pass
|
||||
|
||||
#![feature(const_ptr_nonnull)]
|
||||
|
||||
use std::ptr::NonNull;
|
||||
|
||||
const DANGLING: NonNull<u32> = NonNull::dangling();
|
||||
|
Loading…
x
Reference in New Issue
Block a user