-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bump rustfmt version #80843
Merged
Merged
Bump rustfmt version #80843
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@calebcartwright
This looks like a regression,
|
patterns outside ofmatches!
are not formatted with an indent like this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one requires a much more thorough response. The short answer is that no it's not a regression, though you're not the first person to raise the question and I can certainly understand why.
For the longer answer, there's two core parts.
First, there was an issue in rustfmt where in cases with multi pats and at least one
_
rustfmt was entirely unable to process the arg and thus wasn't applying any formatting at all against the mac call expr and just leaving the original formatting in place; rustfmt was just keeping whatever was here before as-is, not successfully applying the formatting rules.An easy way to see this in practice is by running the older versions (I guess
x.py fmt
from master will work) with a wildly misformatted version of this, and you'll see that wild formatting remains untouched:On the rustfmt side we've been particularly benefiting from the recent parser/tokens/etc. work that folks like yourself and Aaron have been working on, and now that we've pulled those rustc changes into rustfmt it's finally able to actually format these
matches!
calls producing the formatting seen here.The second part relates to how we have to attempt to format macro call args in rustfmt. Obviously we're working with the calls in the AST pre-expansion, so when we encounter a maccall expression, we'll use the token streams to instantiate a parser and attempt to parse the args individually so that we can then apply the corresponding formatting rules when possible (e.g. an expr or type).
In the case of
matches!
, the tokens for that second arg actually ends up getting successfully parsed as a standard binop expression, and so rustfmt applies the corresponding formatting rules for binops which is why it gets indented this way.Eventually I'd like to introduce some new special case process for
matches!
mac calls since we'll know definitively that second arg isn't actually a binop expr, and then be able to apply more pattern-like formatting rules instead.Unfortunately though, for the foreseeable future rustfmt is going to continue to be formatting
matches
like any other mac call even though the emitted formatting is less than desireable