Skip to content

Allow &raw [mut | const] for union field #19867

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Kivooeo
Copy link

@Kivooeo Kivooeo commented May 26, 2025

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

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 26, 2025
@Kivooeo Kivooeo force-pushed the unsafegate branch 5 times, most recently from bb653dd to 85227f4 Compare May 26, 2025 12:35
Copy link
Contributor

@ChayimFriedman2 ChayimFriedman2 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 should wait with this until the rust-lang/rust PR is merged, or at least the FCP completes.

@Kivooeo
Copy link
Author

Kivooeo commented Jun 27, 2025

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

@ChayimFriedman2
Copy link
Contributor

I feel like it'll be better (and more performant) if we'll just unconditionally call walk_field_chain_for_raw_ptr().

}

union LessOuter {
lessouter: ManuallyDrop<MoreInner>,
Copy link
Contributor

Choose a reason for hiding this comment

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

ManuallyDrop is not resolved, just include the type without it.

Copy link
Author

Choose a reason for hiding this comment

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

does it mean the test is not correct in it's current state? i will look into it little bit later today

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, as in "it does not test the thing it should".

Copy link
Author

Choose a reason for hiding this comment

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

oh, thanks for this catch, but, can i add this import into test somehow? as far as i remember it wont work without ManuallyDrop

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, you can add //- minicore: manually_drop, deref at the top of the test and also use core::mem::ManuallyDrop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants