fix(autofmt): remove extra whitespace before commas in for-loop tuple patterns#5384
Open
costajohnt wants to merge 2 commits intoDioxusLabs:mainfrom
Open
fix(autofmt): remove extra whitespace before commas in for-loop tuple patterns#5384costajohnt wants to merge 2 commits intoDioxusLabs:mainfrom
costajohnt wants to merge 2 commits intoDioxusLabs:mainfrom
Conversation
… patterns `dx fmt` was adding spaces before commas in for-loop destructuring patterns (e.g. `for (index , name , value)`) because `TokenStream::Display` inserts spaces between every token. Route the pattern through prettyplease via a new `unparse_pat` helper, following the existing `unparse_expr` pattern. Fixes DioxusLabs#5348
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.
Summary
Fixes #5348
dx fmtwas adding extra spaces before commas in for-loop tuple destructuring patterns:The root cause was that
forloop.pat.clone().into_token_stream()usesproc_macro2::TokenStream::Display, which inserts a space between every token including before commas in tuple patterns.The fix adds an
unparse_pathelper that routes the pattern throughprettypleasefor proper formatting, following the existingunparse_exprpattern.Test plan
forloop_tuple.rsxsample test covering 3-element tuple, simple ident, 2-element tuple, and wildcard patternsdioxus-autofmttests passifchain_forlooptest continues to pass (simplefor i in bregression)