Skip to content

Commit c68a520

Browse files
authored
Fix Nightly warnings (#1080)
1 parent b15cc6c commit c68a520

File tree

6 files changed

+49
-46
lines changed

6 files changed

+49
-46
lines changed

blobby/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,10 @@ fn encode_vlq(mut val: usize, buf: &mut [u8; 4]) -> &[u8] {
151151
/// - (J << 1) & 0x01: indicates this blob is index entry J
152152
/// - (L << 1) & 0x00: indicates an explicit blob of len L
153153
/// - (in the latter case) explicit blob contents (L bytes)
154-
pub fn encode_blobs<'a, I, T: 'a>(blobs: &'a I) -> (Vec<u8>, usize)
154+
pub fn encode_blobs<'a, I, T>(blobs: &'a I) -> (Vec<u8>, usize)
155155
where
156156
&'a I: IntoIterator<Item = &'a T>,
157-
T: AsRef<[u8]>,
157+
T: AsRef<[u8]> + 'a,
158158
{
159159
let mut idx_map = BTreeMap::new();
160160
blobs

inout/src/inout.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,19 @@ impl<'inp, 'out, T> InOut<'inp, 'out, T> {
4444
/// # Safety
4545
/// Behavior is undefined if any of the following conditions are violated:
4646
/// - `in_ptr` must point to a properly initialized value of type `T` and
47-
/// must be valid for reads.
47+
/// must be valid for reads.
4848
/// - `out_ptr` must point to a properly initialized value of type `T` and
49-
/// must be valid for both reads and writes.
49+
/// must be valid for both reads and writes.
5050
/// - `in_ptr` and `out_ptr` must be either equal or non-overlapping.
5151
/// - If `in_ptr` and `out_ptr` are equal, then the memory referenced by
52-
/// them must not be accessed through any other pointer (not derived from
53-
/// the return value) for the duration of lifetime 'a. Both read and write
54-
/// accesses are forbidden.
52+
/// them must not be accessed through any other pointer (not derived from
53+
/// the return value) for the duration of lifetime 'a. Both read and write
54+
/// accesses are forbidden.
5555
/// - If `in_ptr` and `out_ptr` are not equal, then the memory referenced by
56-
/// `out_ptr` must not be accessed through any other pointer (not derived from
57-
/// the return value) for the duration of lifetime `'a`. Both read and write
58-
/// accesses are forbidden. The memory referenced by `in_ptr` must not be
59-
/// mutated for the duration of lifetime `'a`, except inside an `UnsafeCell`.
56+
/// `out_ptr` must not be accessed through any other pointer (not derived from
57+
/// the return value) for the duration of lifetime `'a`. Both read and write
58+
/// accesses are forbidden. The memory referenced by `in_ptr` must not be
59+
/// mutated for the duration of lifetime `'a`, except inside an `UnsafeCell`.
6060
#[inline(always)]
6161
pub unsafe fn from_raw(in_ptr: *const T, out_ptr: *mut T) -> InOut<'inp, 'out, T> {
6262
Self {

inout/src/inout_buf.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,20 +149,20 @@ impl<'inp, 'out, T> InOutBuf<'inp, 'out, T> {
149149
/// # Safety
150150
/// Behavior is undefined if any of the following conditions are violated:
151151
/// - `in_ptr` must point to a properly initialized value of type `T` and
152-
/// must be valid for reads for `len * mem::size_of::<T>()` many bytes.
152+
/// must be valid for reads for `len * mem::size_of::<T>()` many bytes.
153153
/// - `out_ptr` must point to a properly initialized value of type `T` and
154-
/// must be valid for both reads and writes for `len * mem::size_of::<T>()`
155-
/// many bytes.
154+
/// must be valid for both reads and writes for `len * mem::size_of::<T>()`
155+
/// many bytes.
156156
/// - `in_ptr` and `out_ptr` must be either equal or non-overlapping.
157157
/// - If `in_ptr` and `out_ptr` are equal, then the memory referenced by
158-
/// them must not be accessed through any other pointer (not derived from
159-
/// the return value) for the duration of lifetime 'a. Both read and write
160-
/// accesses are forbidden.
158+
/// them must not be accessed through any other pointer (not derived from
159+
/// the return value) for the duration of lifetime 'a. Both read and write
160+
/// accesses are forbidden.
161161
/// - If `in_ptr` and `out_ptr` are not equal, then the memory referenced by
162-
/// `out_ptr` must not be accessed through any other pointer (not derived from
163-
/// the return value) for the duration of lifetime 'a. Both read and write
164-
/// accesses are forbidden. The memory referenced by `in_ptr` must not be
165-
/// mutated for the duration of lifetime `'a`, except inside an `UnsafeCell`.
162+
/// `out_ptr` must not be accessed through any other pointer (not derived from
163+
/// the return value) for the duration of lifetime 'a. Both read and write
164+
/// accesses are forbidden. The memory referenced by `in_ptr` must not be
165+
/// mutated for the duration of lifetime `'a`, except inside an `UnsafeCell`.
166166
/// - The total size `len * mem::size_of::<T>()` must be no larger than `isize::MAX`.
167167
#[inline(always)]
168168
pub unsafe fn from_raw(

inout/src/reserved.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,22 @@ impl<'a, T> InOutBufReserved<'a, 'a, T> {
4444
/// # Safety
4545
/// Behavior is undefined if any of the following conditions are violated:
4646
/// - `in_ptr` must point to a properly initialized value of type `T` and
47-
/// must be valid for reads for `in_len * mem::size_of::<T>()` many bytes.
47+
/// must be valid for reads for `in_len * mem::size_of::<T>()` many bytes.
4848
/// - `out_ptr` must point to a properly initialized value of type `T` and
49-
/// must be valid for both reads and writes for `out_len * mem::size_of::<T>()`
50-
/// many bytes.
49+
/// must be valid for both reads and writes for `out_len * mem::size_of::<T>()`
50+
/// many bytes.
5151
/// - `in_ptr` and `out_ptr` must be either equal or non-overlapping.
5252
/// - If `in_ptr` and `out_ptr` are equal, then the memory referenced by
53-
/// them must not be accessed through any other pointer (not derived from
54-
/// the return value) for the duration of lifetime 'a. Both read and write
55-
/// accesses are forbidden.
53+
/// them must not be accessed through any other pointer (not derived from
54+
/// the return value) for the duration of lifetime 'a. Both read and write
55+
/// accesses are forbidden.
5656
/// - If `in_ptr` and `out_ptr` are not equal, then the memory referenced by
57-
/// `out_ptr` must not be accessed through any other pointer (not derived from
58-
/// the return value) for the duration of lifetime 'a. Both read and write
59-
/// accesses are forbidden. The memory referenced by `in_ptr` must not be
60-
/// mutated for the duration of lifetime `'a`, except inside an `UnsafeCell`.
57+
/// `out_ptr` must not be accessed through any other pointer (not derived from
58+
/// the return value) for the duration of lifetime 'a. Both read and write
59+
/// accesses are forbidden. The memory referenced by `in_ptr` must not be
60+
/// mutated for the duration of lifetime `'a`, except inside an `UnsafeCell`.
6161
/// - The total size `in_len * mem::size_of::<T>()` and
62-
/// `out_len * mem::size_of::<T>()` must be no larger than `isize::MAX`.
62+
/// `out_len * mem::size_of::<T>()` must be no larger than `isize::MAX`.
6363
#[inline(always)]
6464
pub unsafe fn from_raw(
6565
in_ptr: *const T,

wycheproof2blb/src/main.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
)]
66
use std::io::Write;
77

8-
mod aead;
8+
// `pub mod` is used to silence "field is never read" warnings
9+
pub mod aead;
910
mod aes_siv;
1011
mod ecdsa;
1112
mod ed25519;
1213
mod hkdf;
13-
mod mac;
14+
pub mod mac;
1415
mod wycheproof;
1516

1617
/// Test information
@@ -22,10 +23,10 @@ pub struct TestInfo {
2223
}
2324

2425
/// Generator function which takes input parameters:
25-
/// - contents of Wycheproof test data file
26-
/// - algorithm name
27-
/// - key size (in bits) to include
28-
/// and returns the raw contents, together with a list of test identifiers (one per entry).
26+
/// - contents of Wycheproof test data file
27+
/// - algorithm name
28+
/// - key size (in bits) to include
29+
/// and returns the raw contents, together with a list of test identifiers (one per entry).
2930
type BlbGenerator = fn(&[u8], &str, u32) -> Vec<TestInfo>;
3031

3132
struct Algorithm {

zeroize/src/lib.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ mod x86;
252252

253253
use core::{
254254
marker::{PhantomData, PhantomPinned},
255-
mem::{self, MaybeUninit},
255+
mem::{size_of, MaybeUninit},
256256
num::{
257257
self, NonZeroI128, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroIsize,
258258
NonZeroU128, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize,
@@ -409,10 +409,10 @@ where
409409
//
410410
// Safety:
411411
//
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.
413413
// It is also properly aligned, because `u8` has an alignment of `1`.
414414
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>());
416416
}
417417

418418
// Ensures self is overwritten with the `None` bit pattern. volatile_write can't be
@@ -457,7 +457,7 @@ impl<Z> Zeroize for MaybeUninit<Z> {
457457
impl<Z> Zeroize for [MaybeUninit<Z>] {
458458
fn zeroize(&mut self) {
459459
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();
461461
assert!(size <= isize::MAX as usize);
462462

463463
// Safety:
@@ -595,6 +595,8 @@ impl Zeroize for String {
595595
#[cfg(feature = "std")]
596596
impl Zeroize for CString {
597597
fn zeroize(&mut self) {
598+
use core::mem;
599+
598600
// mem::take uses replace internally to swap the pointer
599601
// Unfortunately this results in an allocation for a Box::new(&[0]) as CString must
600602
// contain a trailing zero byte
@@ -767,7 +769,7 @@ fn volatile_write<T: Copy + Sized>(dst: &mut T, src: T) {
767769
/// The memory pointed to by `dst` must be a single allocated object that is valid for `count`
768770
/// contiguous elements of `T`.
769771
/// `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.
771773
/// Also `dst` must be properly aligned.
772774
#[inline(always)]
773775
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) {
783785
// Safety:
784786
//
785787
// 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.
787789
ptr::write_volatile(ptr, src);
788790
}
789791
}
@@ -837,10 +839,10 @@ unsafe fn volatile_set<T: Copy + Sized>(dst: *mut T, src: T, count: usize) {
837839
/// ```
838840
#[inline(always)]
839841
pub unsafe fn zeroize_flat_type<F: Sized>(data: *mut F) {
840-
let size = mem::size_of::<F>();
842+
let size = size_of::<F>();
841843
// Safety:
842844
//
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
844846
// `data_ptr` points directly to the first byte of the data.
845847
volatile_set(data as *mut u8, 0, size);
846848
atomic_fence()

0 commit comments

Comments
 (0)