diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-03-07 10:12:44 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-07 10:12:44 +0100 |
| commit | b8346320717d4080d6fa176b4efbd5b1a642db4a (patch) | |
| tree | 4e46716aab177407f90ae19f165b4920b4686506 /library/core/src/num/mod.rs | |
| parent | 6e7d1353d1fc203c648d0714d576a1b2be93817c (diff) | |
| parent | 5dfa2f5fd0d2e1cdf650679d709ae71bbad7d87a (diff) | |
| download | rust-b8346320717d4080d6fa176b4efbd5b1a642db4a.tar.gz rust-b8346320717d4080d6fa176b4efbd5b1a642db4a.zip | |
Rollup merge of #138034 - thaliaarchi:use-prelude-size-of, r=tgross35
library: Use `size_of` from the prelude instead of imported
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them.
These functions were added to all preludes in Rust 1.80.
try-job: test-various
try-job: x86_64-gnu
try-job: x86_64-msvc-1
Diffstat (limited to 'library/core/src/num/mod.rs')
| -rw-r--r-- | library/core/src/num/mod.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/library/core/src/num/mod.rs b/library/core/src/num/mod.rs index 80a38a6013d..151e128cd78 100644 --- a/library/core/src/num/mod.rs +++ b/library/core/src/num/mod.rs @@ -1241,7 +1241,7 @@ impl usize { /// Returns an `usize` where every byte is equal to `x`. #[inline] pub(crate) const fn repeat_u8(x: u8) -> usize { - usize::from_ne_bytes([x; mem::size_of::<usize>()]) + usize::from_ne_bytes([x; size_of::<usize>()]) } /// Returns an `usize` where every byte pair is equal to `x`. @@ -1249,7 +1249,7 @@ impl usize { pub(crate) const fn repeat_u16(x: u16) -> usize { let mut r = 0usize; let mut i = 0; - while i < mem::size_of::<usize>() { + while i < size_of::<usize>() { // Use `wrapping_shl` to make it work on targets with 16-bit `usize` r = r.wrapping_shl(16) | (x as usize); i += 2; @@ -1330,7 +1330,7 @@ pub enum FpCategory { #[inline(always)] #[unstable(issue = "none", feature = "std_internals")] pub const fn can_not_overflow<T>(radix: u32, is_signed_ty: bool, digits: &[u8]) -> bool { - radix <= 16 && digits.len() <= mem::size_of::<T>() * 2 - is_signed_ty as usize + radix <= 16 && digits.len() <= size_of::<T>() * 2 - is_signed_ty as usize } #[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))] |
