Skip to content

Commit e80b69d

Browse files
committed
Remove guarantees for enums with uninhabited variants
1 parent a8d29ad commit e80b69d

File tree

1 file changed

+4
-30
lines changed

1 file changed

+4
-30
lines changed

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

+4-30
Original file line numberDiff line numberDiff line change
@@ -401,34 +401,8 @@ enum DataCarryingSingleVariant {
401401
* `FieldSingleVariant` has the same layout as `UnitStruct`,
402402
* `DataCarryingSingleVariant` has the same layout as `SomeStruct`.
403403

404-
### Layout of multi-variant enums with one inhabited variant
404+
## Unresolved questions
405405

406-
> **NOTE**: the guarantees in this section have not been approved by an RFC process.
407-
408-
The layout of **multi-variant** enums with **one inhabited variant** is the same
409-
as that of the single-variant enum containing that same inhabited variant.
410-
411-
Here:
412-
413-
```rust
414-
# use std::mem::{size_of, align_of};
415-
struct SomeStruct { x: u32 }
416-
enum SingleVariantDataCarrying {
417-
DataCarryingVariant(SomeStruct),
418-
}
419-
enum Void0 {}
420-
enum Void1 {}
421-
enum MultiVariantSingleHabited {
422-
DataCarryingVariant(SomeStruct),
423-
Uninhabited0(Void0),
424-
Uninhabited1(Void1),
425-
}
426-
# fn main() {
427-
# use std::mem;
428-
# assert_eq!(size_of::<SingleVariantDataCarrying>(), size_of::<MultiVariantSingleHabited>());
429-
# assert_eq!(align_of::<SingleVariantDataCarrying>(), align_of::<MultiVariantSingleHabited>());
430-
# }
431-
```
432-
433-
the `MultiVariantSingleHabited` enum has the same layout as
434-
`SingleVariantDataCarrying`.
406+
See [Issue #79.](https://github.com/rust-rfcs/unsafe-code-guidelines/issues/79):
407+
408+
* Layout of multi-variant enums with one inhabited variant.

0 commit comments

Comments
 (0)