Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6521638

Browse files
authoredMar 7, 2025
Unrolled build for rust-lang#138034
Rollup merge of rust-lang#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
2 parents 59a9b9e + 5dfa2f5 commit 6521638

File tree

118 files changed

+402
-496
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+402
-496
lines changed
 

‎library/alloc/src/slice.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use core::borrow::{Borrow, BorrowMut};
1616
#[cfg(not(no_global_oom_handling))]
1717
use core::cmp::Ordering::{self, Less};
1818
#[cfg(not(no_global_oom_handling))]
19-
use core::mem::{self, MaybeUninit};
19+
use core::mem::MaybeUninit;
2020
#[cfg(not(no_global_oom_handling))]
2121
use core::ptr;
2222
#[unstable(feature = "array_chunks", issue = "74985")]
@@ -446,7 +446,7 @@ impl<T> [T] {
446446
// Avoids binary-size usage in cases where the alignment doesn't work out to make this
447447
// beneficial or on 32-bit platforms.
448448
let is_using_u32_as_idx_type_helpful =
449-
const { mem::size_of::<(K, u32)>() < mem::size_of::<(K, usize)>() };
449+
const { size_of::<(K, u32)>() < size_of::<(K, usize)>() };
450450

451451
// It's possible to instantiate this for u8 and u16 but, doing so is very wasteful in terms
452452
// of compile-times and binary-size, the peak saved heap memory for u16 is (u8 + u16) -> 4

‎library/alloc/src/string.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,14 @@ use crate::vec::{self, Vec};
119119
/// the same `char`s:
120120
///
121121
/// ```
122-
/// use std::mem;
123-
///
124122
/// // `s` is ASCII which represents each `char` as one byte
125123
/// let s = "hello";
126124
/// assert_eq!(s.len(), 5);
127125
///
128126
/// // A `char` array with the same contents would be longer because
129127
/// // every `char` is four bytes
130128
/// let s = ['h', 'e', 'l', 'l', 'o'];
131-
/// let size: usize = s.into_iter().map(|c| mem::size_of_val(&c)).sum();
129+
/// let size: usize = s.into_iter().map(|c| size_of_val(&c)).sum();
132130
/// assert_eq!(size, 20);
133131
///
134132
/// // However, for non-ASCII strings, the difference will be smaller
@@ -137,7 +135,7 @@ use crate::vec::{self, Vec};
137135
/// assert_eq!(s.len(), 20);
138136
///
139137
/// let s = ['💖', '💖', '💖', '💖', '💖'];
140-
/// let size: usize = s.into_iter().map(|c| mem::size_of_val(&c)).sum();
138+
/// let size: usize = s.into_iter().map(|c| size_of_val(&c)).sum();
141139
/// assert_eq!(size, 20);
142140
/// ```
143141
///
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.