diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index a07c7260f712..0387708033b5 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -2903,7 +2903,7 @@ impl NonNull { #[inline] pub fn new(ptr: *mut T) -> Option { if !ptr.is_null() { - Some(NonNull { pointer: unsafe { NonZero(ptr as _) } }) + Some(unsafe { Self::new_unchecked(ptr) }) } else { None }