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

borrowck: name the correct type in error message #43993

Merged
merged 1 commit into from
Aug 22, 2017

Conversation

tamird
Copy link
Contributor

@tamird tamird commented Aug 19, 2017

@arielb1
Copy link
Contributor

arielb1 commented Aug 20, 2017

But this error also occurs for arrays:

fn main() {
    let x = [Box::new(0)][0];
}
error[E0508]: cannot move out of type `[std::boxed::Box<i32>; 1]`, a non-copy array
 --> src/main.rs:2:13
  |
2 |     let x = [Box::new(0)][0];
  |             ^^^^^^^^^^^^^^^^
  |             |
  |             help: consider using a reference instead `&[Box::new(0)][0]`
  |             cannot move out of here

@Mark-Simulacrum
Copy link
Member

r? @arielb1 -- I'm not familiar with this area of the code, perhaps you could suggest how to differentiate between slices and arrays?

@arielb1
Copy link
Contributor

arielb1 commented Aug 20, 2017

The type is available right here on b.ty.sty.

@tamird tamird force-pushed the better-wording-error branch 3 times, most recently from 33d479f to a9c85d3 Compare August 20, 2017 17:41
@tamird tamird changed the title borrowck: call a slice a slice borrowck: name the correct type in error message Aug 20, 2017
@tamird
Copy link
Contributor Author

tamird commented Aug 20, 2017

This should be good to go.

span_bug!(move_from.span, "this path should not cause illegal move");
}
}
let type_name = match &b.ty.sty {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you maintain the bug! on b.ty.sty == ty::TyArray and ik == Kind::Pattern?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, done.

Verified

This commit was signed with the committer’s verified signature.
tamird Tamir Duberstein
Closes rust-lang#36407.
@tamird tamird force-pushed the better-wording-error branch from a9c85d3 to c1ed862 Compare August 20, 2017 22:34
@arielb1
Copy link
Contributor

arielb1 commented Aug 21, 2017

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Aug 21, 2017

📌 Commit c1ed862 has been approved by arielb1

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Aug 22, 2017
bors added a commit that referenced this pull request Aug 22, 2017
Rollup of 5 pull requests

- Successful merges: #43993, #44001, #44010, #44014, #44029
- Failed merges:
@bors bors merged commit c1ed862 into rust-lang:master Aug 22, 2017
@tamird tamird deleted the better-wording-error branch September 8, 2017 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants