Skip to content

Commit cf9647e

Browse files
committed
Remove guarantees for enums with uninhabited variants
1 parent 5dccc8b commit cf9647e

File tree

1 file changed

+4
-36
lines changed

1 file changed

+4
-36
lines changed

Diff for: reference/src/layout/enums.md

+4-36
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,8 @@ enum Enum1<T> {
356356
> **NOTE**: the guarantees in this section have not been approved by an RFC process.
357357

358358
**Data-carrying** enums with a single variant without a `repr()` annotation have
359-
the same SAFNC-layout as the variant field. **Fieldless** enums with a single variant
360-
have the same SAFNC-layout as a unit struct.
359+
the same layout as the variant field. **Fieldless** enums with a single variant
360+
have the same layout as a unit struct.
361361

362362
For example, here:
363363

@@ -371,37 +371,5 @@ enum DataCarryingSingleVariant {
371371
}
372372
```
373373

374-
* `FieldSingleVariant` has the same SAFNC-layout as `UnitStruct`,
375-
* `DataCarryingSingleVariant` has the same SAFNC-layout as `SomeStruct`.
376-
377-
### Layout of multi-variant enums with one inhabited variant
378-
379-
> **NOTE**: the guarantees in this section have not been approved by an RFC process.
380-
381-
The layout of **multi-variant** enums with **one inhabited variant** is the same
382-
as that of the single-variant enum containing that same inhabited variant.
383-
384-
Here:
385-
386-
```rust
387-
# use std::mem::{size_of, align_of};
388-
struct SomeStruct { x: u32 }
389-
enum SingleVariantDataCarrying {
390-
DataCarryingVariant(SomeStruct),
391-
}
392-
enum Void0 {}
393-
enum Void1 {}
394-
enum MultiVariantSingleHabited {
395-
DataCarryingVariant(SomeStruct),
396-
Uninhabited0(Void0),
397-
Uninhabited1(Void1),
398-
}
399-
# fn main() {
400-
# use std::mem;
401-
# assert_eq!(size_of::<SingleVariantDataCarrying>(), size_of::<MultiVariantSingleHabited>());
402-
# assert_eq!(align_of::<SingleVariantDataCarrying>(), align_of::<MultiVariantSingleHabited>());
403-
# }
404-
```
405-
406-
the `MultiVariantSingleHabited` enum has the same layout as
407-
`SingleVariantDataCarrying`.
374+
* `FieldSingleVariant` has the same layout as `UnitStruct`,
375+
* `DataCarryingSingleVariant` has the same layout as `SomeStruct`.

0 commit comments

Comments
 (0)