Skip to content

Commit cddbed0

Browse files
authored
Rollup merge of rust-lang#71589 - RalfJung:unique-no-shr, r=SimonSapin
remove Unique::from for shared pointer types r? @SimonSapin
2 parents ac62dce + 7aebdb6 commit cddbed0

File tree

3 files changed

+3
-20
lines changed

3 files changed

+3
-20
lines changed

src/liballoc/collections/btree/node.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl<K, V> BoxedNode<K, V> {
131131
}
132132

133133
unsafe fn from_ptr(ptr: NonNull<LeafNode<K, V>>) -> Self {
134-
BoxedNode { ptr: Unique::from(ptr) }
134+
BoxedNode { ptr: Unique::new_unchecked(ptr.as_ptr()) }
135135
}
136136

137137
fn as_ptr(&self) -> NonNull<LeafNode<K, V>> {

src/liballoc/raw_vec.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ impl<T, A: AllocRef> RawVec<T, A> {
151151

152152
let memory = alloc.alloc(layout, init).unwrap_or_else(|_| handle_alloc_error(layout));
153153
Self {
154-
ptr: memory.ptr.cast().into(),
154+
ptr: unsafe { Unique::new_unchecked(memory.ptr.cast().as_ptr()) },
155155
cap: Self::capacity_from_bytes(memory.size),
156156
alloc,
157157
}
@@ -469,7 +469,7 @@ impl<T, A: AllocRef> RawVec<T, A> {
469469
}
470470

471471
fn set_memory(&mut self, memory: MemoryBlock) {
472-
self.ptr = memory.ptr.cast().into();
472+
self.ptr = unsafe { Unique::new_unchecked(memory.ptr.cast().as_ptr()) };
473473
self.cap = Self::capacity_from_bytes(memory.size);
474474
}
475475

src/libcore/ptr/unique.rs

-17
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use crate::fmt;
33
use crate::marker::{PhantomData, Unsize};
44
use crate::mem;
55
use crate::ops::{CoerceUnsized, DispatchFromDyn};
6-
use crate::ptr::NonNull;
76

87
// ignore-tidy-undocumented-unsafe
98

@@ -171,19 +170,3 @@ impl<T: ?Sized> From<&mut T> for Unique<T> {
171170
unsafe { Unique { pointer: reference as *mut T, _marker: PhantomData } }
172171
}
173172
}
174-
175-
#[unstable(feature = "ptr_internals", issue = "none")]
176-
impl<T: ?Sized> From<&T> for Unique<T> {
177-
#[inline]
178-
fn from(reference: &T) -> Self {
179-
unsafe { Unique { pointer: reference as *const T, _marker: PhantomData } }
180-
}
181-
}
182-
183-
#[unstable(feature = "ptr_internals", issue = "none")]
184-
impl<T: ?Sized> From<NonNull<T>> for Unique<T> {
185-
#[inline]
186-
fn from(p: NonNull<T>) -> Self {
187-
unsafe { Unique::new_unchecked(p.as_ptr()) }
188-
}
189-
}

0 commit comments

Comments
 (0)