1
Fork 0

Rollup merge of #138040 - thaliaarchi:use-prelude-size-of.compiler, r=compiler-errors

compiler: 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. Apply this change across the compiler.

These functions were added to all preludes in Rust 1.80.

r? ``@compiler-errors``
This commit is contained in:
Matthias Krüger 2025-03-09 10:34:49 +01:00 committed by GitHub
commit c6662879b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 64 additions and 74 deletions

View file

@ -107,12 +107,12 @@ impl<'k> StatCollector<'k> {
let node = self.nodes.entry(label1).or_insert(Node::new());
node.stats.count += 1;
node.stats.size = std::mem::size_of_val(val);
node.stats.size = size_of_val(val);
if let Some(label2) = label2 {
let subnode = node.subnodes.entry(label2).or_insert(NodeStats::new());
subnode.count += 1;
subnode.size = std::mem::size_of_val(val);
subnode.size = size_of_val(val);
}
}

View file

@ -39,7 +39,7 @@ impl RWUTable {
/// Size of packed RWU in bits.
const RWU_BITS: usize = 4;
/// Size of a word in bits.
const WORD_BITS: usize = std::mem::size_of::<u8>() * 8;
const WORD_BITS: usize = size_of::<u8>() * 8;
/// Number of packed RWUs that fit into a single word.
const WORD_RWU_COUNT: usize = Self::WORD_BITS / Self::RWU_BITS;