Improve contractimpl attribute field parsing #259
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Error if contractimpl contains unexpected fields, and make suggestions in compile errors for what the field should be named.
Why
Typos are easy and we should utilize the fact that proc-macros can generate compile errors to alert the developer they are using the macro incorrectly.
Close #258
Known limitations
This partially closes #258, because unexpected fields will now error. This change uses
darling
because that crate will help us scale the attribute use cases into additional cases with less code. However the exact case that @jonjove experienced in #258 is not yet fixed because of a bug in darling where string literals without a field name in the attribute list are ignored. I've opened TedDriggs/darling#192. I'm going to mark #258 as resolved because I think this partial solution and using darling is better than us continuing to extend the existingget_args
code to handle the error cases. We've done it elsewhere in macros, but in this specific case darling is a better long term solution.