-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Outdated docs claim that #[repr(transparent)]
on empty structs is not permitted
#129029
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
#[repr(transparent)]
for empty struct#[repr(transparent)]
for empty struct
This regressed somewhere in 1.55 |
This is intentional: #86279 |
Notably, the difference between empty (variantless) enums and empty (fieldless) structs are that the former are uninhabited. Fieldless structs just have 0 size. |
We should update the reference anyways to note this change in rules. I still don't consider this to be a bug according to these rules: |
Yes, reading the RFC, there is no bug, but the stale documentation needs to be fixed so people are not misled. |
#[repr(transparent)]
for empty struct#[repr(transparent)]
on empty struct is not permitted
#[repr(transparent)]
on empty struct is not permitted#[repr(transparent)]
on empty structs is not permitted
This code compiles:
Going by the docs for
#[repr(transparent)]
:... it seems like the compiler should reject that code, with diagnostics similar to those it emits for an empty transparent enum:
The text was updated successfully, but these errors were encountered: