diff --git a/src/liballoc/collections/btree/node.rs b/src/liballoc/collections/btree/node.rs index 84d34db2d458a..5569c293e2f66 100644 --- a/src/liballoc/collections/btree/node.rs +++ b/src/liballoc/collections/btree/node.rs @@ -131,7 +131,7 @@ impl BoxedNode { } unsafe fn from_ptr(ptr: NonNull>) -> Self { - BoxedNode { ptr: Unique::from(ptr) } + BoxedNode { ptr: Unique::new_unchecked(ptr.as_ptr()) } } fn as_ptr(&self) -> NonNull> { diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs index 0780b33e53ae6..ca165b61e26a7 100644 --- a/src/liballoc/raw_vec.rs +++ b/src/liballoc/raw_vec.rs @@ -151,7 +151,7 @@ impl RawVec { 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 @@ impl RawVec { } 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); } diff --git a/src/libcore/ptr/unique.rs b/src/libcore/ptr/unique.rs index 87b56d951c6ce..d93dc1f326231 100644 --- a/src/libcore/ptr/unique.rs +++ b/src/libcore/ptr/unique.rs @@ -3,7 +3,6 @@ use crate::fmt; use crate::marker::{PhantomData, Unsize}; use crate::mem; use crate::ops::{CoerceUnsized, DispatchFromDyn}; -use crate::ptr::NonNull; // ignore-tidy-undocumented-unsafe @@ -171,19 +170,3 @@ impl From<&mut T> for Unique { unsafe { Unique { pointer: reference as *mut T, _marker: PhantomData } } } } - -#[unstable(feature = "ptr_internals", issue = "none")] -impl From<&T> for Unique { - #[inline] - fn from(reference: &T) -> Self { - unsafe { Unique { pointer: reference as *const T, _marker: PhantomData } } - } -} - -#[unstable(feature = "ptr_internals", issue = "none")] -impl From> for Unique { - #[inline] - fn from(p: NonNull) -> Self { - unsafe { Unique::new_unchecked(p.as_ptr()) } - } -}