Auto merge of #115334 - RalfJung:transparent-aligned-zst, r=compiler-errors
repr(transparent): it's fine if the one non-1-ZST field is a ZST This code currently gets rejected: ```rust #[repr(transparent)] struct MyType([u16; 0]) ``` That clearly seems like a bug to me: `repr(transparent)` [got defined ](https://github.com/rust-lang/rust/issues/77841#issuecomment-716575747) as having any number of 1-ZST fields plus optionally one more field; `MyType` clearly satisfies that definition. This PR changes the `repr(transparent)` logic to actually match that definition.
This commit is contained in:
commit
203c57dbe2
5 changed files with 91 additions and 88 deletions
|
@ -304,13 +304,13 @@ hir_analysis_transparent_enum_variant = transparent enum needs exactly one varia
|
|||
.many_label = too many variants in `{$path}`
|
||||
.multi_label = variant here
|
||||
|
||||
hir_analysis_transparent_non_zero_sized = transparent {$desc} needs at most one non-zero-sized field, but has {$field_count}
|
||||
.label = needs at most one non-zero-sized field, but has {$field_count}
|
||||
.labels = this field is non-zero-sized
|
||||
hir_analysis_transparent_non_zero_sized = transparent {$desc} needs at most one field with non-trivial size or alignment, but has {$field_count}
|
||||
.label = needs at most one field with non-trivial size or alignment, but has {$field_count}
|
||||
.labels = this field has non-zero size or requires alignment
|
||||
|
||||
hir_analysis_transparent_non_zero_sized_enum = the variant of a transparent {$desc} needs at most one non-zero-sized field, but has {$field_count}
|
||||
.label = needs at most one non-zero-sized field, but has {$field_count}
|
||||
.labels = this field is non-zero-sized
|
||||
hir_analysis_transparent_non_zero_sized_enum = the variant of a transparent {$desc} needs at most one field with non-trivial size or alignment, but has {$field_count}
|
||||
.label = needs at most one field with non-trivial size or alignment, but has {$field_count}
|
||||
.labels = this field has non-zero size or requires alignment
|
||||
|
||||
hir_analysis_typeof_reserved_keyword_used =
|
||||
`typeof` is a reserved keyword but unimplemented
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue