Skip to content

Conversation

Kivooeo
Copy link
Member

@Kivooeo Kivooeo commented May 23, 2025

fixes #141264

r? @Veykril

Unresolved questions:

  • Any edge cases?
  • How this works with rust-analyzer (because all I've did is prevent compiler from emitting error in &raw context) (Allow &raw [mut | const] for union field  rust-analyzer#19867)
  • Should we allow addr_of! and addr_of_mut! as well? In current version they both (&raw and addr_of!) are allowed (They are the same)
  • Is chain of union fields is a safe? (Yes)

@rustbot
Copy link
Collaborator

rustbot commented May 23, 2025

Failed to set assignee to Veykril: 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.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 23, 2025
@jieyouxu
Copy link
Member

cc @RalfJung

@fmease fmease added the I-lang-nominated Nominated for discussion during a lang team meeting. label May 23, 2025
@Kivooeo Kivooeo changed the title Allow &raw [mut | const] for union field in safe Allow &raw [mut | const] for union field in safe May 23, 2025
@fmease fmease added the needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. label May 23, 2025
@RalfJung
Copy link
Member

Uh, the unsafety checker is not actually code I know very well, sorry.
r? compiler

@rustbot rustbot assigned davidtwco and unassigned RalfJung May 23, 2025
@RalfJung
Copy link
Member

Should we allow addr_of! and addr_of_mut! as well? In current version they both (&raw and addr_of!) are allowed

The macros just expand to &raw, it's not even possible to treat them differently.

@rust-log-analyzer

This comment has been minimized.

@Kivooeo
Copy link
Member Author

Kivooeo commented May 23, 2025

I will debug this later today but this is very weird

@fmease fmease added T-lang Relevant to the language team S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed I-lang-nominated Nominated for discussion during a lang team meeting. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 24, 2025
@Kivooeo Kivooeo force-pushed the remove-usnsafegate branch from b006128 to 43892d3 Compare May 24, 2025 11:46
@rust-log-analyzer

This comment has been minimized.

@Kivooeo Kivooeo force-pushed the remove-usnsafegate branch from b60d3ff to fc03435 Compare May 24, 2025 12:03
@rust-log-analyzer

This comment has been minimized.

@Kivooeo Kivooeo force-pushed the remove-usnsafegate branch from 9ccf35d to cde9fa0 Compare May 24, 2025 12:48
@Kivooeo
Copy link
Member Author

Kivooeo commented May 24, 2025

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 24, 2025
@rust-cloud-vms rust-cloud-vms bot force-pushed the remove-usnsafegate branch from 4024f37 to 23f1767 Compare August 31, 2025 17:23
@RalfJung RalfJung changed the title Allow &raw [mut | const] for union field in safe Allow &raw [mut | const] for union field in safe code Sep 10, 2025
@tmandry
Copy link
Member

tmandry commented Sep 10, 2025

@rfcbot reviewed

@rust-rfcbot rust-rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Sep 10, 2025
@rust-rfcbot
Copy link
Collaborator

🔔 This is now entering its final comment period, as per the review above. 🔔

@nikomatsakis
Copy link
Contributor

@rfcbot reviewed

@compiler-errors
Copy link
Member

r=me when FCP is over.

@traviscross traviscross added I-lang-radar Items that are on lang's radar and will need eventual work or consideration. and removed I-lang-nominated Nominated for discussion during a lang team meeting. P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang labels Sep 15, 2025
@rust-rfcbot rust-rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Sep 20, 2025
@rust-rfcbot
Copy link
Collaborator

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.

@rust-rfcbot rust-rfcbot added the to-announce Announce this issue on triage meeting label Sep 20, 2025
@traviscross traviscross added the relnotes Marks issues that should be documented in the release notes of the next release. label Sep 21, 2025
@jdonszelmann
Copy link
Contributor

@bors r=compiler-errors

@bors
Copy link
Collaborator

bors commented Sep 28, 2025

📌 Commit 23f1767 has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). labels Sep 28, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Sep 28, 2025
…iler-errors

Allow `&raw [mut | const]` for union field in safe code

fixes rust-lang#141264

r? `@Veykril`

Unresolved questions:

- [x] Any edge cases?
- [x] How this works with rust-analyzer (because all I've did is prevent compiler from emitting error in `&raw` context) (rust-lang/rust-analyzer#19867)
- [x] Should we allow `addr_of!` and `addr_of_mut!` as well? In current version they both (`&raw` and `addr_of!`) are allowed (They are the same)
- [x] Is chain of union fields is a safe? (Yes)
bors added a commit that referenced this pull request Sep 28, 2025
Rollup of 6 pull requests

Successful merges:

 - #140482 (std::net: update tcp deferaccept delay type to Duration.)
 - #141469 (Allow `&raw [mut | const]` for union field in safe code)
 - #144197 (TypeTree support in autodiff)
 - #146675 (Allow shared access to `Exclusive<T>` when `T: Sync`)
 - #147113 (Reland "Add LSX accelerated implementation for source file analysis")
 - #147120 (Fix --extra-checks=spellcheck to prevent cargo install every time)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 6059195 into rust-lang:master Sep 28, 2025
10 checks passed
@rustbot rustbot added this to the 1.92.0 milestone Sep 28, 2025
rust-timer added a commit that referenced this pull request Sep 28, 2025
Rollup merge of #141469 - Kivooeo:remove-usnsafegate, r=compiler-errors

Allow `&raw [mut | const]` for union field in safe code

fixes #141264

r? ``@Veykril``

Unresolved questions:

- [x] Any edge cases?
- [x] How this works with rust-analyzer (because all I've did is prevent compiler from emitting error in `&raw` context) (rust-lang/rust-analyzer#19867)
- [x] Should we allow `addr_of!` and `addr_of_mut!` as well? In current version they both (`&raw` and `addr_of!`) are allowed (They are the same)
- [x] Is chain of union fields is a safe? (Yes)
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Sep 29, 2025
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#140482 (std::net: update tcp deferaccept delay type to Duration.)
 - rust-lang/rust#141469 (Allow `&raw [mut | const]` for union field in safe code)
 - rust-lang/rust#144197 (TypeTree support in autodiff)
 - rust-lang/rust#146675 (Allow shared access to `Exclusive<T>` when `T: Sync`)
 - rust-lang/rust#147113 (Reland "Add LSX accelerated implementation for source file analysis")
 - rust-lang/rust#147120 (Fix --extra-checks=spellcheck to prevent cargo install every time)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-lang Relevant to the language team T-opsem Relevant to the opsem team to-announce Announce this issue on triage meeting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

&raw const some_union.field erroneously requires unsafe