fix(autofmt): remove extra whitespace before commas in for-loop tuple patterns (#5384)

* fix(autofmt): remove extra whitespace before commas in for-loop tuple 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 #5348

* style: apply rustfmt to writer.rs

---------

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
John CostaandJonathan Kelley authored and GitHub committed 2026-03-27 17:15:32 -07:00
1 parent fff2e3d5a9
commit e5b9c39f4e
4 files changed
+49 -5

No files matched your search

+1 -5
View File
@@ -153,11 +153,7 @@ impl<'a> Writer<'a> {
}
fn write_for_loop(&mut self, forloop: &ForLoop) -> std::fmt::Result {
write!(
self.out,
"for {} in ",
forloop.pat.clone().into_token_stream(),
)?;
write!(self.out, "for {} in ", self.unparse_pat(&forloop.pat),)?;
self.write_inline_expr(&forloop.expr)?;