Skip to content

Allow single-value enum types to have size 0 #15747

Closed
@mbrubeck

Description

@mbrubeck
enum Foo { Foo }
std::mem::size_of::<Foo>() // evaluates to 1

Since type Foo has only one value, it could have size zero. (This is already the case for single-valued struct types like struct Foo;.)

Open question: If this change is made, should Foo as uint still evaluate to 0 in the example above?

Note: It would still be possible to force a non-zero size using [#repr(...)] or enum Foo { Foo = 1 }.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationC-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions