Skip to content

Commit

Permalink
Fix Nightly warnings (#1055)
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov committed Mar 1, 2024
1 parent dd4addd commit 878bcfd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 36 deletions.
1 change: 0 additions & 1 deletion blobby/src/lib.rs
Expand Up @@ -51,7 +51,6 @@
extern crate alloc;

use alloc::{boxed::Box, collections::BTreeMap, vec, vec::Vec};
use core::iter::Iterator;

/// Iterator over binary blobs
pub struct BlobIterator<'a> {
Expand Down
2 changes: 0 additions & 2 deletions dbl/src/lib.rs
Expand Up @@ -9,8 +9,6 @@
use hybrid_array::typenum::{U16, U32, U8};
use hybrid_array::Array;

use core::convert::TryInto;

const C64: u64 = 0b1_1011;
const C128: u64 = 0b1000_0111;
const C256: u64 = 0b100_0010_0101;
Expand Down
57 changes: 24 additions & 33 deletions zeroize/src/lib.rs
Expand Up @@ -41,15 +41,13 @@
//! ```
//! use zeroize::Zeroize;
//!
//! fn main() {
//! // Protip: don't embed secrets in your source code.
//! // This is just an example.
//! let mut secret = b"Air shield password: 1,2,3,4,5".to_vec();
//! // [ ... ] open the air shield here
//!
//! // Now that we're done using the secret, zero it out.
//! secret.zeroize();
//! }
//! // Protip: don't embed secrets in your source code.
//! // This is just an example.
//! let mut secret = b"Air shield password: 1,2,3,4,5".to_vec();
//! // [ ... ] open the air shield here
//!
//! // Now that we're done using the secret, zero it out.
//! secret.zeroize();
//! ```
//!
//! The [`Zeroize`] trait is impl'd on all of Rust's core scalar types including
Expand All @@ -68,6 +66,7 @@
//! memory is zeroed by converting it to a `Vec<u8>` and back into a `CString`.
//! (NOTE: see "Stack/Heap Zeroing Notes" for important `Vec`/`String`/`CString` details)
//!
//! [`CString`]: https://doc.rust-lang.org/std/ffi/struct.CString.html
//!
//! The [`DefaultIsZeroes`] marker trait can be impl'd on types which also
//! impl [`Default`], which implements [`Zeroize`] by overwriting a value with
Expand Down Expand Up @@ -143,7 +142,7 @@
//! ```
//! use zeroize::Zeroizing;
//!
//! fn main() {
//! fn use_secret() {
//! let mut secret = Zeroizing::new([0u8; 5]);
//!
//! // Set the air shield password
Expand All @@ -153,6 +152,8 @@
//!
//! // The contents of `secret` will be automatically zeroized on drop
//! }
//!
//! # use_secret()
//! ```
//!
//! ## What guarantees does this crate provide?
Expand Down Expand Up @@ -800,31 +801,21 @@ unsafe fn volatile_set<T: Copy + Sized>(dst: *mut T, src: T, count: usize) {
/// type that already implements `ZeroizeOnDrop`.
///
/// # Safety
/// - The type must not contain references to outside data or dynamically sized data, such as Vec<X>
/// or String<X>.
/// - This function can invalidate the type if it is used after this function is called on it. It is
/// advisable to call this function in `impl Drop`.
/// - The bit pattern of all zeroes must be valid for the data being zeroized. This may not be true for
/// enums and pointers.
/// - The type must not contain references to outside data or dynamically sized data, such as
/// `Vec<T>` or `String`.
/// - Values stored in the type must not have `Drop` impls.
/// - This function can invalidate the type if it is used after this function is called on it.
/// It is advisable to call this function only in `impl Drop`.
/// - The bit pattern of all zeroes must be valid for the data being zeroized. This may not be
/// true for enums and pointers.
///
/// # Incompatible data types
/// Some data types that cannot be safely zeroized using `zeroize_flat_type` include, but are not
/// limited to:
/// - pointers such as
/// - *const u8
/// - *mut u8
/// - references such as
/// - &T
/// - &mut T
/// - smart pointers and collections
/// - Arc<T>
/// - Box<T>
/// - Vec<T>
/// - HashMap<T1, T2>
/// - String
///
/// Some data types that may be invalid after calling `zeroize_flat_type`:
/// - enums
/// Some data types that cannot be safely zeroized using `zeroize_flat_type` include,
/// but are not limited to:
/// - References: `&T` and `&mut T`
/// - Non-nullable types: `NonNull<T>`, `NonZeroU32`, etc.
/// - Enums with explicit non-zero tags.
/// - Smart pointers and collections: `Arc<T>`, `Box<T>`, `Vec<T>`, `HashMap<K, V>`, `String`, etc.
///
/// # Examples
/// Safe usage for a struct containing strictly flat data:
Expand Down
1 change: 1 addition & 0 deletions zeroize/tests/zeroize_derive.rs
Expand Up @@ -345,6 +345,7 @@ fn derive_zeroize_with_marker() {
field: Option<A>,
}

#[allow(dead_code)]
trait Secret: ZeroizeOnDrop + Zeroize {}

impl<A: Marker> Secret for Test<A> {}
Expand Down

0 comments on commit 878bcfd

Please sign in to comment.