Skip to content

Commit 56ae739

Browse files
Merge pull request #213 from iqlusioninc/zeroize/relax-array-bounds
zeroize: Bound blanket array impls on Zeroize
2 parents 834f191 + 958d654 commit 56ae739

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

zeroize/src/lib.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -352,19 +352,16 @@ impl_zeroize_with_default!(i8, i16, i32, i64, i128, isize);
352352
impl_zeroize_with_default!(u8, u16, u32, u64, u128, usize);
353353
impl_zeroize_with_default!(f32, f64, char, bool);
354354

355-
/// Implement `Zeroize` on arrays of types that can be zeroized with `Default`.
356-
///
357-
/// This impl can eventually be optimized using an atomic memset intrinsic.
358-
/// See notes for the blanket impl of `Zeroize` on `[Z]`.
355+
/// Implement `Zeroize` on arrays of types that impl `Zeroize`
359356
macro_rules! impl_zeroize_for_array {
360357
($($size:expr),+) => {
361358
$(
362359
impl<Z> Zeroize for [Z; $size]
363360
where
364-
Z: DefaultIsZeroes
361+
Z: Zeroize
365362
{
366363
fn zeroize(&mut self) {
367-
self.as_mut().zeroize();
364+
self.iter_mut().zeroize();
368365
}
369366
}
370367
)+
@@ -495,15 +492,12 @@ fn atomic_fence() {
495492
}
496493

497494
/// Perform a volatile write to the destination
498-
// TODO(tarcieri): replace this with atomic writes when they're stable
499495
#[inline]
500496
fn volatile_write<T: Copy + Sized>(dst: &mut T, src: T) {
501497
unsafe { ptr::write_volatile(dst, src) }
502498
}
503499

504500
/// Perform a volatile `memset` operation which fills a slice with a value
505-
// TODO(tarcieri): use `llvm.memset.element.unordered.atomic`
506-
// See: https://github.com/rust-lang/rust/issues/58599
507501
#[inline]
508502
fn volatile_set<T: Copy + Sized>(dst: &mut [T], src: T) {
509503
// TODO(tarcieri): use `volatile_set_memory` on nightly?

0 commit comments

Comments
 (0)