about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorMark Mansi <markm@cs.wisc.edu>2018-04-25 16:33:02 -0500
committerMark Mansi <markm@cs.wisc.edu>2018-04-25 16:33:02 -0500
commit256096da9ee680366b839f912e8d3ecccc0da033 (patch)
treeaf468b7e26785c13cd95894035a3144500243bf4 /src/libcore
parent25749ad66de71ffb46e6b04fb0cccf1ae4fc5ed5 (diff)
downloadrust-256096da9ee680366b839f912e8d3ecccc0da033.tar.gz
rust-256096da9ee680366b839f912e8d3ecccc0da033.zip
Make Vec::new const
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/ptr.rs5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs
index 74bb264cc67..b612a278a34 100644
--- a/src/libcore/ptr.rs
+++ b/src/libcore/ptr.rs
@@ -2551,10 +2551,9 @@ impl<T: Sized> Unique<T> {
     /// This is useful for initializing types which lazily allocate, like
     /// `Vec::new` does.
     // FIXME: rename to dangling() to match NonNull?
-    pub fn empty() -> Self {
+    pub const fn empty() -> Self {
         unsafe {
-            let ptr = mem::align_of::<T>() as *mut T;
-            Unique::new_unchecked(ptr)
+            Unique::new_unchecked(mem::align_of::<T>() as *mut T)
         }
     }
 }