-
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
Make visitors iterate #61559
Make visitors iterate #61559
Conversation
); | ||
} | ||
|
||
context = if context.is_mutating_use() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing this suggests to me that you want a .fold
method on place
such that you can provide an initial state...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, may be nice to fix that. Maybe we can leave this for a different PR?. It's pre-existing logic that exists in the default Visitor implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, file an issue about it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need an explicit fold
method. place_projections
is an iterator, so we can just call fold
on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fold
does not work ok because there's a return and a continue there and we would be trying to do that inside a closure :/
3754891
to
0cfaa28
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me with fold
being used for the context
loop
); | ||
} | ||
|
||
context = if context.is_mutating_use() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need an explicit fold
method. place_projections
is an iterator, so we can just call fold
on it.
} | ||
} | ||
}; | ||
self.super_place(place, context, location); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can keep the base checking after the projection checking. It's not very important, all that can happen is that the order of evaluation changes. Since the order is not important, put the base checking back here, so the diff is smaller.
@bors r+ |
📌 Commit 0cfaa28 has been approved by |
…=oli-obk Make visitors iterate r? @oli-obk The second commit is not completely equivalent, unsure if the code is wrong or not. Tests pass though, otherwise we would need to iterate in the opposite direction as it happened in other parts of the code.
⌛ Testing commit 0cfaa28 with merge cbed462bc49e95754ea8d1115a93666636c0a670... |
💔 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 |
@bors retry |
…=oli-obk Make visitors iterate r? @oli-obk The second commit is not completely equivalent, unsure if the code is wrong or not. Tests pass though, otherwise we would need to iterate in the opposite direction as it happened in other parts of the code.
…=oli-obk Make visitors iterate r? @oli-obk The second commit is not completely equivalent, unsure if the code is wrong or not. Tests pass though, otherwise we would need to iterate in the opposite direction as it happened in other parts of the code.
} | ||
} | ||
|
||
for proj in place_projections { | ||
if context.is_borrow() { | ||
if util::is_disaligned(self.tcx, self.mir, self.param_env, place) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change looks very suspicious. Previously, place
was different on every iteration. Now it is the same, only proj
changes. I think this means we are not actually properly checking every place in this deref chain for alignment any more, which would be soundness bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah no, we actually only care about the outermost place as that's what the reference is created for.
But then it seems unnecessary to have this in the loop.
r? @oli-obk
The second commit is not completely equivalent, unsure if the code is wrong or not. Tests pass though, otherwise we would need to iterate in the opposite direction as it happened in other parts of the code.