Skip to content

Document why we don't require a repr for an enum to be FromZeroes #146

@joshlf

Description

@joshlf

When deriving FromZeroes on an enum, and in the safety requirements in the doc comment for that trait, we don't require the enum to have an explicit repr attribute. The justification is that, regardless of repr, an enum's discriminant is well-defined according to the reference. We should document this justification in the FromZeroes docs like we do for not requiring a repr for that trait (or for FromBytes).

Is this actually sound?

Though I was initially convinced by this argument, I'm now second-guessing myself since, even if the discriminant's semantic value is well-defined without an explicit repr, it's less clear that the layout of an enum (ie, how its bits are used to represent that semantic value) is well-defined.

If it turns out that this is actually unsound, then of course we should change the behavior before releasing rather than documenting a justification for it.

cc @djkoloski

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions