File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
compiler/rustc_error_codes/src/error_codes Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 1- A struct with the representation hint ` repr(transparent) ` had zero or more than
2- one fields that were not guaranteed to be zero-sized.
1+ A struct with the representation hint ` repr(transparent) ` had two or more fields
2+ that were not guaranteed to be zero-sized.
33
44Erroneous code example:
55
66``` compile_fail,E0690
77#[repr(transparent)]
8- struct LengthWithUnit<U> { // error: transparent struct needs exactly one
8+ struct LengthWithUnit<U> { // error: transparent struct needs at most one
99 value: f32, // non-zero-sized field, but has 2
1010 unit: U,
1111}
1212```
1313
1414Because transparent structs are represented exactly like one of their fields at
15- run time, said field must be uniquely determined. If there is no field, or if
16- there are multiple fields, it is not clear how the struct should be represented.
15+ run time, said field must be uniquely determined. If there are multiple fields,
16+ it is not clear how the struct should be represented.
1717Note that fields of zero-sized types (e.g., ` PhantomData ` ) can also exist
1818alongside the field that contains the actual data, they do not count for this
1919error. When generic types are involved (as in the above example), an error is
You can’t perform that action at this time.
0 commit comments