-
Notifications
You must be signed in to change notification settings - Fork 13k
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
derive(Copy) on tuple struct with non-Copy field uses unclear "<unnamed_field>" #27340
Comments
This one doesn't sound too hard. Mind if I try my hand at it? |
@cybergeek94 It might be worthwhile in the long run to fix this globally, so that things other than |
Additionally, it would be nice to |
@apasel422 Yeap, the core problem is that fields in a tuple struct aren't given names when added to the AST during parsing. I am unsure how to approach this without breaking a lot of difficult code. |
The primary blocker to giving names to tuple struct fields is that One solution I can see is to add a new field to With that refactored, we could create a name based on the field's index and/or type, and print that to point users towards the culprit in their code. However, a less intrusive change would be to leave the naming semantics as-is, but change This approach would change less of the compiler's internals while being more informative for However, the latter approach would not fix other occurrences of the uninformative @huonw, what would you recommend? |
From a correctness point of view, I think this would make more sense as making At a high level doing this in a way that ensures anywhere that might print In any case, I'm not the best mentor. Maybe someone from @rust-lang/compiler can provide more precise guidance. |
The Having an |
It seems to me that using Option is tonnes nicer than using <unnamed_field>, but this is sort of orthogonal to the issue here. When making the error message in derive (or wherever that happens), can we detect that the field is unnamed, then make up a name on the spot, rather than using the name field? |
@cybergeek94 Returning more information in |
Searching for |
#27551 is merged. |
It'd be nice to mention either the type, or the field index. (Or both.)
The text was updated successfully, but these errors were encountered: