Preserve place context through projections#73732
Preserve place context through projections#73732ecstatic-morse wants to merge 3 commits intorust-lang:masterfrom
Conversation
|
So... back when @spastorino refactored places to be non-recursive datastructures, I think we discussed that we should just eliminate I don't think we should merge this PR as it is, it seems very fragile with all the workarounds "for when we had a projection context". If you want we can do a brainstorming/design sync session to hash out a plan. |
|
Sounds good. I'll close this and we can take it to Zulip. |
Resolves #72931. Implements rust-lang/compiler-team#300.
This removes
PlaceContext::MutatingUse(Projection), which was used forx.y = 42,*x = 42and&mut x.y, as well asPlaceContext::NonMutatingUse(Projection), which was used forlet _ = x.y,let _ = *x, and&x.y. Now, these places receive their originalPlaceContextunless there is aDerefprojection.Unfortunately, there's a lot of code that relies on a context only appearing in
visit_localwhen the entire local is being assigned. Originally, I was going to switch these visitors to usevisit_place. However,visit_placeis not called for every use of aLocalin the MIR, notablyIndexprojections andStorage{Live,Dead}will result in a call tovisit_localwithout one tovisit_place. Instead I added an extra parameter tovisit_localthat is set when theLocalwas in aPlacewith projections.This is not very clean, and the other solutions all have problems as well. I'm starting to wonder if we would be better off with a MIR Visitor 2.0 that was designed specifically for traversing the CFG instead of the current, one-size-fits-all trait. That way, we could make small quality-of-life improvements without worrying about subtly breaking old code that relies on a certain visitation order.
r? @oli-obk, although I'm not very proud of the current state of this.