From fcc7671ef2cfef0d387e45bc5235a61cef19a4ea Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Sat, 29 Sep 2018 00:52:36 +0100 Subject: [PATCH] Make NonNull::dangling a const fn --- src/libcore/ptr.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index b23b72c372010..947b551399433 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -2874,10 +2874,9 @@ impl NonNull { /// sentinel value. Types that lazily allocate must track initialization by /// some other means. #[stable(feature = "nonnull", since = "1.25.0")] - pub fn dangling() -> Self { + pub const fn dangling() -> Self { unsafe { - let ptr = mem::align_of::() as *mut T; - NonNull::new_unchecked(ptr) + NonNull::new_unchecked(mem::align_of::() as *mut T) } } }