Skip to content

Commit 878bcfd

Browse files
authored
Fix Nightly warnings (#1055)
1 parent dd4addd commit 878bcfd

File tree

4 files changed

+25
-36
lines changed

4 files changed

+25
-36
lines changed

blobby/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
extern crate alloc;
5252

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

5655
/// Iterator over binary blobs
5756
pub struct BlobIterator<'a> {

dbl/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
use hybrid_array::typenum::{U16, U32, U8};
1010
use hybrid_array::Array;
1111

12-
use core::convert::TryInto;
13-
1412
const C64: u64 = 0b1_1011;
1513
const C128: u64 = 0b1000_0111;
1614
const C256: u64 = 0b100_0010_0101;

zeroize/src/lib.rs

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,13 @@
4141
//! ```
4242
//! use zeroize::Zeroize;
4343
//!
44-
//! fn main() {
45-
//! // Protip: don't embed secrets in your source code.
46-
//! // This is just an example.
47-
//! let mut secret = b"Air shield password: 1,2,3,4,5".to_vec();
48-
//! // [ ... ] open the air shield here
49-
//!
50-
//! // Now that we're done using the secret, zero it out.
51-
//! secret.zeroize();
52-
//! }
44+
//! // Protip: don't embed secrets in your source code.
45+
//! // This is just an example.
46+
//! let mut secret = b"Air shield password: 1,2,3,4,5".to_vec();
47+
//! // [ ... ] open the air shield here
48+
//!
49+
//! // Now that we're done using the secret, zero it out.
50+
//! secret.zeroize();
5351
//! ```
5452
//!
5553
//! The [`Zeroize`] trait is impl'd on all of Rust's core scalar types including
@@ -68,6 +66,7 @@
6866
//! memory is zeroed by converting it to a `Vec<u8>` and back into a `CString`.
6967
//! (NOTE: see "Stack/Heap Zeroing Notes" for important `Vec`/`String`/`CString` details)
7068
//!
69+
//! [`CString`]: https://doc.rust-lang.org/std/ffi/struct.CString.html
7170
//!
7271
//! The [`DefaultIsZeroes`] marker trait can be impl'd on types which also
7372
//! impl [`Default`], which implements [`Zeroize`] by overwriting a value with
@@ -143,7 +142,7 @@
143142
//! ```
144143
//! use zeroize::Zeroizing;
145144
//!
146-
//! fn main() {
145+
//! fn use_secret() {
147146
//! let mut secret = Zeroizing::new([0u8; 5]);
148147
//!
149148
//! // Set the air shield password
@@ -153,6 +152,8 @@
153152
//!
154153
//! // The contents of `secret` will be automatically zeroized on drop
155154
//! }
155+
//!
156+
//! # use_secret()
156157
//! ```
157158
//!
158159
//! ## What guarantees does this crate provide?
@@ -800,31 +801,21 @@ unsafe fn volatile_set<T: Copy + Sized>(dst: *mut T, src: T, count: usize) {
800801
/// type that already implements `ZeroizeOnDrop`.
801802
///
802803
/// # Safety
803-
/// - The type must not contain references to outside data or dynamically sized data, such as Vec<X>
804-
/// or String<X>.
805-
/// - This function can invalidate the type if it is used after this function is called on it. It is
806-
/// advisable to call this function in `impl Drop`.
807-
/// - The bit pattern of all zeroes must be valid for the data being zeroized. This may not be true for
808-
/// enums and pointers.
804+
/// - The type must not contain references to outside data or dynamically sized data, such as
805+
/// `Vec<T>` or `String`.
806+
/// - Values stored in the type must not have `Drop` impls.
807+
/// - This function can invalidate the type if it is used after this function is called on it.
808+
/// It is advisable to call this function only in `impl Drop`.
809+
/// - The bit pattern of all zeroes must be valid for the data being zeroized. This may not be
810+
/// true for enums and pointers.
809811
///
810812
/// # Incompatible data types
811-
/// Some data types that cannot be safely zeroized using `zeroize_flat_type` include, but are not
812-
/// limited to:
813-
/// - pointers such as
814-
/// - *const u8
815-
/// - *mut u8
816-
/// - references such as
817-
/// - &T
818-
/// - &mut T
819-
/// - smart pointers and collections
820-
/// - Arc<T>
821-
/// - Box<T>
822-
/// - Vec<T>
823-
/// - HashMap<T1, T2>
824-
/// - String
825-
///
826-
/// Some data types that may be invalid after calling `zeroize_flat_type`:
827-
/// - enums
813+
/// Some data types that cannot be safely zeroized using `zeroize_flat_type` include,
814+
/// but are not limited to:
815+
/// - References: `&T` and `&mut T`
816+
/// - Non-nullable types: `NonNull<T>`, `NonZeroU32`, etc.
817+
/// - Enums with explicit non-zero tags.
818+
/// - Smart pointers and collections: `Arc<T>`, `Box<T>`, `Vec<T>`, `HashMap<K, V>`, `String`, etc.
828819
///
829820
/// # Examples
830821
/// Safe usage for a struct containing strictly flat data:

zeroize/tests/zeroize_derive.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ fn derive_zeroize_with_marker() {
345345
field: Option<A>,
346346
}
347347

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

350351
impl<A: Marker> Secret for Test<A> {}

0 commit comments

Comments
 (0)