1
Fork 0

repr(align) <= 4 should still be byval

This commit is contained in:
Erik Desjardins 2023-06-11 17:05:26 -04:00
parent 2591c30eaf
commit 7e933b4e26
13 changed files with 120 additions and 107 deletions

View file

@ -40,7 +40,7 @@ pub trait LayoutCalculator {
largest_niche,
align,
size,
has_repr_align: false,
repr_align: None,
}
}
@ -123,7 +123,7 @@ pub trait LayoutCalculator {
largest_niche: None,
align: dl.i8_align,
size: Size::ZERO,
has_repr_align: false,
repr_align: None,
}
}
@ -424,7 +424,7 @@ pub trait LayoutCalculator {
largest_niche,
size,
align,
has_repr_align: repr.align.is_some(),
repr_align: repr.align,
};
Some(TmpLayout { layout, variants: variant_layouts })
@ -694,7 +694,7 @@ pub trait LayoutCalculator {
abi,
align,
size,
has_repr_align: repr.align.is_some(),
repr_align: repr.align,
};
let tagged_layout = TmpLayout { layout: tagged_layout, variants: layout_variants };
@ -813,7 +813,7 @@ pub trait LayoutCalculator {
largest_niche: None,
align,
size: size.align_to(align.abi),
has_repr_align: repr.align.is_some(),
repr_align: repr.align,
})
}
}
@ -1111,9 +1111,9 @@ fn univariant(
abi = Abi::Uninhabited;
}
let has_repr_align = repr.align.is_some()
|| repr.transparent()
&& layout_of_single_non_zst_field.map_or(false, |l| l.has_repr_align());
let repr_align = repr.align.or_else(|| {
if repr.transparent() { layout_of_single_non_zst_field?.repr_align() } else { None }
});
Some(LayoutS {
variants: Variants::Single { index: FIRST_VARIANT },
@ -1122,7 +1122,7 @@ fn univariant(
largest_niche,
align,
size,
has_repr_align,
repr_align,
})
}

View file

@ -1532,10 +1532,10 @@ pub struct LayoutS {
pub align: AbiAndPrefAlign,
pub size: Size,
/// True if the alignment was explicitly requested with `repr(align)`.
/// The alignment explicitly requested with `repr(align)`.
/// Only used on i686-windows, where the argument passing ABI is different when alignment is
/// requested, even if the requested alignment is equal to or less than the natural alignment.
pub has_repr_align: bool,
/// requested, even if the requested alignment is equal to the natural alignment.
pub repr_align: Option<Align>,
}
impl LayoutS {
@ -1550,7 +1550,7 @@ impl LayoutS {
largest_niche,
size,
align,
has_repr_align: false,
repr_align: None,
}
}
}
@ -1560,7 +1560,7 @@ impl fmt::Debug for LayoutS {
// This is how `Layout` used to print before it become
// `Interned<LayoutS>`. We print it like this to avoid having to update
// expected output in a lot of tests.
let LayoutS { size, align, abi, fields, largest_niche, variants, has_repr_align } = self;
let LayoutS { size, align, abi, fields, largest_niche, variants, repr_align } = self;
f.debug_struct("Layout")
.field("size", size)
.field("align", align)
@ -1568,7 +1568,7 @@ impl fmt::Debug for LayoutS {
.field("fields", fields)
.field("largest_niche", largest_niche)
.field("variants", variants)
.field("has_repr_align", has_repr_align)
.field("repr_align", repr_align)
.finish()
}
}
@ -1609,8 +1609,8 @@ impl<'a> Layout<'a> {
self.0.0.size
}
pub fn has_repr_align(self) -> bool {
self.0.0.has_repr_align
pub fn repr_align(self) -> Option<Align> {
self.0.0.repr_align
}
/// Whether the layout is from a type that implements [`std::marker::PointerLike`].