-
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
Does the repr(transparent) guarantee work for fields that are empty types? #485
Comments
That's a good question. I don't even know what the intention is here; this needs to be brought up with the lang team. (This is not a t-opsem question.) Currently, we give |
It probably does not matter, though, because the ABI for an empty type is "Does not exist", and even if it did match ABI, it would be immediate UB to call a function with |
However this might impact layout, e.g. |
@chorman0773 it does matter when determining the impact of the transparent type on the repr of an enum wrapping it though that also gets us into questions of transitivity #486 |
|
They don't always propagate, true. ( But there's no fundamental reason why they shouldn't propagate through |
Oh, that's something that probably ought to be documented carefully.
This would be a good guarantee to pin down! |
This does affect the ABI for function returns, since a function can diverge, so it's perfectly reasonable to have a |
Context: hyperium/hyper#3500
The
repr(transparent)
RFC states:The reference states:
It's unclear if this applies to situations where a contained type is an empty type (
enum Empty {}
)For example, what are the implications of this?
From the RFC, this type is not "logically equvialent to a newtype", and
repr(transparent)
should not apply. From the reference, the other field is size 0 alignment 1, sorepr(transparent)
should make the repr the same asString
(I believe this is the current behavior in rustc), but it does feel like an edge case.It would be nice to have this explicitly documented, rather than inferred.
The text was updated successfully, but these errors were encountered: