@@ -252,7 +252,7 @@ mod x86;
252
252
253
253
use core:: {
254
254
marker:: { PhantomData , PhantomPinned } ,
255
- mem:: { self , MaybeUninit } ,
255
+ mem:: { size_of , MaybeUninit } ,
256
256
num:: {
257
257
self , NonZeroI128 , NonZeroI16 , NonZeroI32 , NonZeroI64 , NonZeroI8 , NonZeroIsize ,
258
258
NonZeroU128 , NonZeroU16 , NonZeroU32 , NonZeroU64 , NonZeroU8 , NonZeroUsize ,
@@ -409,10 +409,10 @@ where
409
409
//
410
410
// Safety:
411
411
//
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.
413
413
// It is also properly aligned, because `u8` has an alignment of `1`.
414
414
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 > ( ) ) ;
416
416
}
417
417
418
418
// Ensures self is overwritten with the `None` bit pattern. volatile_write can't be
@@ -457,7 +457,7 @@ impl<Z> Zeroize for MaybeUninit<Z> {
457
457
impl < Z > Zeroize for [ MaybeUninit < Z > ] {
458
458
fn zeroize ( & mut self ) {
459
459
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 ( ) ;
461
461
assert ! ( size <= isize :: MAX as usize ) ;
462
462
463
463
// Safety:
@@ -595,6 +595,8 @@ impl Zeroize for String {
595
595
#[ cfg( feature = "std" ) ]
596
596
impl Zeroize for CString {
597
597
fn zeroize ( & mut self ) {
598
+ use core:: mem;
599
+
598
600
// mem::take uses replace internally to swap the pointer
599
601
// Unfortunately this results in an allocation for a Box::new(&[0]) as CString must
600
602
// contain a trailing zero byte
@@ -767,7 +769,7 @@ fn volatile_write<T: Copy + Sized>(dst: &mut T, src: T) {
767
769
/// The memory pointed to by `dst` must be a single allocated object that is valid for `count`
768
770
/// contiguous elements of `T`.
769
771
/// `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.
771
773
/// Also `dst` must be properly aligned.
772
774
#[ inline( always) ]
773
775
unsafe 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) {
783
785
// Safety:
784
786
//
785
787
// 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.
787
789
ptr:: write_volatile ( ptr, src) ;
788
790
}
789
791
}
@@ -837,10 +839,10 @@ unsafe fn volatile_set<T: Copy + Sized>(dst: *mut T, src: T, count: usize) {
837
839
/// ```
838
840
#[ inline( always) ]
839
841
pub unsafe fn zeroize_flat_type < F : Sized > ( data : * mut F ) {
840
- let size = mem :: size_of :: < F > ( ) ;
842
+ let size = size_of :: < F > ( ) ;
841
843
// Safety:
842
844
//
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
844
846
// `data_ptr` points directly to the first byte of the data.
845
847
volatile_set ( data as * mut u8 , 0 , size) ;
846
848
atomic_fence ( )
0 commit comments