Skip to content

Add a note about uninhabited-struct layout optimization #346

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

scottmcm
Copy link
Member

I think this is pretty settled but don't know that we had a good link about it, so figured I'd write this up.

that never reaching the `assume_init` part, it's still unlikely that this occurs frequently.

There *is* still interest in doing optimizations like this on *sum* types, however. There's more
to potentially be gained there since one variant of a `union` or `enum` being uninhabited doesn't
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am very surprised to see union mentioned here. As far as I am concerned those are syntactic sugar for transmutes, and I would be very surprised if we could now start doing such optimizations without breaking tons of code. (I think even the train for "fields not at offset 0" may have sailed, many people forget to set repr(C).)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I wrote that without thinking about it that hard, and looking again you're right, I don't see this happening on unions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants