Skip to content

Conversation

spastorino
Copy link
Member

Closes #52669

@rust-highfive
Copy link
Contributor

r? @cramertj

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 15, 2018
@spastorino
Copy link
Member Author

r? @nikomatsakis

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

Looks good. Left some requests for comments. :)

let mut mpis = vec![mpi];

let mut curr_mpi = mpi;
while let Some(parent_mpi) = &self.move_data.move_paths[curr_mpi].parent {
Copy link
Contributor

Choose a reason for hiding this comment

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

you probably don't need the & here or the * on the lines below

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd also like to see a comment explaining this. Something like:


If we are found a use of a.b.c which was in error, then we want to look for moves not only of a.b.c but also a.b and a.

Copy link
Contributor

Choose a reason for hiding this comment

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

Writing that out makes me realize that probably there is a similar bug the other way... e.g., what happens here?

fn main() {
    let x = (vec![1, 2, 3], );
    drop(x.0);
    drop(x);
}

Ah, trying it on play, it seems to work ok. Interesting. I guess that the moves data already handles this case -- i.e., a move of x.0 is marked as a move of x. Maybe add this to the comment:


Note that the moves data already includes "parent" paths, so we don't have to worry about the other case: that is, if there is a move of a.b.c, it is already marked as a move of a.b and a as well, so we will generate the correct errors there.


but @pnkfelix can you verify that comment? ☝️

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, I wonder if we want to make a helper for iterating over all parents...

Copy link
Member Author

Choose a reason for hiding this comment

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

@nikomatsakis everything is fixed.

@spastorino spastorino force-pushed the use-of-moved-value-error branch from 1d08ffe to 504d732 Compare September 16, 2018 04:35
@memoryruins memoryruins added the A-NLL Area: Non-lexical lifetimes (NLL) label Sep 16, 2018
@spastorino spastorino force-pushed the use-of-moved-value-error branch from 504d732 to e9029ce Compare September 17, 2018 16:39
@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Sep 17, 2018

📌 Commit e9029ce has been approved by nikomatsakis

@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 Sep 17, 2018
@bors
Copy link
Collaborator

bors commented Sep 20, 2018

⌛ Testing commit e9029ce with merge f7f4c50...

bors added a commit that referenced this pull request Sep 20, 2018
…sakis

Inspect parents paths when checking for moves

Closes #52669
@bors
Copy link
Collaborator

bors commented Sep 20, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing f7f4c50 to master...

@bors bors merged commit e9029ce into rust-lang:master Sep 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-NLL Area: Non-lexical lifetimes (NLL) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants