Skip to content

Commit

Permalink
zeroize: use doc_auto_cfg (#1063)
Browse files Browse the repository at this point in the history
Replaces manual `doc_cfg` annotations with automatic ones powered by
`doc_auto_cfg`.
  • Loading branch information
tarcieri committed Apr 24, 2024
1 parent cd3a147 commit 24decb9
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 14 deletions.
4 changes: 0 additions & 4 deletions zeroize/src/aarch64.rs
@@ -1,7 +1,4 @@
//! [`Zeroize`] impls for ARM64 SIMD registers.
//!
//! Gated behind the `aarch64` feature: MSRV 1.59
//! (the overall crate is MSRV 1.60)

use crate::{atomic_fence, volatile_write, Zeroize};

Expand All @@ -10,7 +7,6 @@ use core::arch::aarch64::*;
macro_rules! impl_zeroize_for_simd_register {
($($type:ty),* $(,)?) => {
$(
#[cfg_attr(docsrs, doc(cfg(target_arch = "aarch64")))]
impl Zeroize for $type {
#[inline]
fn zeroize(&mut self) {
Expand Down
10 changes: 1 addition & 9 deletions zeroize/src/lib.rs
@@ -1,5 +1,5 @@
#![no_std]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![doc(
html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg",
html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg"
Expand Down Expand Up @@ -243,7 +243,6 @@ extern crate alloc;
extern crate std;

#[cfg(feature = "zeroize_derive")]
#[cfg_attr(docsrs, doc(cfg(feature = "zeroize_derive")))]
pub use zeroize_derive::{Zeroize, ZeroizeOnDrop};

#[cfg(all(feature = "aarch64", target_arch = "aarch64"))]
Expand Down Expand Up @@ -541,7 +540,6 @@ impl_zeroize_tuple!(A, B, C, D, E, F, G, H, I);
impl_zeroize_tuple!(A, B, C, D, E, F, G, H, I, J);

#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
impl<Z> Zeroize for Vec<Z>
where
Z: Zeroize,
Expand All @@ -563,11 +561,9 @@ where
}

#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
impl<Z> ZeroizeOnDrop for Vec<Z> where Z: ZeroizeOnDrop {}

#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
impl<Z> Zeroize for Box<[Z]>
where
Z: Zeroize,
Expand All @@ -580,27 +576,23 @@ where
}

#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
impl<Z> ZeroizeOnDrop for Box<[Z]> where Z: ZeroizeOnDrop {}

#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
impl Zeroize for Box<str> {
fn zeroize(&mut self) {
self.as_mut().zeroize();
}
}

#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
impl Zeroize for String {
fn zeroize(&mut self) {
unsafe { self.as_mut_vec() }.zeroize();
}
}

#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl Zeroize for CString {
fn zeroize(&mut self) {
// mem::take uses replace internally to swap the pointer
Expand Down
1 change: 0 additions & 1 deletion zeroize/src/x86.rs
Expand Up @@ -11,7 +11,6 @@ use core::arch::x86_64::*;
macro_rules! impl_zeroize_for_simd_register {
($($type:ty),* $(,)?) => {
$(
#[cfg_attr(docsrs, doc(cfg(any(target_arch = "x86", target_arch = "x86_64"))))]
impl Zeroize for $type {
#[inline]
fn zeroize(&mut self) {
Expand Down

0 comments on commit 24decb9

Please sign in to comment.