Handle DefinitiveListTactic::SpecialMacro when writing pre-comments#5028
Merged
calebcartwright merged 1 commit intorust-lang:masterfrom Oct 17, 2021
Merged
Handle DefinitiveListTactic::SpecialMacro when writing pre-comments#5028calebcartwright merged 1 commit intorust-lang:masterfrom
calebcartwright merged 1 commit intorust-lang:masterfrom
Conversation
Resolves 4615 Previously only Vertical and Mixed enum variants of DefinitiveListTactic were considered when rewriting pre-comments for inner items in lists::write_list. Because we failed to considering the SpecialMacro variant we ended up in a scenario where a ListItem with a pre_comment and a pre_comment_style of ListItemCommentStyle::DifferentLine was written on the same line as the list item itself. Now we apply the same pre-comment formatting to SpecialMacro, Vertical, and Mixed variants of DefinitiveListTactic.
calebcartwright
approved these changes
Oct 17, 2021
Member
calebcartwright
left a comment
There was a problem hiding this comment.
Excellent find and fix, thank you!
Comment on lines
+370
to
+373
| match tactic { | ||
| DefinitiveListTactic::SpecialMacro(_) | ||
| | DefinitiveListTactic::Vertical | ||
| | DefinitiveListTactic::Mixed => { |
Member
There was a problem hiding this comment.
Don't feel obligated to change anything, just sharing for awareness. For future reference, you may want to consider utilizing the matches! macro in these types of cases because it could both express the condition more succinctly, and it helps avoid the extra level of indentation that comes with the match arm body, e.g.
use DefinitiveListTactic::*;
if matches!(tactic, Vertical | Mixed | SpecialMacro(_)) {(with the wildcard import being another option to shorten the length of the pattern variants)
Contributor
Author
There was a problem hiding this comment.
I appreciate you pointing this out. It didn't even occur to me to use the matches! macro. I went ahead and made the change in #5034!
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.
Resolves #4615
Previously only
VerticalandMixedenum variants ofDefinitiveListTacticwere considered when rewriting pre-comments for inner items in
lists::write_list.Because we failed to considering the
SpecialMacrovariant we ended up ina scenario where a
ListItemwith apre_commentand apre_comment_styleof
ListItemCommentStyle::DifferentLinewas written on the same line as thelist item itself.
Now we apply the same pre-comment formatting to
SpecialMacro,Vertical,and
Mixedvariants ofDefinitiveListTactic.