Collapse #[repr(transparent)] types#619
Conversation
There was a problem hiding this comment.
This looks directionally good to me.
Insole_structural_newtype_field it talks about “one non-ZST field”, but repr(transparent) is more specific...ignored fields must be both size 0 and align 1. Looks like we are only checking is_zst()?
Also a few more projection tests might be good, something like:
#[repr(transparent)]
struct W(Inner);and then use W through &W, &mut W, raw pointers, arrays/slices, function args/returns, and nested transparent wrappers. Mostly want to make sure that once the wrapper type gets collapsed, accessing .0 still becomes a no-op and we don't accidentally emit an invalid access chain.
Might worth adding a test for an over-aligned ZST too:
#[repr(align(8))]
struct Blah;
#[repr(transparent)]
struct W {
inner: u32,
marker: Blah,
}marker is size 0 but it has alignment 8 so it can affect W’s layout.
Requesting changes, but feel free to put up again if you are merely extracting and don't want to change anything.
Supersedes #566