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

@ -435,7 +435,7 @@ pub enum Res<Id = hir::HirId> {
/// mention any generic parameters to allow the following with `min_const_generics`:
/// ```
/// # struct Foo;
/// impl Foo { fn test() -> [u8; std::mem::size_of::<Self>()] { todo!() } }
/// impl Foo { fn test() -> [u8; size_of::<Self>()] { todo!() } }
///
/// struct Bar([u8; baz::<Self>()]);
/// const fn baz<T>() -> usize { 10 }
@ -445,7 +445,7 @@ pub enum Res<Id = hir::HirId> {
/// compat lint:
/// ```
/// fn foo<T>() {
/// let _bar = [1_u8; std::mem::size_of::<*mut T>()];
/// let _bar = [1_u8; size_of::<*mut T>()];
/// }
/// ```
// FIXME(generic_const_exprs): Remove this bodge once that feature is stable.