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

Better error reporting in Copy derive #50536

Merged

Conversation

leoyvens
Copy link
Contributor

@leoyvens leoyvens commented May 8, 2018

In Copy derive, report all fulfillment erros when present and do not report errors for types tainted with TyErr. Also report all fields which are not Copy rather than just the first.

Also refactored fn fully_normalize, removing the not very useful helper function along with a FIXME to the closed issue #26721 that looks out of context now.

Fixes #50480

r? @estebank

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 8, 2018
Copy link
Contributor

@estebank estebank left a comment

Choose a reason for hiding this comment

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

Great work! One nitpick inline.

| ^^^^
...
LL | struct Foo(NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
| ------- this field does not implement `Copy`
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not introduced by your PR, nor it needs to be addressed here, but the String) span is wrong here and in the previous error's Vec<i32>,.

tcx.def_span(field.did),
"this field does not implement `Copy`")
.emit()
for field in fields {
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of having one error per field, I think there should be one error and one span_label per field. This way we reduce the amount of errors being emitted to only one per struct:

+error[E0204]: the trait `Copy` may not be implemented for this type
+  --> $DIR/issue-50480.rs:11:17
+   |
+LL | #[derive(Clone, Copy)]
+   |                 ^^^^
+...
+LL | struct Foo(NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
+   |                                                 --------- ------- this field does not implement `Copy`
+   |                                                 |
+   |                                                 this field does not implement `Copy`

@leoyvens
Copy link
Contributor Author

leoyvens commented May 9, 2018

Merged the errors as requested, I intended to expand on this PR but gave up, it will be just this for now.

@estebank
Copy link
Contributor

estebank commented May 9, 2018

@bors r+

@bors
Copy link
Contributor

bors commented May 9, 2018

📌 Commit dfac81c has been approved by estebank

@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 May 9, 2018
alexcrichton added a commit to alexcrichton/rust that referenced this pull request May 10, 2018
Fix tuple struct field spans

Fix rust-lang#50578. Will have a merge conflict with rust-lang#50536.
@bors
Copy link
Contributor

bors commented May 12, 2018

⌛ Testing commit dfac81c2abfb6255f5d24960b2b0acf435d200da with merge 09a553f39d39568bf8ea1d32fa093c5ec9d1082b...

@bors
Copy link
Contributor

bors commented May 12, 2018

💔 Test failed - status-appveyor

@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 May 12, 2018
@leoyvens
Copy link
Contributor Author

I just need to rebase this.

In Copy derive, report all fulfillment erros when present and do not
report errors for types tainted with `TyErr`. Also report all fields
which are not Copy rather than just the first.

Also refactored `fn fully_normalize`, removing the not very useful
helper function along with a FIXME to the closed issue rust-lang#26721 that's
looks out of context now.
@leoyvens leoyvens force-pushed the report-fullfilment-errors-in-copy-derive branch from dfac81c to 6389f35 Compare May 12, 2018 18:07
@estebank
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented May 12, 2018

📌 Commit 6389f35 has been approved by estebank

@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 May 12, 2018
@bors
Copy link
Contributor

bors commented May 12, 2018

⌛ Testing commit 6389f35 with merge 6fb34bd...

bors added a commit that referenced this pull request May 12, 2018
…derive, r=estebank

Better error reporting in Copy derive

In Copy derive, report all fulfillment erros when present and do not report errors for types tainted with `TyErr`. Also report all fields which are not Copy rather than just the first.

Also refactored `fn fully_normalize`, removing the not very useful helper function along with a FIXME to the closed issue #26721 that looks out of context now.

Fixes #50480

r? @estebank
@bors
Copy link
Contributor

bors commented May 13, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: estebank
Pushing 6fb34bd to master...

@bors bors merged commit 6389f35 into rust-lang:master May 13, 2018
oli-obk added a commit to rust-lang/rust-clippy that referenced this pull request May 14, 2018
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.

Bad second error about Copy reference
4 participants