-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-layoutArea: Memory layout of typesArea: Memory layout of typesC-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchCategory: An issue highlighting optimization opportunities or PRs implementing suchT-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.
Description
I tried this code:
enum En1 {
Bool(bool),
Other(En2),
}
#[repr(u8)]
enum En2 {
Six = 6,
Seven = 7,
}
fn main() {
dbg!(size_of::<En1>());
}
I expected to see this happen: En1
has size 1
Instead, this happened: En1
has size 2
This will become more of an issue with range types on the horizon
Meta
rustc --version --verbose
:
1.85.1
AmityWilder
Metadata
Metadata
Assignees
Labels
A-layoutArea: Memory layout of typesArea: Memory layout of typesC-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchCategory: An issue highlighting optimization opportunities or PRs implementing suchT-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.