-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add a raw "address of" operator #64588
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.
_ => None, | ||
}; | ||
|
||
if let Some((ctx, place)) = borrow_ctx { |
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.
syntax: cleanup param, method, and misc parsing Do some misc cleanup of the parser: - Method and parameter parsing is refactored. - A parser for `const | mut` is introduced that rust-lang#64588 can reuse. - Some other misc parsing. Next up in a different PR: - ~Implementing rust-lang#64252 -- maybe some other time... - Heavily restructuring up `item.rs` which is a mess (hopefully, no promises ^^). r? @petrochenkov
syntax: cleanup param, method, and misc parsing Do some misc cleanup of the parser: - Method and parameter parsing is refactored. - A parser for `const | mut` is introduced that rust-lang#64588 can reuse. - Some other misc parsing. Next up in a different PR: - ~Implementing rust-lang#64252 -- maybe some other time... - Heavily restructuring up `item.rs` which is a mess (hopefully, no promises ^^). r? @petrochenkov
syntax: cleanup param, method, and misc parsing Do some misc cleanup of the parser: - Method and parameter parsing is refactored. - A parser for `const | mut` is introduced that rust-lang#64588 can reuse. - Some other misc parsing. Next up in a different PR: - ~Implementing rust-lang#64252 -- maybe some other time... - Heavily restructuring up `item.rs` which is a mess (hopefully, no promises ^^). r? @petrochenkov
syntax: cleanup param, method, and misc parsing Do some misc cleanup of the parser: - Method and parameter parsing is refactored. - A parser for `const | mut` is introduced that rust-lang#64588 can reuse. - Some other misc parsing. Next up in a different PR: - ~Implementing rust-lang#64252 -- maybe some other time... - Heavily restructuring up `item.rs` which is a mess (hopefully, no promises ^^). r? @petrochenkov
syntax: cleanup param, method, and misc parsing Do some misc cleanup of the parser: - Method and parameter parsing is refactored. - A parser for `const | mut` is introduced that rust-lang#64588 can reuse. - Some other misc parsing. Next up in a different PR: - ~Implementing rust-lang#64252 -- maybe some other time... - Heavily restructuring up `item.rs` which is a mess (hopefully, no promises ^^). r? @petrochenkov
syntax: cleanup param, method, and misc parsing Do some misc cleanup of the parser: - Method and parameter parsing is refactored. - A parser for `const | mut` is introduced that rust-lang#64588 can reuse. - Some other misc parsing. Next up in a different PR: - ~Implementing rust-lang#64252 -- maybe some other time... - Heavily restructuring up `item.rs` which is a mess (hopefully, no promises ^^). r? @petrochenkov
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.
…-obk Add a raw "address of" operator * Parse and feature gate `&raw [const | mut] expr` (feature gate name is `raw_address_of`) * Add `mir::Rvalue::AddressOf` * Use the new `Rvalue` for: * the new syntax * reference to pointer casts * drop shims for slices and arrays * Stop using `mir::Rvalue::Cast` with a reference as the operand * Correctly evaluate `mir::Rvalue::{Ref, AddressOf}` in constant propagation cc @Centril @RalfJung @oli-obk @eddyb cc rust-lang#64490
…-obk Add a raw "address of" operator * Parse and feature gate `&raw [const | mut] expr` (feature gate name is `raw_address_of`) * Add `mir::Rvalue::AddressOf` * Use the new `Rvalue` for: * the new syntax * reference to pointer casts * drop shims for slices and arrays * Stop using `mir::Rvalue::Cast` with a reference as the operand * Correctly evaluate `mir::Rvalue::{Ref, AddressOf}` in constant propagation cc @Centril @RalfJung @oli-obk @eddyb cc rust-lang#64490
Rollup of 5 pull requests Successful merges: - #64588 (Add a raw "address of" operator) - #67031 (Update tokio crates to latest versions) - #67131 (Merge `TraitItem` & `ImplItem into `AssocItem`) - #67354 (Fix pointing at arg when cause is outside of call) - #67363 (Fix handling of wasm import modules and names) Failed merges: r? @ghost
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.
Test raw-ptr-cast without reborrow With rust-lang/rust#64588 landed, we can finally test these things adequately. :)
Test raw-ptr-cast without reborrow With rust-lang/rust#64588 landed, we can finally test these things adequately. :)
&raw [const | mut] expr
(feature gate name israw_address_of
)mir::Rvalue::AddressOf
Rvalue
for:mir::Rvalue::Cast
with a reference as the operandmir::Rvalue::{Ref, AddressOf}
in constant propagationcc @Centril @RalfJung @oli-obk @eddyb
cc #64490