From b4cb3869b2a9828c359f9f2b71ad97f4409a269b Mon Sep 17 00:00:00 2001 From: Google PR Creation Bot Date: Fri, 7 Jun 2024 12:41:15 +0000 Subject: [PATCH] [ci] Roll pinned nightly toolchain --- Cargo.toml | 2 +- src/byteorder.rs | 4 ++-- src/error.rs | 2 +- src/impls.rs | 2 +- src/layout.rs | 12 ++++++------ src/lib.rs | 20 ++++++++++---------- src/macro_util.rs | 2 +- src/pointer/ptr.rs | 4 ++-- src/ref.rs | 12 ++++++------ src/util.rs | 4 ++-- 10 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d39c31a6cd..461f07c62a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ zerocopy-panic-in-const = "1.57.0" [package.metadata.ci] # The versions of the stable and nightly compiler toolchains to use in CI. pinned-stable = "1.78.0" -pinned-nightly = "nightly-2024-06-05" +pinned-nightly = "nightly-2024-06-06" [package.metadata.docs.rs] all-features = true diff --git a/src/byteorder.rs b/src/byteorder.rs index cfdfdfa2d5..cb0aa57431 100644 --- a/src/byteorder.rs +++ b/src/byteorder.rs @@ -661,7 +661,7 @@ define_type!( Usize, usize, mem::size_of::() * 8, - mem::size_of::(), + size_of::(), usize::from_be_bytes, usize::to_be_bytes, usize::from_le_bytes, @@ -746,7 +746,7 @@ define_type!( Isize, isize, mem::size_of::() * 8, - mem::size_of::(), + size_of::(), isize::from_be_bytes, isize::to_be_bytes, isize::from_le_bytes, diff --git a/src/error.rs b/src/error.rs index fff9e4d36e..dcc1cd9f90 100644 --- a/src/error.rs +++ b/src/error.rs @@ -139,7 +139,7 @@ where f.write_str("the conversion failed because the address of the source (a multiple of ")?; addr_align.fmt(f)?; f.write_str(") is not a multiple of the alignment (")?; - core::mem::align_of::().fmt(f)?; + align_of::().fmt(f)?; f.write_str(") of the destination type: ")?; f.write_str(core::any::type_name::())?; Ok(()) diff --git a/src/impls.rs b/src/impls.rs index 938ab6d192..a99528627f 100644 --- a/src/impls.rs +++ b/src/impls.rs @@ -919,7 +919,7 @@ mod tests { let mut t = Self::new_zeroed(); let ptr: *mut T = &mut t; // SAFETY: `T: FromBytes` - unsafe { ptr::write_bytes(ptr.cast::(), 0xFF, mem::size_of::()) }; + unsafe { ptr::write_bytes(ptr.cast::(), 0xFF, size_of::()) }; t }; diff --git a/src/layout.rs b/src/layout.rs index 266883c300..18f5f6ab44 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -7,12 +7,12 @@ // This file may not be copied, modified, or distributed except according to // those terms. -use core::{mem, num::NonZeroUsize}; +use core::num::NonZeroUsize; use crate::util; /// The target pointer width, counted in bits. -const POINTER_WIDTH_BITS: usize = mem::size_of::() * 8; +const POINTER_WIDTH_BITS: usize = size_of::() * 8; /// The layout of a type which might be dynamically-sized. /// @@ -160,11 +160,11 @@ impl DstLayout { // sound to initialize `size_info` to `SizeInfo::Sized { size }`; the // `size` field is also correct by construction. DstLayout { - align: match NonZeroUsize::new(mem::align_of::()) { + align: match NonZeroUsize::new(align_of::()) { Some(align) => align, None => const_unreachable!(), }, - size_info: SizeInfo::Sized { size: mem::size_of::() }, + size_info: SizeInfo::Sized { size: size_of::() }, } } @@ -183,13 +183,13 @@ impl DstLayout { // construction. Since `[T]` is a (degenerate case of a) slice DST, it // is correct to initialize `size_info` to `SizeInfo::SliceDst`. DstLayout { - align: match NonZeroUsize::new(mem::align_of::()) { + align: match NonZeroUsize::new(align_of::()) { Some(align) => align, None => const_unreachable!(), }, size_info: SizeInfo::SliceDst(TrailingSliceLayout { offset: 0, - elem_size: mem::size_of::(), + elem_size: size_of::(), }), } } diff --git a/src/lib.rs b/src/lib.rs index 6054c7e641..e668ed656c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2043,7 +2043,7 @@ pub unsafe trait FromZeros: TryFromBytes { #[inline(always)] fn zero(&mut self) { let slf: *mut Self = self; - let len = mem::size_of_val(self); + let len = size_of_val(self); // SAFETY: // - `self` is guaranteed by the type system to be valid for writes of // size `size_of_val(self)`. @@ -2165,10 +2165,10 @@ pub unsafe trait FromZeros: TryFromBytes { where Self: Sized, { - let size = mem::size_of::() + let size = size_of::() .checked_mul(len) .expect("mem::size_of::() * len overflows `usize`"); - let align = mem::align_of::(); + let align = align_of::(); // On stable Rust versions <= 1.64.0, `Layout::from_size_align` has a // bug in which sufficiently-large allocations (those which, when // rounded up to the alignment, overflow `isize`) are not rejected, @@ -3817,7 +3817,7 @@ pub unsafe trait IntoBytes { { // Note that this method does not have a `Self: Sized` bound; // `size_of_val` works for unsized values too. - let len = mem::size_of_val(self); + let len = size_of_val(self); let slf: *const Self = self; // SAFETY: @@ -3894,7 +3894,7 @@ pub unsafe trait IntoBytes { { // Note that this method does not have a `Self: Sized` bound; // `size_of_val` works for unsized values too. - let len = mem::size_of_val(self); + let len = size_of_val(self); let slf: *mut Self = self; // SAFETY: @@ -3972,7 +3972,7 @@ pub unsafe trait IntoBytes { where Self: Immutable, { - if bytes.len() != mem::size_of_val(self) { + if bytes.len() != size_of_val(self) { return Err(SizeError::new(self)); } bytes.copy_from_slice(self.as_bytes()); @@ -4032,7 +4032,7 @@ pub unsafe trait IntoBytes { where Self: Immutable, { - let size = mem::size_of_val(self); + let size = size_of_val(self); match bytes.get_mut(..size) { Some(bytes) => { bytes.copy_from_slice(self.as_bytes()); @@ -4102,7 +4102,7 @@ pub unsafe trait IntoBytes { where Self: Immutable, { - let start = if let Some(start) = bytes.len().checked_sub(mem::size_of_val(self)) { + let start = if let Some(start) = bytes.len().checked_sub(size_of_val(self)) { start } else { return Err(SizeError::new(self)); @@ -4989,7 +4989,7 @@ mod alloc_support { #[should_panic(expected = "assertion failed: size <= max_alloc")] fn test_new_box_slice_zeroed_panics_isize_overflow() { let max = usize::try_from(isize::MAX).unwrap(); - let _ = u16::new_box_slice_zeroed((max / mem::size_of::()) + 1); + let _ = u16::new_box_slice_zeroed((max / size_of::()) + 1); } } } @@ -5053,7 +5053,7 @@ mod tests { test!(u8, layout(1, 1, None)); // Use `align_of` because `u64` alignment may be smaller than 8 on some // platforms. - test!(u64, layout(8, mem::align_of::(), None)); + test!(u64, layout(8, align_of::(), None)); test!(AU64, layout(8, 8, None)); test!(Option<&'static ()>, usize::LAYOUT); diff --git a/src/macro_util.rs b/src/macro_util.rs index 4936d4f035..5a1077176d 100644 --- a/src/macro_util.rs +++ b/src/macro_util.rs @@ -447,7 +447,7 @@ where I::Aliasing: AtLeast, R: AliasingSafeReason, { - static_assert!(Src, Dst => mem::size_of::() >= mem::size_of::()); + static_assert!(Src, Dst => size_of::() >= size_of::()); // SAFETY: This is a pointer cast, satisfying the following properties: // - `p as *mut Dst` addresses a subset of the `bytes` addressed by `src`, diff --git a/src/pointer/ptr.rs b/src/pointer/ptr.rs index 3725823fde..0b880a0866 100644 --- a/src/pointer/ptr.rs +++ b/src/pointer/ptr.rs @@ -1573,7 +1573,7 @@ mod tests { let t = slf.bikeshed_recall_valid().as_ref(); let bytes = { - let len = mem::size_of_val(t); + let len = size_of_val(t); let t: *const T = t; // SAFETY: // - We know `t`'s bytes are all initialized @@ -1596,7 +1596,7 @@ mod tests { // shouldn't be (see the comment above). assert_eq!(bytes, vec![0u8; bytes.len()]); - mem::size_of_val(t) + size_of_val(t) } for meta in metas.clone().into_iter() { diff --git a/src/ref.rs b/src/ref.rs index 052a3aadb1..22bc2aa63b 100644 --- a/src/ref.rs +++ b/src/ref.rs @@ -209,7 +209,7 @@ where { #[must_use = "has no side effects"] pub(crate) fn sized_from(bytes: B) -> Result, CastError> { - if bytes.len() != mem::size_of::() { + if bytes.len() != size_of::() { return Err(SizeError::new(bytes).into()); } if !util::aligned_to::<_, T>(bytes.deref()) { @@ -227,14 +227,14 @@ where { #[must_use = "has no side effects"] pub(crate) fn sized_from_prefix(bytes: B) -> Result<(Ref, B), CastError> { - if bytes.len() < mem::size_of::() { + if bytes.len() < size_of::() { return Err(SizeError::new(bytes).into()); } if !util::aligned_to::<_, T>(bytes.deref()) { return Err(AlignmentError::new(bytes).into()); } let (bytes, suffix) = - try_split_at(bytes, mem::size_of::()).map_err(|b| SizeError::new(b).into())?; + try_split_at(bytes, size_of::()).map_err(|b| SizeError::new(b).into())?; // SAFETY: We just validated alignment and that `bytes` is at least as // large as `T`. `try_split_at(bytes, mem::size_of::())?` ensures // that the new `bytes` is exactly the size of `T`. By safety @@ -247,7 +247,7 @@ where #[must_use = "has no side effects"] pub(crate) fn sized_from_suffix(bytes: B) -> Result<(B, Ref), CastError> { let bytes_len = bytes.len(); - let split_at = if let Some(split_at) = bytes_len.checked_sub(mem::size_of::()) { + let split_at = if let Some(split_at) = bytes_len.checked_sub(size_of::()) { split_at } else { return Err(SizeError::new(bytes).into()); @@ -1324,7 +1324,7 @@ mod tests { // will fail thanks to the buffer being too short; these are different // error paths, and while the error types are the same, the distinction // shows up in code coverage metrics. - let n = (usize::MAX / mem::size_of::()) + 1; + let n = (usize::MAX / size_of::()) + 1; assert!(Ref::<_, [AU64]>::from_bytes_with_elems(&buf.t[..], n).is_err()); assert!(Ref::<_, [AU64]>::from_bytes_with_elems(&buf.t[..], 2).is_err()); assert!(Ref::<_, [AU64]>::from_prefix_with_elems(&buf.t[..], n).is_err()); @@ -1358,7 +1358,7 @@ mod tests { // Fail due to arithmetic overflow. let buf = Align::<[u8; 16], AU64>::default(); - let unreasonable_len = usize::MAX / mem::size_of::() + 1; + let unreasonable_len = usize::MAX / size_of::() + 1; assert!(Ref::<_, [AU64]>::from_prefix_with_elems(&buf.t[..], unreasonable_len).is_err()); assert!(Ref::<_, [AU64]>::from_suffix_with_elems(&buf.t[..], unreasonable_len).is_err()); assert!(Ref::<_, [[u8; 8]]>::unaligned_from_prefix_with_elems( diff --git a/src/util.rs b/src/util.rs index f91e9475f1..01367e789a 100644 --- a/src/util.rs +++ b/src/util.rs @@ -8,7 +8,7 @@ use core::{ cell::UnsafeCell, - mem::{self, ManuallyDrop, MaybeUninit}, + mem::{ManuallyDrop, MaybeUninit}, num::{NonZeroUsize, Wrapping}, ptr::NonNull, sync::atomic::{ @@ -484,7 +484,7 @@ pub(crate) fn aligned_to(t: T) -> bool { // `mem::align_of::()` is guaranteed to return a non-zero value, which in // turn guarantees that this mod operation will not panic. #[allow(clippy::arithmetic_side_effects)] - let remainder = t.addr() % mem::align_of::(); + let remainder = t.addr() % align_of::(); remainder == 0 }