about summary refs log tree commit diff
path: root/compiler/rustc_data_structures/src/aligned.rs
diff options
context:
space:
mode:
authorMaybe Waffle <waffle.lapkin@gmail.com>2023-04-14 12:29:10 +0000
committerMaybe Waffle <waffle.lapkin@gmail.com>2023-04-14 12:31:49 +0000
commit014c6f208e59534cf36b11fdf43f8c90a304073f (patch)
treea280aac6dfb6f8848ed078796114fe6d334567e3 /compiler/rustc_data_structures/src/aligned.rs
parent36f5918bf169a7ab5ae24a5aad12dd6ecd20b8c4 (diff)
downloadrust-014c6f208e59534cf36b11fdf43f8c90a304073f.tar.gz
rust-014c6f208e59534cf36b11fdf43f8c90a304073f.zip
Use `ptr::Alignment` for extra coolness points
Diffstat (limited to 'compiler/rustc_data_structures/src/aligned.rs')
-rw-r--r--compiler/rustc_data_structures/src/aligned.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/compiler/rustc_data_structures/src/aligned.rs b/compiler/rustc_data_structures/src/aligned.rs
index 2d0adfe2ae3..7ac073539fb 100644
--- a/compiler/rustc_data_structures/src/aligned.rs
+++ b/compiler/rustc_data_structures/src/aligned.rs
@@ -1,10 +1,10 @@
-use std::mem;
+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
 /// types (e.g. slices or rustc's `List`s).
-pub const fn align_of<T: ?Sized + Aligned>() -> usize {
+pub const fn align_of<T: ?Sized + Aligned>() -> Alignment {
     T::ALIGN
 }
 
@@ -19,13 +19,13 @@ pub const fn align_of<T: ?Sized + Aligned>() -> usize {
 /// [`mem::align_of<Self>()`]: mem::align_of
 pub unsafe trait Aligned {
     /// Alignment of `Self`.
-    const ALIGN: usize;
+    const ALIGN: Alignment;
 }
 
 unsafe impl<T> Aligned for T {
-    const ALIGN: usize = mem::align_of::<Self>();
+    const ALIGN: Alignment = Alignment::of::<Self>();
 }
 
 unsafe impl<T> Aligned for [T] {
-    const ALIGN: usize = mem::align_of::<T>();
+    const ALIGN: Alignment = Alignment::of::<T>();
 }