don't inhibit random field reordering on repr(packed(1))

This commit is contained in:
Ralf Jung 2024-05-21 14:07:02 +02:00
parent e875391458
commit 37aeb75eb6
6 changed files with 14 additions and 19 deletions

View file

@ -278,7 +278,7 @@ fn reduce_ty<'tcx>(cx: &LateContext<'tcx>, mut ty: Ty<'tcx>) -> ReducedTy<'tcx>
ty = sized_ty;
continue;
}
if def.repr().inhibit_struct_field_reordering_opt() {
if def.repr().inhibit_struct_field_reordering() {
ReducedTy::OrderedFields(Some(sized_ty))
} else {
ReducedTy::UnorderedFields(ty)

View file

@ -1,7 +1,7 @@
#![allow(dead_code)]
// We use packed structs to get around alignment restrictions
#[repr(packed)]
#[repr(C, packed)]
struct Data {
pad: u8,
ptr: &'static i32,

View file

@ -7,7 +7,7 @@ pub struct Aligned {
_pad: [u8; 11],
packed: Packed,
}
#[repr(packed)]
#[repr(C, packed)]
#[derive(Default, Copy, Clone)]
pub struct Packed {
_pad: [u8; 5],