Skip to content

use PlaceRef abstractions more consistently - #82091

Merged
bors merged 4 commits into
rust-lang:masterfrom
henryboisdequin:use-place-ref-more
Feb 23, 2021
Merged

use PlaceRef abstractions more consistently#82091
bors merged 4 commits into
rust-lang:masterfrom
henryboisdequin:use-place-ref-more

Conversation

@henryboisdequin

@henryboisdequinhenryboisdequin commented Feb 14, 2021

Copy link
Copy Markdown
Contributor

Addresses this comment
Associated issue: #80647

r? @RalfJung

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 14, 2021
@henryboisdequin

Copy link
Copy Markdown
ContributorAuthor

@rustbot label: +C-cleanup +A-mir +T-compiler

@rustbotrustbot 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 Feb 14, 2021
Comment threadcompiler/rustc_middle/src/mir/mod.rs Outdated
Comment threadcompiler/rustc_mir/src/transform/check_consts/validation.rs
Comment threadcompiler/rustc_mir/src/transform/check_consts/validation.rs Outdated
Comment threadcompiler/rustc_mir/src/transform/check_consts/validation.rs Outdated
Comment threadcompiler/rustc_mir/src/transform/check_consts/validation.rs Outdated
@rust-log-analyzer

This comment has been minimized.

Comment threadcompiler/rustc_mir/src/transform/check_consts/validation.rs Outdated
@henryboisdequin

henryboisdequin commented Feb 14, 2021

Copy link
Copy Markdown
ContributorAuthor

@RalfJung Update:

  • Addressed all of your comments (but not pushed yet)
  • I'm currently changing visit_projection and all of its associated functions to take a PlaceRef

@henryboisdequin

Copy link
Copy Markdown
ContributorAuthor

@rustbot label: +S-waiting-on-author -S-waiting-on-review

@rustbotrustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 14, 2021
@henryboisdequinhenryboisdequin changed the title use option<PlaceRef<'tcx>> to clean up mir code a littleuse PlaceRef abstractions more consistentlyFeb 14, 2021
@henryboisdequin

Copy link
Copy Markdown
ContributorAuthor

@RalfJung Nearly finished but I still have some errors and don't know how to resolve them. The current code is pushed, as you can see. Here are the errors:

error[E0308]: mismatched types
--> compiler/rustc_middle/src/mir/visit.rs:154:34
|
68 | / macro_rules! make_mir_visitor {
69 | | ($visitor_trait_name:ident, $($mutability:ident)?) => {
70 | | pub trait $visitor_trait_name<'tcx> {
71 | | // Override these, and call `self.super_xxx` to revert back to the
... |
154 | | self.super_place(place_ref, context, location);
| | ^^^^^^^^^ expected struct `mir::PlaceRef`, found `&mut mir::PlaceRef<'tcx>`
... |
929 | | }
930 | | }
| |_- in this expansion of `make_mir_visitor!`
...
1084 | make_mir_visitor!(Visitor,);
| ---------------------------- in this macro invocation
error[E0308]: mismatched types
--> compiler/rustc_middle/src/mir/visit.rs:383:29
|
68 | / macro_rules! make_mir_visitor {
69 | | ($visitor_trait_name:ident, $($mutability:ident)?) => {
70 | | pub trait $visitor_trait_name<'tcx> {
71 | | // Override these, and call `self.super_xxx` to revert back to the
... |
383 | | &mut place.as_ref(),
| | ^^^^^^^^^^^^^^^^^^^ expected struct `mir::PlaceRef`, found `&mir::Place<'_>`
... |
929 | | }
930 | | }
| |_- in this expansion of `make_mir_visitor!`
...
1084 | make_mir_visitor!(Visitor,);
| ---------------------------- in this macro invocation
|
= note: expected mutable reference `&mut mir::PlaceRef<'tcx>`
found mutable reference `&mut &mir::Place<'_>`
error[E0308]: mismatched types
--> compiler/rustc_middle/src/mir/visit.rs:390:29
|
68 | / macro_rules! make_mir_visitor {
69 | | ($visitor_trait_name:ident, $($mutability:ident)?) => {
70 | | pub trait $visitor_trait_name<'tcx> {
71 | | // Override these, and call `self.super_xxx` to revert back to the
... |
390 | | &mut place.as_ref(),
| | ^^^^^^^^^^^^^^^^^^^ expected struct `mir::PlaceRef`, found `&mir::Place<'_>`
... |
929 | | }
930 | | }
| |_- in this expansion of `make_mir_visitor!`
...
1084 | make_mir_visitor!(Visitor,);
| ---------------------------- in this macro invocation
|
= note: expected mutable reference `&mut mir::PlaceRef<'tcx>`
found mutable reference `&mut &mir::Place<'_>`
error[E0308]: mismatched types
--> compiler/rustc_middle/src/mir/visit.rs:383:29
|
68 | / macro_rules! make_mir_visitor {
69 | | ($visitor_trait_name:ident, $($mutability:ident)?) => {
70 | | pub trait $visitor_trait_name<'tcx> {
71 | | // Override these, and call `self.super_xxx` to revert back to the
... |
383 | | &mut place.as_ref(),
| | ^^^^^^^^^^^^^^^^^^^ expected struct `mir::PlaceRef`, found `&mir::Place<'_>`
... |
929 | | }
930 | | }
| |_- in this expansion of `make_mir_visitor!`
...
1085 | make_mir_visitor!(MutVisitor, mut);
| ----------------------------------- in this macro invocation
|
= note: expected mutable reference `&mut mir::PlaceRef<'tcx>`
found mutable reference `&mut &mir::Place<'_>`
error[E0308]: mismatched types
--> compiler/rustc_middle/src/mir/visit.rs:390:29
|
68 | / macro_rules! make_mir_visitor {
69 | | ($visitor_trait_name:ident, $($mutability:ident)?) => {
70 | | pub trait $visitor_trait_name<'tcx> {
71 | | // Override these, and call `self.super_xxx` to revert back to the
... |
390 | | &mut place.as_ref(),
| | ^^^^^^^^^^^^^^^^^^^ expected struct `mir::PlaceRef`, found `&mir::Place<'_>`
... |
929 | | }
930 | | }
| |_- in this expansion of `make_mir_visitor!`
...
1085 | make_mir_visitor!(MutVisitor, mut);
| ----------------------------------- in this macro invocation
|
= note: expected mutable reference `&mut mir::PlaceRef<'tcx>`
found mutable reference `&mut &mir::Place<'_>`
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0308`.
error: could not compile `rustc_middle`

I'm not really sure why they are happening or how to fix them. Help would be appreciated!

@rust-log-analyzer

This comment has been minimized.

@RalfJung

Copy link
Copy Markdown
Member

@henryboisdequin thanks! I'll take a look, but I can't promise I'll do that before next weekend. In the mean time, you could also ask on the Rust Zulip; there might be people there that can help you.

@henryboisdequin

henryboisdequin commented Feb 16, 2021

Copy link
Copy Markdown
ContributorAuthor

@RalfJung on Zulip I and a couple of others discussed that it would be impossible to replace &mut Place with &mut PlaceRef in a mutable visitor. To make such a change, we would require a lot more refactoring which I think should be done in another PR. In this PR, it just addresses your comment. I'll start working on the other PR!

Oops: #80647 (comment)

@henryboisdequin

Copy link
Copy Markdown
ContributorAuthor

@rustbot label -S-waiting-on-author +S-waiting-on-review

@rustbotrustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 16, 2021
@henryboisdequin
henryboisdequinforce-pushed the use-place-ref-more branch 2 times, most recently from 0573d2d to 606752cCompareFebruary 16, 2021 01:36
@henryboisdequin

Copy link
Copy Markdown
ContributorAuthor

@RalfJungvisit_projection now takes a PlaceRef

Comment threadcompiler/rustc_middle/src/mir/visit.rs Outdated
Comment threadcompiler/rustc_middle/src/mir/visit.rs Outdated
@RalfJung

Copy link
Copy Markdown
Member

Awesome, thanks a lot. :)
Let's see if CI passes, then I'll r+.

@RalfJung

Copy link
Copy Markdown
Member

@bors r+

@bors

bors commented Feb 20, 2021

Copy link
Copy Markdown
Collaborator

📌 Commit a9c6188 has been approved by RalfJung

@borsbors 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 Feb 20, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Feb 20, 2021
… r=RalfJung
use PlaceRef abstractions more consistently
Addresses this [comment](https://github.com/rust-lang/rust/pull/80865/files#r558978715)
Associated issue: rust-lang#80647
r? `@RalfJung`
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Feb 23, 2021
… r=RalfJung
use PlaceRef abstractions more consistently
Addresses this [comment](https://github.com/rust-lang/rust/pull/80865/files#r558978715)
Associated issue: rust-lang#80647
r? ``@RalfJung``
This was referenced Feb 23, 2021
@camelid

Copy link
Copy Markdown
Member

Associated issue: #80647

Should this PR close that issue, or no?

@henryboisdequin

Copy link
Copy Markdown
ContributorAuthor

Associated issue: #80647

Should this PR close that issue, or no?

@RalfJung What do you think?

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 23, 2021
Rollup of 12 pull requests
Successful merges:
- rust-lang#79423 (Enable smart punctuation)
- rust-lang#81154 (Improve design of `assert_len`)
- rust-lang#81235 (Improve suggestion for tuple struct pattern matching errors.)
- rust-lang#81769 (Suggest `return`ing tail expressions that match return type)
- rust-lang#81837 (Slight perf improvement on char::to_ascii_lowercase)
- rust-lang#81969 (Avoid `cfg_if` in `std::os`)
- rust-lang#81984 (Make WASI's `hard_link` behavior match other platforms.)
- rust-lang#82091 (use PlaceRef abstractions more consistently)
- rust-lang#82128 (add diagnostic items for OsString/PathBuf/Owned as well as to_vec on slice)
- rust-lang#82166 (add s390x-unknown-linux-musl target)
- rust-lang#82234 (Remove query parameters when skipping search results)
- rust-lang#82255 (Make `treat_err_as_bug` Option<NonZeroUsize>)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit cc07061 into rust-lang:masterFeb 23, 2021
@rustbotrustbot added this to the 1.52.0 milestone Feb 23, 2021
@henryboisdequin
henryboisdequin deleted the use-place-ref-more branch February 23, 2021 07:55
@RalfJung

Copy link
Copy Markdown
Member

No it should not close the issue, there's still more cleanup left to be done.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlC-cleanupCategory: PRs that clean code up or issues documenting cleanup.S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant 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.

7 participants

@henryboisdequin@rust-log-analyzer@RalfJung@bors@camelid@rust-highfive@rustbot