mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-01 19:23:50 +00:00
Rollup merge of #71589 - RalfJung:unique-no-shr, r=SimonSapin
remove Unique::from for shared pointer types r? @SimonSapin
This commit is contained in:
commit
cddbed0003
@ -131,7 +131,7 @@ impl<K, V> BoxedNode<K, V> {
|
||||
}
|
||||
|
||||
unsafe fn from_ptr(ptr: NonNull<LeafNode<K, V>>) -> Self {
|
||||
BoxedNode { ptr: Unique::from(ptr) }
|
||||
BoxedNode { ptr: Unique::new_unchecked(ptr.as_ptr()) }
|
||||
}
|
||||
|
||||
fn as_ptr(&self) -> NonNull<LeafNode<K, V>> {
|
||||
|
@ -151,7 +151,7 @@ impl<T, A: AllocRef> RawVec<T, A> {
|
||||
|
||||
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<T, A: AllocRef> RawVec<T, A> {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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<T: ?Sized> From<&mut T> for Unique<T> {
|
||||
unsafe { Unique { pointer: reference as *mut T, _marker: PhantomData } }
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "ptr_internals", issue = "none")]
|
||||
impl<T: ?Sized> From<&T> for Unique<T> {
|
||||
#[inline]
|
||||
fn from(reference: &T) -> Self {
|
||||
unsafe { Unique { pointer: reference as *const T, _marker: PhantomData } }
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "ptr_internals", issue = "none")]
|
||||
impl<T: ?Sized> From<NonNull<T>> for Unique<T> {
|
||||
#[inline]
|
||||
fn from(p: NonNull<T>) -> Self {
|
||||
unsafe { Unique::new_unchecked(p.as_ptr()) }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user