]> git.lizzy.rs Git - rust.git/blobdiff - src/liballoc/raw_vec.rs
remove Unique::from for shared pointer types
[rust.git] / src / liballoc / raw_vec.rs
index 0780b33e53ae6f207a7aed3156efad46582dbf95..ca165b61e26a7da30b2c3e210992a2d8412e4d9a 100644 (file)
@@ -151,7 +151,7 @@ fn allocate_in(capacity: usize, init: AllocInit, mut alloc: A) -> Self {
 
             let memory = alloc.alloc(layout, init).unwrap_or_else(|_| handle_alloc_error(layout));
             Self {
-                ptr: memory.ptr.cast().into(),
+                ptr: unsafe { Unique::new_unchecked(memory.ptr.cast().as_ptr()) },
                 cap: Self::capacity_from_bytes(memory.size),
                 alloc,
             }
@@ -469,7 +469,7 @@ fn capacity_from_bytes(excess: usize) -> usize {
     }
 
     fn set_memory(&mut self, memory: MemoryBlock) {
-        self.ptr = memory.ptr.cast().into();
+        self.ptr = unsafe { Unique::new_unchecked(memory.ptr.cast().as_ptr()) };
         self.cap = Self::capacity_from_bytes(memory.size);
     }