-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Missed niche optimization #119055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
this optimization should apply when variants have data too:
|
I was debugging this today together with @holodorum and observed an unexpected layout difference for the simplest possible inhabited enum: Is this intended? I'm not that familiar with the compiler code, but at least based on the name (i.e. Full output of
|
I think The normal niche-filling logic can offset the variant index→tag encoding around to accommodate whatever niche is available. To handle the values of Probably the most tricky part would be the tag↔discriminant codegen which would need a switch or lookup table for |
I tried this code:
I expected to see this happen:
Choice
has size 1Instead, this happened:
Choice
has size 2Meta
Rust version; 1.74.1
@rustbot label A-layout T-compiler
The text was updated successfully, but these errors were encountered: