@@ -260,7 +260,7 @@ impl<'a, T: 'a + Array> Drop for Drain<'a, T> {
260260#[ cfg( feature = "union" ) ]
261261union SmallVecData < A : Array > {
262262 inline : MaybeUninit < A > ,
263- heap : ( * mut A :: Item , usize ) ,
263+ heap : ( NonNull < A :: Item > , usize ) ,
264264}
265265
266266#[ cfg( feature = "union" ) ]
@@ -283,37 +283,39 @@ impl<A: Array> SmallVecData<A> {
283283 }
284284 #[ inline]
285285 unsafe fn heap ( & self ) -> ( * mut A :: Item , usize ) {
286- self . heap
286+ ( self . heap . 0 . as_ptr ( ) , self . heap . 1 )
287287 }
288288 #[ inline]
289- unsafe fn heap_mut ( & mut self ) -> & mut ( * mut A :: Item , usize ) {
290- & mut self . heap
289+ unsafe fn heap_mut ( & mut self ) -> ( * mut A :: Item , & mut usize ) {
290+ ( self . heap . 0 . as_ptr ( ) , & mut self . heap . 1 )
291291 }
292292 #[ inline]
293293 fn from_heap ( ptr : * mut A :: Item , len : usize ) -> SmallVecData < A > {
294- SmallVecData { heap : ( ptr, len) }
294+ SmallVecData {
295+ heap : ( NonNull :: new ( ptr) . unwrap ( ) , len) ,
296+ }
295297 }
296298}
297299
298300#[ cfg( not( feature = "union" ) ) ]
299301enum SmallVecData < A : Array > {
300302 Inline ( MaybeUninit < A > ) ,
301- Heap ( ( * mut A :: Item , usize ) ) ,
303+ Heap ( ( NonNull < A :: Item > , usize ) ) ,
302304}
303305
304306#[ cfg( not( feature = "union" ) ) ]
305307impl < A : Array > SmallVecData < A > {
306308 #[ inline]
307309 unsafe fn inline ( & self ) -> * const A :: Item {
308- match * self {
309- SmallVecData :: Inline ( ref a) => a. as_ptr ( ) as * const A :: Item ,
310+ match self {
311+ SmallVecData :: Inline ( a) => a. as_ptr ( ) as * const A :: Item ,
310312 _ => debug_unreachable ! ( ) ,
311313 }
312314 }
313315 #[ inline]
314316 unsafe fn inline_mut ( & mut self ) -> * mut A :: Item {
315- match * self {
316- SmallVecData :: Inline ( ref mut a) => a. as_mut_ptr ( ) as * mut A :: Item ,
317+ match self {
318+ SmallVecData :: Inline ( a) => a. as_mut_ptr ( ) as * mut A :: Item ,
317319 _ => debug_unreachable ! ( ) ,
318320 }
319321 }
@@ -330,21 +332,21 @@ impl<A: Array> SmallVecData<A> {
330332 }
331333 #[ inline]
332334 unsafe fn heap ( & self ) -> ( * mut A :: Item , usize ) {
333- match * self {
334- SmallVecData :: Heap ( data) => data,
335+ match self {
336+ SmallVecData :: Heap ( data) => ( data. 0 . as_ptr ( ) , data . 1 ) ,
335337 _ => debug_unreachable ! ( ) ,
336338 }
337339 }
338340 #[ inline]
339- unsafe fn heap_mut ( & mut self ) -> & mut ( * mut A :: Item , usize ) {
340- match * self {
341- SmallVecData :: Heap ( ref mut data) => data,
341+ unsafe fn heap_mut ( & mut self ) -> ( * mut A :: Item , & mut usize ) {
342+ match self {
343+ SmallVecData :: Heap ( data) => ( data. 0 . as_ptr ( ) , & mut data . 1 ) ,
342344 _ => debug_unreachable ! ( ) ,
343345 }
344346 }
345347 #[ inline]
346348 fn from_heap ( ptr : * mut A :: Item , len : usize ) -> SmallVecData < A > {
347- SmallVecData :: Heap ( ( ptr, len) )
349+ SmallVecData :: Heap ( ( NonNull :: new ( ptr) . unwrap ( ) , len) )
348350 }
349351}
350352
@@ -571,7 +573,7 @@ impl<A: Array> SmallVec<A> {
571573 fn triple_mut ( & mut self ) -> ( * mut A :: Item , & mut usize , usize ) {
572574 unsafe {
573575 if self . spilled ( ) {
574- let & mut ( ptr, ref mut len_ptr) = self . data . heap_mut ( ) ;
576+ let ( ptr, len_ptr) = self . data . heap_mut ( ) ;
575577 ( ptr, len_ptr, self . capacity )
576578 } else {
577579 ( self . data . inline_mut ( ) , & mut self . capacity , A :: size ( ) )
0 commit comments