diff options
Diffstat (limited to 'library/core/src/slice/mod.rs')
| -rw-r--r-- | library/core/src/slice/mod.rs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 4055038b958..3570d8d0876 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -3893,9 +3893,9 @@ impl<T> [T] { // Explicitly wrap the function call in a const block so it gets // constant-evaluated even in debug mode. - let gcd: usize = const { gcd(mem::size_of::<T>(), mem::size_of::<U>()) }; - let ts: usize = mem::size_of::<U>() / gcd; - let us: usize = mem::size_of::<T>() / gcd; + let gcd: usize = const { gcd(size_of::<T>(), size_of::<U>()) }; + let ts: usize = size_of::<U>() / gcd; + let us: usize = size_of::<T>() / gcd; // Armed with this knowledge, we can find how many `U`s we can fit! let us_len = self.len() / ts * us; @@ -3945,7 +3945,7 @@ impl<T> [T] { // ptr.align_offset. let ptr = self.as_ptr(); // SAFETY: See the `align_to_mut` method for the detailed safety comment. - let offset = unsafe { crate::ptr::align_offset(ptr, mem::align_of::<U>()) }; + let offset = unsafe { crate::ptr::align_offset(ptr, align_of::<U>()) }; if offset > self.len() { (self, &[], &[]) } else { @@ -3955,7 +3955,7 @@ impl<T> [T] { #[cfg(miri)] crate::intrinsics::miri_promise_symbolic_alignment( rest.as_ptr().cast(), - mem::align_of::<U>(), + align_of::<U>(), ); // SAFETY: now `rest` is definitely aligned, so `from_raw_parts` below is okay, // since the caller guarantees that we can transmute `T` to `U` safely. @@ -4016,7 +4016,7 @@ impl<T> [T] { // valid pointer `ptr` (it comes from a reference to `self`) and with // a size that is a power of two (since it comes from the alignment for U), // satisfying its safety constraints. - let offset = unsafe { crate::ptr::align_offset(ptr, mem::align_of::<U>()) }; + let offset = unsafe { crate::ptr::align_offset(ptr, align_of::<U>()) }; if offset > self.len() { (self, &mut [], &mut []) } else { @@ -4028,7 +4028,7 @@ impl<T> [T] { #[cfg(miri)] crate::intrinsics::miri_promise_symbolic_alignment( mut_ptr.cast() as *const (), - mem::align_of::<U>(), + align_of::<U>(), ); // We can't use `rest` again after this, that would invalidate its alias `mut_ptr`! // SAFETY: see comments for `align_to`. @@ -4099,7 +4099,7 @@ impl<T> [T] { // These are expected to always match, as vector types are laid out like // arrays per <https://llvm.org/docs/LangRef.html#vector-type>, but we // might as well double-check since it'll optimize away anyhow. - assert_eq!(mem::size_of::<Simd<T, LANES>>(), mem::size_of::<[T; LANES]>()); + assert_eq!(size_of::<Simd<T, LANES>>(), size_of::<[T; LANES]>()); // SAFETY: The simd types have the same layout as arrays, just with // potentially-higher alignment, so the de-facto transmutes are sound. @@ -4135,7 +4135,7 @@ impl<T> [T] { // These are expected to always match, as vector types are laid out like // arrays per <https://llvm.org/docs/LangRef.html#vector-type>, but we // might as well double-check since it'll optimize away anyhow. - assert_eq!(mem::size_of::<Simd<T, LANES>>(), mem::size_of::<[T; LANES]>()); + assert_eq!(size_of::<Simd<T, LANES>>(), size_of::<[T; LANES]>()); // SAFETY: The simd types have the same layout as arrays, just with // potentially-higher alignment, so the de-facto transmutes are sound. @@ -4700,11 +4700,11 @@ impl<T> [T] { let byte_offset = elem_start.wrapping_sub(self_start); - if byte_offset % mem::size_of::<T>() != 0 { + if byte_offset % size_of::<T>() != 0 { return None; } - let offset = byte_offset / mem::size_of::<T>(); + let offset = byte_offset / size_of::<T>(); if offset < self.len() { Some(offset) } else { None } } @@ -4754,11 +4754,11 @@ impl<T> [T] { let byte_start = subslice_start.wrapping_sub(self_start); - if byte_start % core::mem::size_of::<T>() != 0 { + if byte_start % size_of::<T>() != 0 { return None; } - let start = byte_start / core::mem::size_of::<T>(); + let start = byte_start / size_of::<T>(); let end = start.wrapping_add(subslice.len()); if start <= self.len() && end <= self.len() { Some(start..end) } else { None } |
