reference
reference copied to clipboard
Specify guarantees for repr(rust) structs
Closes: #1151
I'm not sure who is to review this PR, but as the author of #1151, I wanted to make explicit that IMO, merging this PR would completely resolve this issue.
My thanks to the author of the PR.
Nominating for t-lang. These seem like reasonable guarantees to add to me, and want to get your input if you agree or have comments.
The only open question I had was would it help to define the layout of struct Foo()
to be the same as ()
.
The only open question I had was would it help to define the layout of
struct Foo()
to be the same as()
.
This would be very helpful. E.g., in zerocopy, we want to implement FromBytes
for ZSTs like Foo()
, but currently aren't convinced that it's sound. If structs like Foo()
had the same layout as ()
, we'd be sure that it is sound.
@rfcbot merge
@Darksonn have you seen this write-up here?
https://rust-lang.github.io/unsafe-code-guidelines/layout/structs-and-tuples.html
I didn't do a detailed comparison, but I would like to ensure they are compatible as that text had a fair bit of thought put into it :)
No, I haven't looked at that one in detail either.
Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members:
- [x] @cramertj
- [x] @joshtriplett
- [ ] @nikomatsakis
- [ ] @pnkfelix
- [x] @scottmcm
Concerns:
- ~~tuple-layout~~ resolved by https://github.com/rust-lang/reference/pull/1152#issuecomment-1233226776
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!
See this document for info about what commands tagged team members can give me.
@cramertj It looks like your concern didn't get registered; can you try again in a top-level comment?
@rfcbot concern tuple-layout
See https://github.com/rust-lang/reference/pull/1152#discussion_r832497012
What do I need to do to get this PR finished? I believe that the tuple-layout concern is resolved per the conversation above.
@rfcbot resolve tuple-layout
I think the intention is to clarify here that tuple layout and struct layout are not guaranteed to be the same. With that in mind, the rest of this looks great to me! Sorry for forgetting this thread for ages :(
:bell: This is now entering its final comment period, as per the review above. :bell:
psst @joshtriplett, I wasn't able to add the final-comment-period
label, please do so.
The final comment period, with a disposition to merge, as per the review above, is now complete.
As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.
This will be merged soon.
psst @joshtriplett, I wasn't able to add the finished-final-comment-period
label, please do so.