-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Add a raw "address of" operator #64588
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
Conversation
This comment has been minimized.
This comment has been minimized.
c6f4a9e to
1f210d6
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @ecstatic-morse @oli-obk re. the qualification code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea I think none of it should be changed and we should just treat raw borrows as unpromotable (because any potentially promotable things had to error out before)
This comment has been minimized.
This comment has been minimized.
|
Thanks for the PR. I've made an initial review above ^--- (but Ralf should also review this). Some more remarks on the PR description:
This is not part of the RFC and should remain UB.
Can you elaborate on this please? Is this a spec change or just internal refactoring?
Seems like the same as Can you please also extend the |
|
@matthewjasper You need to handle |
What should be UB?
It's a refactoring. If the precise stacked borrows effects of slice/array drop shims is defined, then maybe it's a change, but not a very big one since the parameter is a mutable reference, and the calls to drop the elements create mutable references.
This can be a follow up. The (lack of) behavior here is consistent with |
Oh I see; seems I misread. Can you add a mir-opt test to that effect?
Sure, can you add a ticket to the tracking issue when this PR is merged? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@matthewjasper @RalfJung Some tests need to be added to ensure that |
This comment has been minimized.
This comment has been minimized.
f9f85b1 to
a749116
Compare
|
@bors r=oli-obk |
|
📌 Commit a749116 has been approved by |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
This is awesome, thanks so much. :) |
| // Retag-as-raw after escaping to a raw pointer. | ||
| StatementKind::Assign(box (ref place, Rvalue::AddressOf(..))) => { | ||
| (RetagKind::Raw, place.clone()) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is doing that for all &raw now, right? Certainly a reasonable start, though it doesn't seem to be entirely equivalent to the previous operation which also made sure that the "input" is a reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There wasn't any way to write &raw const *x where x is a raw pointer before.
&raw [const | mut] expr(feature gate name israw_address_of)mir::Rvalue::AddressOfRvaluefor:mir::Rvalue::Castwith a reference as the operandmir::Rvalue::{Ref, AddressOf}in constant propagationcc @Centril @RalfJung @oli-obk @eddyb
cc #64490