Skip to content

Commit d525ac1

Browse files
committed
AlignmentEnum should just be repr(usize) now
Since it's cfg'd instead of type-aliased
1 parent ba7e63b commit d525ac1

6 files changed

+20
-37
lines changed

library/core/src/ptr/alignment.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ impl const Default for Alignment {
241241

242242
#[cfg(target_pointer_width = "16")]
243243
#[derive(Copy, Clone, PartialEq, Eq)]
244-
#[repr(u16)]
244+
#[repr(usize)]
245245
enum AlignmentEnum {
246246
_Align1Shl0 = 1 << 0,
247247
_Align1Shl1 = 1 << 1,
@@ -263,7 +263,7 @@ enum AlignmentEnum {
263263

264264
#[cfg(target_pointer_width = "32")]
265265
#[derive(Copy, Clone, PartialEq, Eq)]
266-
#[repr(u32)]
266+
#[repr(usize)]
267267
enum AlignmentEnum {
268268
_Align1Shl0 = 1 << 0,
269269
_Align1Shl1 = 1 << 1,
@@ -301,7 +301,7 @@ enum AlignmentEnum {
301301

302302
#[cfg(target_pointer_width = "64")]
303303
#[derive(Copy, Clone, PartialEq, Eq)]
304-
#[repr(u64)]
304+
#[repr(usize)]
305305
enum AlignmentEnum {
306306
_Align1Shl0 = 1 << 0,
307307
_Align1Shl1 = 1 << 1,

tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-abort.mir

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
88
let _2: std::ptr::NonNull<[T]>;
99
let mut _3: *mut [T];
1010
let mut _4: *const [T];
11-
let _12: ();
11+
let _11: ();
1212
scope 3 {
1313
let _8: std::ptr::alignment::AlignmentEnum;
1414
scope 4 {
@@ -31,12 +31,11 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
3131
scope 20 (inlined NonNull::<u8>::as_ptr) {
3232
}
3333
scope 21 (inlined std::alloc::dealloc) {
34-
let mut _11: usize;
34+
let mut _10: usize;
3535
scope 22 (inlined Layout::size) {
3636
}
3737
scope 23 (inlined Layout::align) {
3838
scope 24 (inlined std::ptr::Alignment::as_usize) {
39-
let mut _10: u32;
4039
}
4140
}
4241
}
@@ -87,16 +86,13 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
8786
bb2: {
8887
StorageLive(_9);
8988
_9 = copy _3 as *mut u8 (PtrToPtr);
90-
StorageLive(_11);
9189
StorageLive(_10);
9290
_10 = discriminant(_8);
93-
_11 = move _10 as usize (IntToInt);
94-
StorageDead(_10);
95-
_12 = alloc::alloc::__rust_dealloc(move _9, move _5, move _11) -> [return: bb3, unwind unreachable];
91+
_11 = alloc::alloc::__rust_dealloc(move _9, move _5, move _10) -> [return: bb3, unwind unreachable];
9692
}
9793

9894
bb3: {
99-
StorageDead(_11);
95+
StorageDead(_10);
10096
StorageDead(_9);
10197
goto -> bb4;
10298
}

tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.32bit.panic-unwind.mir

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
88
let _2: std::ptr::NonNull<[T]>;
99
let mut _3: *mut [T];
1010
let mut _4: *const [T];
11-
let _12: ();
11+
let _11: ();
1212
scope 3 {
1313
let _8: std::ptr::alignment::AlignmentEnum;
1414
scope 4 {
@@ -31,12 +31,11 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
3131
scope 20 (inlined NonNull::<u8>::as_ptr) {
3232
}
3333
scope 21 (inlined std::alloc::dealloc) {
34-
let mut _11: usize;
34+
let mut _10: usize;
3535
scope 22 (inlined Layout::size) {
3636
}
3737
scope 23 (inlined Layout::align) {
3838
scope 24 (inlined std::ptr::Alignment::as_usize) {
39-
let mut _10: u32;
4039
}
4140
}
4241
}
@@ -87,16 +86,13 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
8786
bb2: {
8887
StorageLive(_9);
8988
_9 = copy _3 as *mut u8 (PtrToPtr);
90-
StorageLive(_11);
9189
StorageLive(_10);
9290
_10 = discriminant(_8);
93-
_11 = move _10 as usize (IntToInt);
94-
StorageDead(_10);
95-
_12 = alloc::alloc::__rust_dealloc(move _9, move _5, move _11) -> [return: bb3, unwind unreachable];
91+
_11 = alloc::alloc::__rust_dealloc(move _9, move _5, move _10) -> [return: bb3, unwind unreachable];
9692
}
9793

9894
bb3: {
99-
StorageDead(_11);
95+
StorageDead(_10);
10096
StorageDead(_9);
10197
goto -> bb4;
10298
}

tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-abort.mir

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
88
let _2: std::ptr::NonNull<[T]>;
99
let mut _3: *mut [T];
1010
let mut _4: *const [T];
11-
let _12: ();
11+
let _11: ();
1212
scope 3 {
1313
let _8: std::ptr::alignment::AlignmentEnum;
1414
scope 4 {
@@ -31,12 +31,11 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
3131
scope 20 (inlined NonNull::<u8>::as_ptr) {
3232
}
3333
scope 21 (inlined std::alloc::dealloc) {
34-
let mut _11: usize;
34+
let mut _10: usize;
3535
scope 22 (inlined Layout::size) {
3636
}
3737
scope 23 (inlined Layout::align) {
3838
scope 24 (inlined std::ptr::Alignment::as_usize) {
39-
let mut _10: u64;
4039
}
4140
}
4241
}
@@ -87,16 +86,13 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
8786
bb2: {
8887
StorageLive(_9);
8988
_9 = copy _3 as *mut u8 (PtrToPtr);
90-
StorageLive(_11);
9189
StorageLive(_10);
9290
_10 = discriminant(_8);
93-
_11 = move _10 as usize (IntToInt);
94-
StorageDead(_10);
95-
_12 = alloc::alloc::__rust_dealloc(move _9, move _5, move _11) -> [return: bb3, unwind unreachable];
91+
_11 = alloc::alloc::__rust_dealloc(move _9, move _5, move _10) -> [return: bb3, unwind unreachable];
9692
}
9793

9894
bb3: {
99-
StorageDead(_11);
95+
StorageDead(_10);
10096
StorageDead(_9);
10197
goto -> bb4;
10298
}

tests/mir-opt/pre-codegen/drop_boxed_slice.generic_in_place.PreCodegen.after.64bit.panic-unwind.mir

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
88
let _2: std::ptr::NonNull<[T]>;
99
let mut _3: *mut [T];
1010
let mut _4: *const [T];
11-
let _12: ();
11+
let _11: ();
1212
scope 3 {
1313
let _8: std::ptr::alignment::AlignmentEnum;
1414
scope 4 {
@@ -31,12 +31,11 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
3131
scope 20 (inlined NonNull::<u8>::as_ptr) {
3232
}
3333
scope 21 (inlined std::alloc::dealloc) {
34-
let mut _11: usize;
34+
let mut _10: usize;
3535
scope 22 (inlined Layout::size) {
3636
}
3737
scope 23 (inlined Layout::align) {
3838
scope 24 (inlined std::ptr::Alignment::as_usize) {
39-
let mut _10: u64;
4039
}
4140
}
4241
}
@@ -87,16 +86,13 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () {
8786
bb2: {
8887
StorageLive(_9);
8988
_9 = copy _3 as *mut u8 (PtrToPtr);
90-
StorageLive(_11);
9189
StorageLive(_10);
9290
_10 = discriminant(_8);
93-
_11 = move _10 as usize (IntToInt);
94-
StorageDead(_10);
95-
_12 = alloc::alloc::__rust_dealloc(move _9, move _5, move _11) -> [return: bb3, unwind unreachable];
91+
_11 = alloc::alloc::__rust_dealloc(move _9, move _5, move _10) -> [return: bb3, unwind unreachable];
9692
}
9793

9894
bb3: {
99-
StorageDead(_11);
95+
StorageDead(_10);
10096
StorageDead(_9);
10197
goto -> bb4;
10298
}

tests/mir-opt/pre-codegen/drop_boxed_slice.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ pub unsafe fn generic_in_place<T: Copy>(ptr: *mut Box<[T]>) {
1313
// CHECK: [[B:_.+]] = copy [[ALIGN]] as std::ptr::Alignment (Transmute);
1414
// CHECK: [[C:_.+]] = move ([[B]].0: std::ptr::alignment::AlignmentEnum);
1515
// CHECK: [[D:_.+]] = discriminant([[C]]);
16-
// CHECK: [[E:_.+]] = move [[D]] as usize (IntToInt);
17-
// CHECK: = alloc::alloc::__rust_dealloc({{.+}}, move [[SIZE]], move [[E]]) ->
16+
// CHECK: = alloc::alloc::__rust_dealloc({{.+}}, move [[SIZE]], move [[D]]) ->
1817
std::ptr::drop_in_place(ptr)
1918
}

0 commit comments

Comments
 (0)