-
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
Change visit api #61554
Change visit api #61554
Conversation
I've processed the rest of the So this ends being a little change that I think it's a bit better but may not worth applying, unsure to be honest :). |
In particular, having |
I think just leaving a comment on the |
I like it, and we're going to "need it" (in some form) anyway when moving to slice projections. |
e786f63
to
67197e2
Compare
@bors r+ |
📌 Commit 67197e2 has been approved by |
Change visit api r? @oli-obk In the [first commit](rust-lang@37386d3) of this PR, I'm changing `visit_place` to be the function that traverses the `Place` and have only that responsibility. Then there are two other functions `visit_place_base` and `visit_projection` which are the ones in charge of visiting the base and the projection. Visitor implementors can implement any of those. In the [second commit](rust-lang@e786f63) we can already see some things that confuses me, which I think this division will make more clear. The old code, first checked if the place was a base, did something with it and then called `super_place` [here](rust-lang@e786f63#diff-d583e4efe1a72516e274158e53223633L678). `super_place` checks again if it's a base [here](https://github.com/rust-lang/rust/blob/master/src/librustc/mir/visit.rs#L679-L684) and in case is a local, visits the local and stuff like that. That's not very obvious on the code, and if I'm not wrong it's not needed. In this PR or we have [this](rust-lang@e786f63#diff-d583e4efe1a72516e274158e53223633R673) as I did or we can just do `- => self.super_place_base(...)` and that will be obvious that I'm letting the default implementation process the base.
⌛ Testing commit 67197e2 with merge 8d380c4fe5c3cf00b5231cdd14d49bf50d9f5996... |
💔 Test failed - checks-travis |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
The rand crate broke. |
Change visit api r? @oli-obk In the [first commit](rust-lang@37386d3) of this PR, I'm changing `visit_place` to be the function that traverses the `Place` and have only that responsibility. Then there are two other functions `visit_place_base` and `visit_projection` which are the ones in charge of visiting the base and the projection. Visitor implementors can implement any of those. In the [second commit](rust-lang@e786f63) we can already see some things that confuses me, which I think this division will make more clear. The old code, first checked if the place was a base, did something with it and then called `super_place` [here](rust-lang@e786f63#diff-d583e4efe1a72516e274158e53223633L678). `super_place` checks again if it's a base [here](https://github.com/rust-lang/rust/blob/master/src/librustc/mir/visit.rs#L679-L684) and in case is a local, visits the local and stuff like that. That's not very obvious on the code, and if I'm not wrong it's not needed. In this PR or we have [this](rust-lang@e786f63#diff-d583e4efe1a72516e274158e53223633R673) as I did or we can just do `- => self.super_place_base(...)` and that will be obvious that I'm letting the default implementation process the base.
r? @oli-obk
In the first commit of this PR, I'm changing
visit_place
to be the function that traverses thePlace
and have only that responsibility. Then there are two other functionsvisit_place_base
andvisit_projection
which are the ones in charge of visiting the base and the projection. Visitor implementors can implement any of those.In the second commit we can already see some things that confuses me, which I think this division will make more clear. The old code, first checked if the place was a base, did something with it and then called
super_place
here.super_place
checks again if it's a base here and in case is a local, visits the local and stuff like that. That's not very obvious on the code, and if I'm not wrong it's not needed. In this PR or we have this as I did or we can just do- => self.super_place_base(...)
and that will be obvious that I'm letting the default implementation process the base.