You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 ](#77841 (comment)) 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.
Copy file name to clipboardExpand all lines: compiler/rustc_hir_analysis/messages.ftl
+6-6
Original file line number
Diff line number
Diff line change
@@ -304,13 +304,13 @@ hir_analysis_transparent_enum_variant = transparent enum needs exactly one varia
304
304
.many_label = too many variants in `{$path}`
305
305
.multi_label = variant here
306
306
307
-
hir_analysis_transparent_non_zero_sized = transparent {$desc} needs at most one non-zero-sized field, but has {$field_count}
308
-
.label = needs at most one non-zero-sized field, but has {$field_count}
309
-
.labels = this field is non-zero-sized
307
+
hir_analysis_transparent_non_zero_sized = transparent {$desc} needs at most one field with non-trivial size or alignment, but has {$field_count}
308
+
.label = needs at most one field with non-trivial size or alignment, but has {$field_count}
309
+
.labels = this field has non-zero size or requires alignment
310
310
311
-
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}
312
-
.label = needs at most one non-zero-sized field, but has {$field_count}
313
-
.labels = this field is non-zero-sized
311
+
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}
312
+
.label = needs at most one field with non-trivial size or alignment, but has {$field_count}
313
+
.labels = this field has non-zero size or requires alignment
0 commit comments