Clean up more comments near use declarations#126776
Merged
bors merged 3 commits intorust-lang:masterfrom Jul 17, 2024
Merged
Conversation
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.
#125443 will reformat all use declarations in the repository. There are a few edge cases involving comments on use declarations that require care. This PR fixes them up so #125443 can go ahead with a simple
x fmt --all. A follow-up to #126717.r? @cuviper
[Post-merge update] Just to clarify what happened here: with auto-formatting of
usedeclarations there is a very small loss of expressivity involving comments that apply to multipleusedeclarations. Imagine you want to write this:You just can't have a custom separate section any more; the sections are fixed. (Unless rust-lang/rustfmt#6241 is addressed, which may happen in the future.)
[Second update] I learned that you can have custom groups, by using
#[rustfmt::skip]:The
use a::d::eacts as a barrier: rustfmt won't reorder otherusedeclarations around it. This is a very nice, idiomatic way of doing a custom group.)[end of second update]
Fortunately, there are multiple reasonable alternatives:
or this:
or this:
or you could even exclude the comment if it's not that important.
Comments having the first form are rare in practice. This PR converted the small number of them in the repository into one of the subsequent forms.