:wave: @ecstatic-morse about https://github.com/rust-lang/rust/pull/73732#issuecomment-650289464
cc @Santiago Pastorino
We haven't been able to figure out a good way to make mir::Visitor
visit projections. While there were some improvements during the Place refactorings, we kinda stopped there and various visitors still require wild schemes around visiting locals in the correct order and with the correct projection information.
the linked PR above tried another approach, which, while improving some cases, made others worse (requiring additional visitor state and such)
Quoting from the PR
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.
Maybe we should indeed "just give up" and not have the mir::Visitor
go below the visit_place
level. We could then offer different schemes for visiting places (maybe as methods on Place
?)
oli said:
Maybe we should indeed "just give up" and not have the
mir::Visitor
go below thevisit_place
level. We could then offer different schemes for visiting places (maybe as methods onPlace
?)
This is the approach I favor as well. My only new proposal is that Visitor
and MutVisitor
should diverge here. Creating "fake places" for MutVisitor
s is bad, since they have to figure out whether a Place
is a fake or not. I want to keep MutVisitor
as close to the actual structure MIR as possible and continue to have visit_local
, but have Visitor
be tweaked to make it obvious how to write analysis passes.