Skip to content

Commit fcc7671

Browse files
committed
Make NonNull::dangling a const fn
1 parent 6846f22 commit fcc7671

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/libcore/ptr.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -2874,10 +2874,9 @@ impl<T: Sized> NonNull<T> {
28742874
/// sentinel value. Types that lazily allocate must track initialization by
28752875
/// some other means.
28762876
#[stable(feature = "nonnull", since = "1.25.0")]
2877-
pub fn dangling() -> Self {
2877+
pub const fn dangling() -> Self {
28782878
unsafe {
2879-
let ptr = mem::align_of::<T>() as *mut T;
2880-
NonNull::new_unchecked(ptr)
2879+
NonNull::new_unchecked(mem::align_of::<T>() as *mut T)
28812880
}
28822881
}
28832882
}

0 commit comments

Comments
 (0)