Skip to content

Commit 2f215b6

Browse files
committed
Use NonNull instead of Unique in MemoryBlock
1 parent 2526acc commit 2f215b6

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/libcore/alloc/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub enum AllocInit {
4747
#[unstable(feature = "allocator_api", issue = "32838")]
4848
#[must_use = "`MemoryBlock` should be passed to `AllocRef::dealloc`"]
4949
pub struct MemoryBlock {
50-
ptr: Unique<u8>,
50+
ptr: NonNull<u8>,
5151
layout: Layout,
5252
}
5353

@@ -63,15 +63,14 @@ impl MemoryBlock {
6363
#[inline]
6464
#[unstable(feature = "allocator_api", issue = "32838")]
6565
pub const unsafe fn new(ptr: NonNull<u8>, layout: Layout) -> Self {
66-
Self { ptr: Unique::new_unchecked(ptr.as_ptr()), layout }
66+
Self { ptr, layout }
6767
}
6868

6969
/// Acquires the underlying `NonNull<u8>` pointer.
7070
#[inline]
7171
#[unstable(feature = "allocator_api", issue = "32838")]
7272
pub const fn ptr(&self) -> NonNull<u8> {
73-
// SAFETY: Unique<T> is always non-null
74-
unsafe { NonNull::new_unchecked(self.ptr.as_ptr()) }
73+
self.ptr
7574
}
7675

7776
/// Returns the layout describing the memory block.

0 commit comments

Comments
 (0)