-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Uninhabited repr(uX) enum shouldn't have size zero #146984
Copy link
Copy link
Closed
Labels
A-enumArea: Enums (discriminated unions, or more generally ADTs (algebraic data types))Area: Enums (discriminated unions, or more generally ADTs (algebraic data types))A-layoutArea: Memory layout of typesArea: Memory layout of typesA-reprArea: the `#[repr(stuff)]` attributeArea: the `#[repr(stuff)]` attributeC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Metadata
Metadata
Assignees
Labels
A-enumArea: Enums (discriminated unions, or more generally ADTs (algebraic data types))Area: Enums (discriminated unions, or more generally ADTs (algebraic data types))A-layoutArea: Memory layout of typesArea: Memory layout of typesA-reprArea: the `#[repr(stuff)]` attributeArea: the `#[repr(stuff)]` attributeC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Type
Fields
Give feedbackNo fields configured for issues without a type.
I tried this code:
I expected
MyEnumandMyEnumReprto have the same size, since this is the desugaring given as an example in the reference.Instead,
MyEnumhas size 0, whileMyEnumReprhas size 4.Discovered by masterjason9637 on the rust community discord.
Meta
Reproducible on the playground with version
1.92.0-nightly (2025-09-23 975e6c8fec280816d24f)