-
Notifications
You must be signed in to change notification settings - Fork 60
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
Layout of uninhabited types #165
Comments
We should describe when types are considered uninhabited, but I don't see any reason to special case layout of uninhabited types: there is no general relation between inhabitedness and (mentioning everything that anyone ever proposed as part of layout):
So the layout rules should largely be the same for inhabited and uninhabited types. The one possible exception is that perhaps the niche for uninhabited types becomes maximal, but we'd have to be careful there for the same reasons e.g. |
I think for Rust, "uninhabited" is a particular "call ABI": https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/layout/enum.Abi.html#variant.Uninhabited.
Agreed. We should also define the term precisely, because there are many kinds of "uninhabited" in Rust. Some types have "uninhabited" call ABI, some have no value satisfying the validity invariant, some have no value satisfying the safety invariant. |
Closing this as broadly decided. Someone could ask T-lang to guarantee a size of zero if that isn't documented yet |
I'll open a new issue for the sub-question of enums with uninhabited variants. EDIT: #443 |
We don't define the layout of uninhabited types anywhere.
We probably want to define that
!
andenum Void {}
have zero size, but as pointed out in #37,(!, i32)
is uninhabited but does not have zero-size.We should probably expand the struct, enum, union, and array sections with a sub-section about when are these types uninhabited, and what their layout is in this case.
The text was updated successfully, but these errors were encountered: