Conversation
This comment has been minimized.
This comment has been minimized.
e4c08f7 to
3b1957a
Compare
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.
|
Some changes occurred in cc @BoxyUwU Some changes occurred in match checking cc @Nadrieril This PR changes MIR cc @oli-obk, @RalfJung, @JakobDegen, @vakaras This PR changes rustc_public cc @oli-obk, @celinval, @ouz-a, @makai410 Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt Some changes occurred to constck cc @fee1-dead Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 Some changes occurred to the CTFE machinery Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
|
r? compiler |
|
Where can I read context on what CoerceShared is/why it exists, and what the design for reborrow traits is |
I added a link to the experiment tracking issue but put it very shortly: |
|
I think I'll just |
Thank you <3 my top secret plan (designed together with tmandry) was to get a compiler review and then reroll into types to that view as well so that works well :) |
Appreciated. |
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.
6c284b5 to
2b5cd0f
Compare
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.
fc476b9 to
819963c
Compare
This comment has been minimized.
This comment has been minimized.
819963c to
2038ae9
Compare
|
@rustbot ready |
|
I don't have anything more to add here, most of this touches code I know nothing about. I deliberately unsubscribed from the PR. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment has been minimized.
This comment has been minimized.
|
Hi @oli-obk, it looks like this is ready for another round of review when you get a chance. Thanks! 🙂 |
7cdb66f to
339fc61
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
| borrowed_place: &Place<'tcx>, | ||
| dest_ty: Ty<'tcx>, | ||
| ) { | ||
| // These constraints are only meaningful during borrowck: |
There was a problem hiding this comment.
I don't understand this comment. And why is it on the destructuring statement?
There was a problem hiding this comment.
This is directly copied over from add_reborrow_constraint where the same comment is in a similarly odd place.
I can remove it if preferred; I thought I'd just keep it same since I don't understand it myself either :D
| let right_ty = rvalue.ty(&self.body.local_decls, self.tcx); | ||
|
|
||
| if matches!(rvalue, Rvalue::Reborrow(..)) { | ||
| // Trust me bro: Reborrow/CoerceShared is only inserted if types match. |
There was a problem hiding this comment.
wait, but this is validation :D
double-checking seems good, especially to catch optimizations from messing up
There was a problem hiding this comment.
Yeah; the thinking here is that because we only produce an Rvalue::Reborrow from an adjustment, and we only produce such an adjustment if we're looking at an assignment where we're going either from T -> T where T: Reborrow, or we're going from T -> U where T: CoerceShared<U>, then at this point we know we're necessarily doing a T -> T or T -> U and types match.
But double-checking is fine by me, and it does also offer up a future improvement of the implementation where we drop the adjustment and instead perform Reborrow somewhere at a deeper level on every use/access of a Reborrow or CoerceShared type.
| if !errors.is_empty() { Err(errors) } else { Ok(()) } | ||
| } | ||
|
|
||
| pub(crate) fn coerce_shared_info<'tcx>( |
There was a problem hiding this comment.
how much is the logic of this copied from similar logic on the other coercion traits? Can we share some of the algorithm or sth else here?
There was a problem hiding this comment.
The basic structure and error handling is copied from CoerceUnsized. I'll take a look at possible deduplications.
|
The job Click to see the possible cause of the failure (guessed by this bot) |
View all comments
With this PR we now have basic functional Reborrow and CoerceShared traits. The current limitations are:
&mutwrappers is working (though I've not tested generic wrappers likeOption<&mut T>yet), but CoerceShared of&mutwrappers currently causes an ICE.The remaining tasks to complete before I'd consider this PR mergeable are:
Reborrow traits experiment: #145612
Co-authored by @dingxiangfei2009