Skip to content
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

Detail layout of repr(C) unions #160

Merged
merged 20 commits into from Aug 15, 2019
Merged

Conversation

gnzlbg
Copy link
Contributor

@gnzlbg gnzlbg commented Jul 8, 2019

Documents the behavior described in #156 .

# }
```

**C++ compatibility hazard**: C++ does, in general, give a size of 1 to empty
Copy link
Member

Choose a reason for hiding this comment

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

Should we maybe say "struct with no field"? "empty" in Rust means something else than in C++.

Copy link

@comex comex Aug 14, 2019

Choose a reason for hiding this comment

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

Can we add a link somewhere to the section about zero-sized types in structs-and-tuples.md? That section goes into a lot more detail, e.g.

  • explicitly stating that empty structs are illegal in C
  • mentioning [[no_unique_address]]
  • differentiating between structs with no fields and structs with fields of zero size

There's no need to repeat all that here, but a link would be helpful.

Copy link

Choose a reason for hiding this comment

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

(Perhaps also mention that Rust unions can't have zero fields.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The text now uses "struct with no fields" and refers and links to the structs chapter for details.

Copy link
Member

@RalfJung RalfJung Aug 15, 2019

Choose a reason for hiding this comment

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

Some of your commits seem to have been lost? Like, "Link to struct chapter" just is not in this PR any more.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That might not have been intended. I merged the "suggestion changes" and that had conflicts so I had to force push :/

Copy link
Member

Choose a reason for hiding this comment

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

Force-push shouldn't be needed after merging...? Weird.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I screw up. I need to learn how to "pull" changes to my branch locally and rebase them without spurious merge commits when my local branch has other changes :/

@RalfJung RalfJung added A-layout Topic: Related to data structure layout (`#[repr]`) A-unions Topic: Related to unions labels Aug 14, 2019
@RalfJung
Copy link
Member

Other than this final issue about empty structs, I have one more remark. I felt it is eaiser to just open a PR against your PR for this: gnzlbg#1

mention size-filling padding
Copy link
Member

@RalfJung RalfJung left a comment

Choose a reason for hiding this comment

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

I think we are finally there. :) Thanks for prevailing!

@RalfJung RalfJung merged commit 727fc88 into rust-lang:master Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-layout Topic: Related to data structure layout (`#[repr]`) A-unions Topic: Related to unions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants