fixes #4115, #4029, #3898#4136
Merged
Merged
Conversation
topecongiro
approved these changes
Apr 22, 2020
Contributor
topecongiro
left a comment
There was a problem hiding this comment.
Awesome! LGTM, thank you!
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:
I think we could use overflow::rewrite_with_parens for this with some refactoring, though I am not confident.
Contributor
|
Backported in #4564 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 returnsNoneif thederiveis 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.