@@ -22,13 +22,13 @@ use core::cmp;
2222/// involved. This type is excellent for building your own data structures like Vec and VecDeque.
2323/// In particular:
2424///
25- /// * Produces heap::EMPTY on zero-sized types
26- /// * Produces heap::EMPTY on zero-length allocations
25+ /// * Produces Unique::empty() on zero-sized types
26+ /// * Produces Unique::empty() on zero-length allocations
2727/// * Catches all overflows in capacity computations (promotes them to "capacity overflow" panics)
2828/// * Guards against 32-bit systems allocating more than isize::MAX bytes
2929/// * Guards against overflowing your length
3030/// * Aborts on OOM
31- /// * Avoids freeing heap::EMPTY
31+ /// * Avoids freeing Unique::empty()
3232/// * Contains a ptr::Unique and thus endows the user with all related benefits
3333///
3434/// This type does not in anyway inspect the memory that it manages. When dropped it *will*
@@ -55,15 +55,13 @@ impl<T> RawVec<T> {
5555 /// it makes a RawVec with capacity `usize::MAX`. Useful for implementing
5656 /// delayed allocation.
5757 pub fn new ( ) -> Self {
58- unsafe {
59- // !0 is usize::MAX. This branch should be stripped at compile time.
60- let cap = if mem:: size_of :: < T > ( ) == 0 { !0 } else { 0 } ;
58+ // !0 is usize::MAX. This branch should be stripped at compile time.
59+ let cap = if mem:: size_of :: < T > ( ) == 0 { !0 } else { 0 } ;
6160
62- // heap::EMPTY doubles as "unallocated" and "zero-sized allocation"
63- RawVec {
64- ptr : Unique :: new ( heap:: EMPTY as * mut T ) ,
65- cap : cap,
66- }
61+ // Unique::empty() doubles as "unallocated" and "zero-sized allocation"
62+ RawVec {
63+ ptr : Unique :: empty ( ) ,
64+ cap : cap,
6765 }
6866 }
6967
@@ -101,7 +99,7 @@ impl<T> RawVec<T> {
10199
102100 // handles ZSTs and `cap = 0` alike
103101 let ptr = if alloc_size == 0 {
104- heap :: EMPTY as * mut u8
102+ mem :: align_of :: < T > ( ) as * mut u8
105103 } else {
106104 let align = mem:: align_of :: < T > ( ) ;
107105 let ptr = if zeroed {
@@ -148,10 +146,10 @@ impl<T> RawVec<T> {
148146
149147impl < T > RawVec < T > {
150148 /// Gets a raw pointer to the start of the allocation. Note that this is
151- /// heap::EMPTY if `cap = 0` or T is zero-sized. In the former case, you must
149+ /// Unique::empty() if `cap = 0` or T is zero-sized. In the former case, you must
152150 /// be careful.
153151 pub fn ptr ( & self ) -> * mut T {
154- self . ptr . ptr ( )
152+ self . ptr . as_ptr ( )
155153 }
156154
157155 /// Gets the capacity of the allocation.
0 commit comments