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

When using value after move, point at span of local #57294

Merged
merged 6 commits into from
Jan 25, 2019

Conversation

estebank
Copy link
Contributor

@estebank estebank commented Jan 3, 2019

When trying to use a value after move, instead of using a note, point
at the local declaration that has a type that doesn't implement Copy
trait.

error[E0382]: use of moved value: `x`
  --> $DIR/issue-34721.rs:27:9
   |
LL |     pub fn baz<T: Foo>(x: T) -> T {
   |                -       - move occurs because `x` has type `T`, which does not implement the `Copy` trait
   |                |
   |                consider adding a `Copy` constraint to this type argument
LL |         if 0 == 1 {
LL |             bar::bar(x.zero())
   |                      - value moved here
LL |         } else {
LL |             x.zero()
   |             - value moved here
LL |         };
LL |         x.zero()
   |         ^ value used here after move

Fix #34721.

@rust-highfive
Copy link
Collaborator

r? @eddyb

(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 Jan 3, 2019
@estebank

This comment has been minimized.

@estebank
Copy link
Contributor Author

estebank commented Jan 7, 2019

@nikomatsakis, you might also be interested in taking a look at this.

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.

I think this looks nice

@estebank
Copy link
Contributor Author

Ping @eddyb :)

@estebank
Copy link
Contributor Author

r? @nikomatsakis

@rust-highfive rust-highfive assigned nikomatsakis and unassigned eddyb Jan 18, 2019
@nikomatsakis nikomatsakis 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 Jan 18, 2019
@estebank estebank 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 Jan 18, 2019
@estebank
Copy link
Contributor Author

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Jan 21, 2019

📌 Commit 09006d8 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 Jan 21, 2019
Centril added a commit to Centril/rust that referenced this pull request Jan 21, 2019
…sakis

When using value after move, point at span of local

When trying to use a value after move, instead of using a note, point
at the local declaration that has a type that doesn't implement `Copy`
trait.

```
error[E0382]: use of moved value: `x`
  --> $DIR/issue-34721.rs:27:9
   |
LL |     pub fn baz<T: Foo>(x: T) -> T {
   |                -       - move occurs because `x` has type `T`, which does not implement the `Copy` trait
   |                |
   |                consider adding a `Copy` constraint to this type argument
LL |         if 0 == 1 {
LL |             bar::bar(x.zero())
   |                      - value moved here
LL |         } else {
LL |             x.zero()
   |             - value moved here
LL |         };
LL |         x.zero()
   |         ^ value used here after move
```

Fix rust-lang#34721.
@bors
Copy link
Contributor

bors commented Jan 22, 2019

⌛ Testing commit 09006d8 with merge 1c661d9fc2c921cbd8f8baae786af49812562ad7...

@bors
Copy link
Contributor

bors commented Jan 22, 2019

💔 Test failed - checks-travis

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 22, 2019
@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 22, 2019
@estebank
Copy link
Contributor Author

@bors r- need to update nll tests.

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 22, 2019
@estebank
Copy link
Contributor Author

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Jan 24, 2019

📌 Commit baa0828 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 24, 2019
@nikomatsakis
Copy link
Contributor

@bors r-

@estebank I never actually r+'d :)

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 24, 2019
@nikomatsakis
Copy link
Contributor

@bors r+

However, it does seem fine. 😛

@bors
Copy link
Contributor

bors commented Jan 24, 2019

📌 Commit baa0828 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 24, 2019
@estebank
Copy link
Contributor Author

@nikomatsakis I though I had seen green checkmark gated on fixing feedback, but looking now I must have gotten confused with a different PR, sorry about that 😬

Centril added a commit to Centril/rust that referenced this pull request Jan 25, 2019
…sakis

When using value after move, point at span of local

When trying to use a value after move, instead of using a note, point
at the local declaration that has a type that doesn't implement `Copy`
trait.

```
error[E0382]: use of moved value: `x`
  --> $DIR/issue-34721.rs:27:9
   |
LL |     pub fn baz<T: Foo>(x: T) -> T {
   |                -       - move occurs because `x` has type `T`, which does not implement the `Copy` trait
   |                |
   |                consider adding a `Copy` constraint to this type argument
LL |         if 0 == 1 {
LL |             bar::bar(x.zero())
   |                      - value moved here
LL |         } else {
LL |             x.zero()
   |             - value moved here
LL |         };
LL |         x.zero()
   |         ^ value used here after move
```

Fix rust-lang#34721.
bors added a commit that referenced this pull request Jan 25, 2019
Rollup of 5 pull requests

Successful merges:

 - #56217 (Add grammar in docs for {f32,f64}::from_str, mention known bug.)
 - #57294 (When using value after move, point at span of local)
 - #57652 (Update/remove some old readmes)
 - #57802 (Print visible name for types as well as modules.)
 - #57865 (Don't ICE when logging unusual types)

Failed merges:

r? @ghost
@bors bors merged commit baa0828 into rust-lang:master Jan 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

5 participants