@@ -79,7 +79,7 @@ use ops::{CoerceUnsized, DispatchFromDyn};
7979use fmt;
8080use hash;
8181use marker:: { PhantomData , Unsize } ;
82- use mem;
82+ use mem:: { self , MaybeUninit } ;
8383use nonzero:: NonZero ;
8484
8585use cmp:: Ordering :: { self , Less , Equal , Greater } ;
@@ -575,9 +575,9 @@ pub unsafe fn replace<T>(dst: *mut T, mut src: T) -> T {
575575#[ inline]
576576#[ stable( feature = "rust1" , since = "1.0.0" ) ]
577577pub unsafe fn read < T > ( src : * const T ) -> T {
578- let mut tmp: T = mem :: uninitialized ( ) ;
579- copy_nonoverlapping ( src, & mut tmp, 1 ) ;
580- tmp
578+ let mut tmp = MaybeUninit :: < T > :: uninitialized ( ) ;
579+ copy_nonoverlapping ( src, tmp. as_mut_ptr ( ) , 1 ) ;
580+ tmp. into_inner ( )
581581}
582582
583583/// Reads the value from `src` without moving it. This leaves the
@@ -642,11 +642,11 @@ pub unsafe fn read<T>(src: *const T) -> T {
642642#[ inline]
643643#[ stable( feature = "ptr_unaligned" , since = "1.17.0" ) ]
644644pub unsafe fn read_unaligned < T > ( src : * const T ) -> T {
645- let mut tmp: T = mem :: uninitialized ( ) ;
645+ let mut tmp = MaybeUninit :: < T > :: uninitialized ( ) ;
646646 copy_nonoverlapping ( src as * const u8 ,
647- & mut tmp as * mut T as * mut u8 ,
647+ tmp. as_mut_ptr ( ) as * mut u8 ,
648648 mem:: size_of :: < T > ( ) ) ;
649- tmp
649+ tmp. into_inner ( )
650650}
651651
652652/// Overwrites a memory location with the given value without reading or
0 commit comments