Skip to content

Conversation

@joshlf
Copy link
Contributor

@joshlf joshlf commented Dec 30, 2025

AFAICT, this behavior is widely assumed, and is the intended behavior. repr(C) unions are designed to match the behavior of C unions, and per the C standard:

The size of a union is sufficient to contain the
largest of its members. The value of at most one of the
members can be stored in a union object at any time. A
pointer to a union object, suitably converted, points
to each of its members (or if a member is a bit- field,
then to the unit in which it resides), and vice versa.

Makes progress on rust-lang/unsafe-code-guidelines#595

@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Dec 30, 2025
@joshlf
Copy link
Contributor Author

joshlf commented Dec 30, 2025

r? t-lang

(Is that valid r? syntax?)

@rustbot rustbot added the T-lang Team: Lang label Dec 30, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 30, 2025

Failed to set assignee to syntax: invalid assignee

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

@RalfJung
Copy link
Member

I'm surprised we don't already document this.^^

Copy link
Member

@scottmcm scottmcm left a comment

Choose a reason for hiding this comment

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

TBH I think this is so settled that we can just merge it without even an FCP, but cc @rust-lang/lang in case anyone has objections to that.

(It's hard to even argue that it's useful to allow differently even for repr(Rust), so for repr(C) I see absolutely no reason we'd even consider something different.)

@traviscross traviscross added I-lang-nominated P-lang-drag-1 Lang team prioritization drag level 1. labels Dec 30, 2025
@traviscross
Copy link
Contributor

traviscross commented Dec 30, 2025

Agreed with @scottmcm it seems well settled, and I'm tempted to merge it too, but from a Reference maintainer point-of-view, it's a bit more straightforward to follow the program and lang FCP new (-ly-documented) language guarantees of this kind.

@rfcbot fcp merge lang

(I'll check @scottmcm's box.)

@rust-rfcbot
Copy link
Collaborator

rust-rfcbot commented Dec 30, 2025

Team member @traviscross has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

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!

cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns.
See this document for info about what commands tagged team members can give me.

@traviscross traviscross removed the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Dec 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

disposition-merge I-lang-nominated P-lang-drag-1 Lang team prioritization drag level 1. proposed-final-comment-period S-waiting-on-fcp S-waiting-on-team Status: This is waiting for action from some team. T-lang Team: Lang

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants