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.
There was a problem hiding this comment.
cc @ecstatic-morse @oli-obk re. the qualification code.
There was a problem hiding this comment.
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
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.
This operator creates a raw pointer to a Place directly, without first creating a reference. See RFC rust-lang#2582 for motivation. The Rvalue is currently unused.
`hir::BorrowKind::Raw` borrows and casting a reference to a raw pointer no longer do a reborrow followed by a cast. Instead we dereference and take the address.
|
@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.
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.
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