Skip to content

Commit a3c6369

Browse files
authored
Rollup merge of rust-lang#144667 - scottmcm:alignment-is-usize, r=tgross35
`AlignmentEnum` should just be `repr(usize)` now These used to use specific sizes because they were compiled on all widths. But now that the types themselves are `#[cfg]`'d, we can save some conversions by having it always be `repr(usize)`.
2 parents bf1b45a + df69b7d commit a3c6369

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

core/src/ptr/alignment.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::enum_clike_unportable_variant)]
2+
13
use crate::num::NonZero;
24
use crate::ub_checks::assert_unsafe_precondition;
35
use crate::{cmp, fmt, hash, mem, num};
@@ -241,7 +243,7 @@ impl const Default for Alignment {
241243

242244
#[cfg(target_pointer_width = "16")]
243245
#[derive(Copy, Clone, PartialEq, Eq)]
244-
#[repr(u16)]
246+
#[repr(usize)]
245247
enum AlignmentEnum {
246248
_Align1Shl0 = 1 << 0,
247249
_Align1Shl1 = 1 << 1,
@@ -263,7 +265,7 @@ enum AlignmentEnum {
263265

264266
#[cfg(target_pointer_width = "32")]
265267
#[derive(Copy, Clone, PartialEq, Eq)]
266-
#[repr(u32)]
268+
#[repr(usize)]
267269
enum AlignmentEnum {
268270
_Align1Shl0 = 1 << 0,
269271
_Align1Shl1 = 1 << 1,
@@ -301,7 +303,7 @@ enum AlignmentEnum {
301303

302304
#[cfg(target_pointer_width = "64")]
303305
#[derive(Copy, Clone, PartialEq, Eq)]
304-
#[repr(u64)]
306+
#[repr(usize)]
305307
enum AlignmentEnum {
306308
_Align1Shl0 = 1 << 0,
307309
_Align1Shl1 = 1 << 1,

0 commit comments

Comments
 (0)