Allow &raw [mut | const] for union field #19867
Merged
Veykril merged 1 commit intorust-lang:masterfrom Sep 28, 2025
Merged
Conversation
bb653dd to
85227f4
Compare
ChayimFriedman2
previously requested changes
May 26, 2025
Contributor
ChayimFriedman2
left a comment
There was a problem hiding this comment.
I think we should wait with this until the rust-lang/rust PR is merged, or at least the FCP completes.
Member
Author
|
I decided to stick with separate methods because of I dont know how to rewrite this without recursion, and, I believe, it should be fine like this (not inlined) even if we used this methods just for this single case |
4 tasks
Contributor
|
I feel like it'll be better (and more performant) if we'll just unconditionally call |
Member
Author
|
@rustbot ready |
Veykril
approved these changes
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)
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)
rust-timer
added a commit
to rust-lang/rust
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
Allow `&raw [mut | const]` for union field in safe code fixes rust-lang/rust#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)
Member
|
changelog fix (first contribution) allow |
Kobzol
pushed a commit
to Kobzol/rustc_codegen_gcc
that referenced
this pull request
Dec 21, 2025
Allow `&raw [mut | const]` for union field in safe code fixes rust-lang/rust#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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
follow up rust-lang/rust#141469
i didn’t test it locally, just relying on the tests for now. also not really familiar with rust-analyzer code, but tried my best
if there’s anything that can be improved, feel free to point it out
r? @Veykril