Skip to content
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

Use PlaceRef projection abstractions more consistently in rustc_mir #80865

Merged
merged 1 commit into from
Jan 18, 2021
Merged

Use PlaceRef projection abstractions more consistently in rustc_mir #80865

merged 1 commit into from
Jan 18, 2021

Conversation

oliviacrain
Copy link
Contributor

PlaceRef contains abstractions for dealing with the projections array. This PR uses these abstractions more consistently within the rustc_mir crate.

See associated issue: #80647.

r? @RalfJung

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 10, 2021
@oliviacrain oliviacrain changed the title Use PlaceRef more consistently in rustc_mir Use PlaceRef projection abstractions more consistently in rustc_mir Jan 10, 2021
@camelid camelid added A-mir Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 11, 2021
@@ -478,7 +478,7 @@ impl<'tcx> Validator<'_, 'tcx> {
// https://github.com/rust-lang/rust/pull/74945#discussion_r463063247
// There may be opportunity for generalization, but this needs to be
// accounted for.
if proj_base.is_empty()
if place_base.projection.is_empty()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the is_empty check should be moved up near self.temps[place_base.local] -- that code only makes sense if there are no projections.

@RalfJung
Copy link
Member

Thanks a lot for this PR, @oliviacrain. :) I just left two minor comments; everything else looks perfect!

@oliviacrain
Copy link
Contributor Author

Thanks for the comments, @RalfJung! I've addressed comments, squashed fixups, and rebased against master.

@RalfJung
Copy link
Member

RalfJung commented Jan 16, 2021

Thanks for the quick update!

However, for the future, it'd be better if you could refrain from force-pushing to a branch until review is done. With a force-push, now I have to re-read the entire PR again, I have no way of checking just the new diff. If there are conflicts, a rebase (+ force-push) is needed, but squashing should never be done until review is complete. If you hadn't rebased I could have used GH's force-push-diff link, but after squash + rebase, all hope of an incremental review is lost.^^

@oliviacrain
Copy link
Contributor Author

Ah, so sorry about that. My brain didn't switch from work PR mode... will avoid that in the future.

@RalfJung
Copy link
Member

No worries, different policies in different projects can be confusing. ;)
Luckily, GH mostly retained the per-file "viewed" state in the diff, so I don't have to actually re-read everything.

@@ -1007,27 +1007,26 @@ fn place_as_reborrow(
body: &Body<'tcx>,
place: Place<'tcx>,
) -> Option<&'a [PlaceElem<'tcx>]> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks to me like the return type should be changed to Option<PlaceRef>... but that's a larger change, no need to do it in this PR.

@RalfJung
Copy link
Member

This looks great, thanks for working on this. :)
@bors r+

@bors
Copy link
Contributor

bors commented Jan 16, 2021

📌 Commit 65b5e43 has been approved by RalfJung

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 16, 2021
m-ou-se added a commit to m-ou-se/rust that referenced this pull request Jan 16, 2021
Use PlaceRef projection abstractions more consistently in rustc_mir

PlaceRef contains abstractions for dealing with the `projections` array. This PR uses these abstractions more consistently within the `rustc_mir` crate.

See associated issue: rust-lang#80647.

r? `@RalfJung`
@bors
Copy link
Contributor

bors commented Jan 18, 2021

⌛ Testing commit 65b5e43 with merge 0677d97...

@bors
Copy link
Contributor

bors commented Jan 18, 2021

☀️ Test successful - checks-actions
Approved by: RalfJung
Pushing 0677d97 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 18, 2021
@bors bors merged commit 0677d97 into rust-lang:master Jan 18, 2021
@rustbot rustbot added this to the 1.51.0 milestone Jan 18, 2021
@oliviacrain oliviacrain deleted the proj_based branch January 18, 2021 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mir Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-cleanup Category: PRs that clean code up or issues documenting cleanup. merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants