Guarantee repr(C) union field offset#2128
Conversation
|
r? t-lang (Is that valid r? syntax?) |
|
Failed to set assignee to
|
|
I'm surprised we don't already document this.^^ |
scottmcm
left a comment
There was a problem hiding this comment.
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.)
|
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. |
|
If this weren't true we'd be in trouble :) @rfcbot reviewed |
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
This comment has been minimized.
This comment has been minimized.
Makes progress on rust-lang/unsafe-code-guidelines#595
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
cc @rust-lang/fls |
|
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. |
Update books ## rust-lang/book 1 commits in 39aeceaa3aeab845bc4517e7a44e48727d3b9dbe..05d114287b7d6f6c9253d5242540f00fbd6172ab 2026-02-03 15:19:04 UTC to 2026-02-03 15:19:04 UTC - Temporarily remove the link to `Drop::drop` (rust-lang/book#4576) ## rust-lang/nomicon 1 commits in 050c002a360fa45b701ea34feed7a860dc8a41bf..b8f254a991b8b7e8f704527f0d4f343a4697dfa9 2026-01-29 12:15:01 UTC to 2026-01-29 12:15:01 UTC - Fix deprecation warning for compare_and_swap in atomics.md (rust-lang/nomicon#519) ## rust-lang/reference 12 commits in 990819b86c22bbf538c0526f0287670f3dc1a67a..addd0602c819b6526b9cc97653b0fadca395528c 2026-02-04 14:35:59 UTC to 2026-01-26 18:02:14 UTC - const-eval.const-expr.field: make paragraph more clear (rust-lang/reference#2157) - make more clear what the link target is (rust-lang/reference#2156) - Update two URLs (rust-lang/reference#2154) - Add a chapter on divergence (rust-lang/reference#2067) - Guarantee `repr(C)` union field offset (rust-lang/reference#2128) - Reference updates for forbidding object lifetime changing pointer casts (rust-lang/reference#1951) - Clarify only arrays undergo unsized coercion during dispatch (rust-lang/reference#2139) - Split the textual chapter into separate char and str chapters (rust-lang/reference#2145) - Document ppc inline asm support (rust-lang/reference#2056) - Unwrap items, expressions, patterns, and types (rust-lang/reference#2141) - undefined behavior: add missing plural in `undefined.misaligned.ptr` (rust-lang/reference#2146) - inline-assembly: add a space to the `asm.abi-clobbers.many` example (rust-lang/reference#2144)
Update books ## rust-lang/book 1 commits in 39aeceaa3aeab845bc4517e7a44e48727d3b9dbe..05d114287b7d6f6c9253d5242540f00fbd6172ab 2026-02-03 15:19:04 UTC to 2026-02-03 15:19:04 UTC - Temporarily remove the link to `Drop::drop` (rust-lang/book#4576) ## rust-lang/nomicon 1 commits in 050c002a360fa45b701ea34feed7a860dc8a41bf..b8f254a991b8b7e8f704527f0d4f343a4697dfa9 2026-01-29 12:15:01 UTC to 2026-01-29 12:15:01 UTC - Fix deprecation warning for compare_and_swap in atomics.md (rust-lang/nomicon#519) ## rust-lang/reference 12 commits in 990819b86c22bbf538c0526f0287670f3dc1a67a..addd0602c819b6526b9cc97653b0fadca395528c 2026-02-04 14:35:59 UTC to 2026-01-26 18:02:14 UTC - const-eval.const-expr.field: make paragraph more clear (rust-lang/reference#2157) - make more clear what the link target is (rust-lang/reference#2156) - Update two URLs (rust-lang/reference#2154) - Add a chapter on divergence (rust-lang/reference#2067) - Guarantee `repr(C)` union field offset (rust-lang/reference#2128) - Reference updates for forbidding object lifetime changing pointer casts (rust-lang/reference#1951) - Clarify only arrays undergo unsized coercion during dispatch (rust-lang/reference#2139) - Split the textual chapter into separate char and str chapters (rust-lang/reference#2145) - Document ppc inline asm support (rust-lang/reference#2056) - Unwrap items, expressions, patterns, and types (rust-lang/reference#2141) - undefined behavior: add missing plural in `undefined.misaligned.ptr` (rust-lang/reference#2146) - inline-assembly: add a space to the `asm.abi-clobbers.many` example (rust-lang/reference#2144)
Update books ## rust-lang/book 1 commits in 39aeceaa3aeab845bc4517e7a44e48727d3b9dbe..05d114287b7d6f6c9253d5242540f00fbd6172ab 2026-02-03 15:19:04 UTC to 2026-02-03 15:19:04 UTC - Temporarily remove the link to `Drop::drop` (rust-lang/book#4576) ## rust-lang/nomicon 1 commits in 050c002a360fa45b701ea34feed7a860dc8a41bf..b8f254a991b8b7e8f704527f0d4f343a4697dfa9 2026-01-29 12:15:01 UTC to 2026-01-29 12:15:01 UTC - Fix deprecation warning for compare_and_swap in atomics.md (rust-lang/nomicon#519) ## rust-lang/reference 12 commits in 990819b86c22bbf538c0526f0287670f3dc1a67a..addd0602c819b6526b9cc97653b0fadca395528c 2026-02-04 14:35:59 UTC to 2026-01-26 18:02:14 UTC - const-eval.const-expr.field: make paragraph more clear (rust-lang/reference#2157) - make more clear what the link target is (rust-lang/reference#2156) - Update two URLs (rust-lang/reference#2154) - Add a chapter on divergence (rust-lang/reference#2067) - Guarantee `repr(C)` union field offset (rust-lang/reference#2128) - Reference updates for forbidding object lifetime changing pointer casts (rust-lang/reference#1951) - Clarify only arrays undergo unsized coercion during dispatch (rust-lang/reference#2139) - Split the textual chapter into separate char and str chapters (rust-lang/reference#2145) - Document ppc inline asm support (rust-lang/reference#2056) - Unwrap items, expressions, patterns, and types (rust-lang/reference#2141) - undefined behavior: add missing plural in `undefined.misaligned.ptr` (rust-lang/reference#2146) - inline-assembly: add a space to the `asm.abi-clobbers.many` example (rust-lang/reference#2144)
Update books ## rust-lang/book 1 commits in 39aeceaa3aeab845bc4517e7a44e48727d3b9dbe..05d114287b7d6f6c9253d5242540f00fbd6172ab 2026-02-03 15:19:04 UTC to 2026-02-03 15:19:04 UTC - Temporarily remove the link to `Drop::drop` (rust-lang/book#4576) ## rust-lang/nomicon 1 commits in 050c002a360fa45b701ea34feed7a860dc8a41bf..b8f254a991b8b7e8f704527f0d4f343a4697dfa9 2026-01-29 12:15:01 UTC to 2026-01-29 12:15:01 UTC - Fix deprecation warning for compare_and_swap in atomics.md (rust-lang/nomicon#519) ## rust-lang/reference 12 commits in 990819b86c22bbf538c0526f0287670f3dc1a67a..addd0602c819b6526b9cc97653b0fadca395528c 2026-02-04 14:35:59 UTC to 2026-01-26 18:02:14 UTC - const-eval.const-expr.field: make paragraph more clear (rust-lang/reference#2157) - make more clear what the link target is (rust-lang/reference#2156) - Update two URLs (rust-lang/reference#2154) - Add a chapter on divergence (rust-lang/reference#2067) - Guarantee `repr(C)` union field offset (rust-lang/reference#2128) - Reference updates for forbidding object lifetime changing pointer casts (rust-lang/reference#1951) - Clarify only arrays undergo unsized coercion during dispatch (rust-lang/reference#2139) - Split the textual chapter into separate char and str chapters (rust-lang/reference#2145) - Document ppc inline asm support (rust-lang/reference#2056) - Unwrap items, expressions, patterns, and types (rust-lang/reference#2141) - undefined behavior: add missing plural in `undefined.misaligned.ptr` (rust-lang/reference#2146) - inline-assembly: add a space to the `asm.abi-clobbers.many` example (rust-lang/reference#2144)
Update books ## rust-lang/book 1 commits in 39aeceaa3aeab845bc4517e7a44e48727d3b9dbe..05d114287b7d6f6c9253d5242540f00fbd6172ab 2026-02-03 15:19:04 UTC to 2026-02-03 15:19:04 UTC - Temporarily remove the link to `Drop::drop` (rust-lang/book#4576) ## rust-lang/nomicon 1 commits in 050c002a360fa45b701ea34feed7a860dc8a41bf..b8f254a991b8b7e8f704527f0d4f343a4697dfa9 2026-01-29 12:15:01 UTC to 2026-01-29 12:15:01 UTC - Fix deprecation warning for compare_and_swap in atomics.md (rust-lang/nomicon#519) ## rust-lang/reference 12 commits in 990819b86c22bbf538c0526f0287670f3dc1a67a..addd0602c819b6526b9cc97653b0fadca395528c 2026-02-04 14:35:59 UTC to 2026-01-26 18:02:14 UTC - const-eval.const-expr.field: make paragraph more clear (rust-lang/reference#2157) - make more clear what the link target is (rust-lang/reference#2156) - Update two URLs (rust-lang/reference#2154) - Add a chapter on divergence (rust-lang/reference#2067) - Guarantee `repr(C)` union field offset (rust-lang/reference#2128) - Reference updates for forbidding object lifetime changing pointer casts (rust-lang/reference#1951) - Clarify only arrays undergo unsized coercion during dispatch (rust-lang/reference#2139) - Split the textual chapter into separate char and str chapters (rust-lang/reference#2145) - Document ppc inline asm support (rust-lang/reference#2056) - Unwrap items, expressions, patterns, and types (rust-lang/reference#2141) - undefined behavior: add missing plural in `undefined.misaligned.ptr` (rust-lang/reference#2146) - inline-assembly: add a space to the `asm.abi-clobbers.many` example (rust-lang/reference#2144)
Update books ## rust-lang/book 1 commits in 39aeceaa3aeab845bc4517e7a44e48727d3b9dbe..05d114287b7d6f6c9253d5242540f00fbd6172ab 2026-02-03 15:19:04 UTC to 2026-02-03 15:19:04 UTC - Temporarily remove the link to `Drop::drop` (rust-lang/book#4576) ## rust-lang/nomicon 1 commits in 050c002a360fa45b701ea34feed7a860dc8a41bf..b8f254a991b8b7e8f704527f0d4f343a4697dfa9 2026-01-29 12:15:01 UTC to 2026-01-29 12:15:01 UTC - Fix deprecation warning for compare_and_swap in atomics.md (rust-lang/nomicon#519) ## rust-lang/reference 12 commits in 990819b86c22bbf538c0526f0287670f3dc1a67a..addd0602c819b6526b9cc97653b0fadca395528c 2026-02-04 14:35:59 UTC to 2026-01-26 18:02:14 UTC - const-eval.const-expr.field: make paragraph more clear (rust-lang/reference#2157) - make more clear what the link target is (rust-lang/reference#2156) - Update two URLs (rust-lang/reference#2154) - Add a chapter on divergence (rust-lang/reference#2067) - Guarantee `repr(C)` union field offset (rust-lang/reference#2128) - Reference updates for forbidding object lifetime changing pointer casts (rust-lang/reference#1951) - Clarify only arrays undergo unsized coercion during dispatch (rust-lang/reference#2139) - Split the textual chapter into separate char and str chapters (rust-lang/reference#2145) - Document ppc inline asm support (rust-lang/reference#2056) - Unwrap items, expressions, patterns, and types (rust-lang/reference#2141) - undefined behavior: add missing plural in `undefined.misaligned.ptr` (rust-lang/reference#2146) - inline-assembly: add a space to the `asm.abi-clobbers.many` example (rust-lang/reference#2144)
Rollup merge of #152397 - rustbot:docs-update, r=ehuss Update books ## rust-lang/book 1 commits in 39aeceaa3aeab845bc4517e7a44e48727d3b9dbe..05d114287b7d6f6c9253d5242540f00fbd6172ab 2026-02-03 15:19:04 UTC to 2026-02-03 15:19:04 UTC - Temporarily remove the link to `Drop::drop` (rust-lang/book#4576) ## rust-lang/nomicon 1 commits in 050c002a360fa45b701ea34feed7a860dc8a41bf..b8f254a991b8b7e8f704527f0d4f343a4697dfa9 2026-01-29 12:15:01 UTC to 2026-01-29 12:15:01 UTC - Fix deprecation warning for compare_and_swap in atomics.md (rust-lang/nomicon#519) ## rust-lang/reference 12 commits in 990819b86c22bbf538c0526f0287670f3dc1a67a..addd0602c819b6526b9cc97653b0fadca395528c 2026-02-04 14:35:59 UTC to 2026-01-26 18:02:14 UTC - const-eval.const-expr.field: make paragraph more clear (rust-lang/reference#2157) - make more clear what the link target is (rust-lang/reference#2156) - Update two URLs (rust-lang/reference#2154) - Add a chapter on divergence (rust-lang/reference#2067) - Guarantee `repr(C)` union field offset (rust-lang/reference#2128) - Reference updates for forbidding object lifetime changing pointer casts (rust-lang/reference#1951) - Clarify only arrays undergo unsized coercion during dispatch (rust-lang/reference#2139) - Split the textual chapter into separate char and str chapters (rust-lang/reference#2145) - Document ppc inline asm support (rust-lang/reference#2056) - Unwrap items, expressions, patterns, and types (rust-lang/reference#2141) - undefined behavior: add missing plural in `undefined.misaligned.ptr` (rust-lang/reference#2146) - inline-assembly: add a space to the `asm.abi-clobbers.many` example (rust-lang/reference#2144)
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:Makes progress on rust-lang/unsafe-code-guidelines#595