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.
Fixes #4115. Fixes #4029. Fixes #3898.
The new tests fail on master as follows:
They (and all other tests) pass with the proposed fix.
At the root of all three issues is the use of
ast::Attribute:: meta_item_list()
which returnsNone
if thederive
is malformed. In addition no affordance was made for comments interspersed with derive components. This fix checks for errors frommeta_item_list()
and leans on existing mechanisms to deal with comments.Although I handled this case, I would appreciate review feedback for the case where a derive doesn't fit quite fit on a single line and is formatted like this:
To handle that case I use Always for the trailing separator with ListFormatting and then remove that final character if it all does fit on one line. I couldn't find an existing mechanism in ListFormatting that did what I wanted there.
See lines 143 and 177.