File tree 1 file changed +5
-5
lines changed
compiler/rustc_error_codes/src/error_codes
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.
3
3
4
4
Erroneous code example:
5
5
6
6
``` compile_fail,E0690
7
7
#[repr(transparent)]
8
- struct LengthWithUnit<U> { // error: transparent struct needs exactly one
8
+ struct LengthWithUnit<U> { // error: transparent struct needs at most one
9
9
value: f32, // non-zero-sized field, but has 2
10
10
unit: U,
11
11
}
12
12
```
13
13
14
14
Because 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.
17
17
Note that fields of zero-sized types (e.g., ` PhantomData ` ) can also exist
18
18
alongside the field that contains the actual data, they do not count for this
19
19
error. 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