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 abstractions more consistently #82091

Merged
merged 4 commits into from
Feb 23, 2021

Conversation

henryboisdequin
Copy link
Contributor

@henryboisdequin henryboisdequin commented Feb 14, 2021

Addresses this comment
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 Feb 14, 2021
@henryboisdequin
Copy link
Contributor Author

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

@rustbot rustbot 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
@rust-log-analyzer

This comment has been minimized.

@henryboisdequin
Copy link
Contributor Author

henryboisdequin commented Feb 14, 2021

@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
Contributor Author

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

@rustbot rustbot 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
@henryboisdequin henryboisdequin changed the title use option<PlaceRef<'tcx>> to clean up mir code a little use PlaceRef abstractions more consistently Feb 14, 2021
@henryboisdequin
Copy link
Contributor Author

@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
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
Copy link
Contributor Author

henryboisdequin commented Feb 16, 2021

@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
Contributor Author

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

@rustbot rustbot 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 henryboisdequin force-pushed the use-place-ref-more branch 2 times, most recently from 0573d2d to 606752c Compare February 16, 2021 01:36
@henryboisdequin
Copy link
Contributor Author

@RalfJung visit_projection now takes a PlaceRef

@RalfJung
Copy link
Member

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

@RalfJung
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Feb 20, 2021

📌 Commit a9c6188 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 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``
@camelid
Copy link
Member

camelid commented Feb 23, 2021

Associated issue: #80647

Should this PR close that issue, or no?

@henryboisdequin
Copy link
Contributor Author

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:master Feb 23, 2021
@rustbot rustbot 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
Member

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

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. 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.

7 participants