-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Better error reporting in Copy derive #50536
Conversation
There was a problem hiding this 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.
src/test/ui/issue-50480.stderr
Outdated
| ^^^^ | ||
... | ||
LL | struct Foo(NotDefined, <i32 as Iterator>::Item, Vec<i32>, String); | ||
| ------- this field does not implement `Copy` |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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`
Merged the errors as requested, I intended to expand on this PR but gave up, it will be just this for now. |
@bors r+ |
📌 Commit dfac81c has been approved by |
Fix tuple struct field spans Fix rust-lang#50578. Will have a merge conflict with rust-lang#50536.
⌛ Testing commit dfac81c2abfb6255f5d24960b2b0acf435d200da with merge 09a553f39d39568bf8ea1d32fa093c5ec9d1082b... |
💔 Test failed - status-appveyor |
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.
dfac81c
to
6389f35
Compare
@bors r+ |
📌 Commit 6389f35 has been approved by |
…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
☀️ Test successful - status-appveyor, status-travis |
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