File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -1193,12 +1193,32 @@ discriminant values so that they fit within the existing type.
1193
1193
"## ,
1194
1194
1195
1195
E0084 : r##"
1196
+ An unsupported representation was attempted on a zero-variant enum.
1197
+
1198
+ Erroneous code example:
1199
+
1200
+ ```compile_fail
1201
+ #[repr(i32)]
1202
+ enum NightWatch {} // error: unsupported representation for zero-variant enum
1203
+ ```
1204
+
1196
1205
It is impossible to define an integer type to be used to represent zero-variant
1197
1206
enum values because there are no zero-variant enum values. There is no way to
1198
- construct an instance of the following type using only safe code:
1207
+ construct an instance of the following type using only safe code. So you have
1208
+ two solutions. Either you add variants in your enum:
1209
+
1210
+ ```
1211
+ #[repr(i32)]
1212
+ enum NightWatch {
1213
+ JohnSnow,
1214
+ Commander,
1215
+ }
1216
+ ```
1217
+
1218
+ or you remove the integer represention of your enum:
1199
1219
1200
1220
```
1201
- enum Empty {}
1221
+ enum NightWatch {}
1202
1222
```
1203
1223
"## ,
1204
1224
You can’t perform that action at this time.
0 commit comments