@@ -252,7 +252,7 @@ mod x86;
252252
253253use core:: {
254254 marker:: { PhantomData , PhantomPinned } ,
255- mem:: { self , MaybeUninit } ,
255+ mem:: { size_of , MaybeUninit } ,
256256 num:: {
257257 self , NonZeroI128 , NonZeroI16 , NonZeroI32 , NonZeroI64 , NonZeroI8 , NonZeroIsize ,
258258 NonZeroU128 , NonZeroU16 , NonZeroU32 , NonZeroU64 , NonZeroU8 , NonZeroUsize ,
@@ -409,10 +409,10 @@ where
409409 //
410410 // Safety:
411411 //
412- // The memory pointed to by `self` is valid for `mem:: size_of::<Self>()` bytes.
412+ // The memory pointed to by `self` is valid for `size_of::<Self>()` bytes.
413413 // It is also properly aligned, because `u8` has an alignment of `1`.
414414 unsafe {
415- volatile_set ( ( self as * mut Self ) . cast :: < u8 > ( ) , 0 , mem :: size_of :: < Self > ( ) ) ;
415+ volatile_set ( ( self as * mut Self ) . cast :: < u8 > ( ) , 0 , size_of :: < Self > ( ) ) ;
416416 }
417417
418418 // Ensures self is overwritten with the `None` bit pattern. volatile_write can't be
@@ -457,7 +457,7 @@ impl<Z> Zeroize for MaybeUninit<Z> {
457457impl < Z > Zeroize for [ MaybeUninit < Z > ] {
458458 fn zeroize ( & mut self ) {
459459 let ptr = self . as_mut_ptr ( ) . cast :: < MaybeUninit < u8 > > ( ) ;
460- let size = self . len ( ) . checked_mul ( mem :: size_of :: < Z > ( ) ) . unwrap ( ) ;
460+ let size = self . len ( ) . checked_mul ( size_of :: < Z > ( ) ) . unwrap ( ) ;
461461 assert ! ( size <= isize :: MAX as usize ) ;
462462
463463 // Safety:
@@ -595,6 +595,8 @@ impl Zeroize for String {
595595#[ cfg( feature = "std" ) ]
596596impl Zeroize for CString {
597597 fn zeroize ( & mut self ) {
598+ use core:: mem;
599+
598600 // mem::take uses replace internally to swap the pointer
599601 // Unfortunately this results in an allocation for a Box::new(&[0]) as CString must
600602 // contain a trailing zero byte
@@ -767,7 +769,7 @@ fn volatile_write<T: Copy + Sized>(dst: &mut T, src: T) {
767769/// The memory pointed to by `dst` must be a single allocated object that is valid for `count`
768770/// contiguous elements of `T`.
769771/// `count` must not be larger than an `isize`.
770- /// `dst` being offset by `mem:: size_of::<T> * count` bytes must not wrap around the address space.
772+ /// `dst` being offset by `size_of::<T> * count` bytes must not wrap around the address space.
771773/// Also `dst` must be properly aligned.
772774#[ inline( always) ]
773775unsafe fn volatile_set < T : Copy + Sized > ( dst : * mut T , src : T , count : usize ) {
@@ -783,7 +785,7 @@ unsafe fn volatile_set<T: Copy + Sized>(dst: *mut T, src: T, count: usize) {
783785 // Safety:
784786 //
785787 // This is safe, because the pointer is valid and because `dst` is well aligned for `T` and
786- // `ptr` is an offset of `dst` by a multiple of `mem:: size_of::<T>()` bytes.
788+ // `ptr` is an offset of `dst` by a multiple of `size_of::<T>()` bytes.
787789 ptr:: write_volatile ( ptr, src) ;
788790 }
789791}
@@ -837,10 +839,10 @@ unsafe fn volatile_set<T: Copy + Sized>(dst: *mut T, src: T, count: usize) {
837839/// ```
838840#[ inline( always) ]
839841pub unsafe fn zeroize_flat_type < F : Sized > ( data : * mut F ) {
840- let size = mem :: size_of :: < F > ( ) ;
842+ let size = size_of :: < F > ( ) ;
841843 // Safety:
842844 //
843- // This is safe because `mem:: size_of<T>()` returns the exact size of the object in memory, and
845+ // This is safe because `size_of<T>()` returns the exact size of the object in memory, and
844846 // `data_ptr` points directly to the first byte of the data.
845847 volatile_set ( data as * mut u8 , 0 , size) ;
846848 atomic_fence ( )
0 commit comments