ZST's layout leaks #114391
Labels
A-crate-compat
Area: Impacting SemVer compatibility of crates in the ecosystem
A-repr
Area: the `#[repr(stuff)]` attribute
C-bug
Category: This is a bug.
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
I have the following code:
I would expect this code to be rejected - since
Zst
doesn't have a repr, it isn't guaranteed to be a ZST. As a result,repr(transparent)
should considerFoo
to have two non-ZST fields, which is illegal. Instead, it compiles successfully.One practical consequence is that, if I were to publish
Zst
in a crate, downstream crates could write code whose correctness depends onZst
's layout even though I didn't intend to expose it anywhere.Rust version: 1.71.0
The text was updated successfully, but these errors were encountered: