1
Fork 0

move has_repr to layout, handle repr(transparent) properly

This commit is contained in:
Erik Desjardins 2023-06-11 13:43:49 -04:00
parent 65d11b5c65
commit 00b3eca0df
6 changed files with 34 additions and 25 deletions

View file

@ -1531,6 +1531,11 @@ pub struct LayoutS {
pub align: AbiAndPrefAlign,
pub size: Size,
/// True if the alignment was 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,
}
impl LayoutS {
@ -1545,6 +1550,7 @@ impl LayoutS {
largest_niche,
size,
align,
has_repr_align: false,
}
}
}
@ -1554,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 } = self;
let LayoutS { size, align, abi, fields, largest_niche, variants, has_repr_align } = self;
f.debug_struct("Layout")
.field("size", size)
.field("align", align)
@ -1562,6 +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)
.finish()
}
}
@ -1602,6 +1609,10 @@ impl<'a> Layout<'a> {
self.0.0.size
}
pub fn has_repr_align(self) -> bool {
self.0.0.has_repr_align
}
/// Whether the layout is from a type that implements [`std::marker::PointerLike`].
///
/// Currently, that means that the type is pointer-sized, pointer-aligned,