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.
These functions were added to all preludes in Rust 1.80.
This commit is contained in:
@@ -2,10 +2,8 @@ use std::ptr::Alignment;
|
||||
|
||||
/// Returns the ABI-required minimum alignment of a type in bytes.
|
||||
///
|
||||
/// This is equivalent to [`mem::align_of`], but also works for some unsized
|
||||
/// This is equivalent to [`align_of`], but also works for some unsized
|
||||
/// types (e.g. slices or rustc's `List`s).
|
||||
///
|
||||
/// [`mem::align_of`]: std::mem::align_of
|
||||
pub const fn align_of<T: ?Sized + Aligned>() -> Alignment {
|
||||
T::ALIGN
|
||||
}
|
||||
@@ -15,10 +13,10 @@ pub const fn align_of<T: ?Sized + Aligned>() -> Alignment {
|
||||
/// # Safety
|
||||
///
|
||||
/// `Self::ALIGN` must be equal to the alignment of `Self`. For sized types it
|
||||
/// is [`mem::align_of<Self>()`], for unsized types it depends on the type, for
|
||||
/// is [`align_of::<Self>()`], for unsized types it depends on the type, for
|
||||
/// example `[T]` has alignment of `T`.
|
||||
///
|
||||
/// [`mem::align_of<Self>()`]: std::mem::align_of
|
||||
/// [`align_of::<Self>()`]: align_of
|
||||
pub unsafe trait Aligned {
|
||||
/// Alignment of `Self`.
|
||||
const ALIGN: Alignment;
|
||||
|
||||
Reference in New Issue
Block a user