Fix trailing newline in singleton tuple pretty printing - #274
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
Note
Copilot was unable to run its full agentic suite in this review.
Copilot review overview
Review effort: Lite
Findings: 1
Open (2)
What changed in this PR
Adjusts pretty-printing of a 1-element tuple/type list to avoid allocating an unused separator builder and to ensure a trailing comma is emitted for the single-element case.
Changes:
- Removes the top-level
separatorbinding and scopes it to the multi-element branch. - Changes the single-element formatting to append a comma before wrapping in parentheses.
| File | Description |
|---|---|
| src/rty.rs | Tweaks pretty-printer separator handling for single vs multi element cases. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| let separator = allocator.text(",").append(allocator.line()); | ||
| if self.elems.len() == 1 { | ||
| self.elems[0].pretty(allocator).append(separator).parens() | ||
| self.elems[0].pretty(allocator).append(",").parens() |
| let separator = allocator.text(",").append(allocator.line()); | ||
| if self.elems.len() == 1 { | ||
| self.elems[0].pretty(allocator).append(separator).parens() | ||
| self.elems[0].pretty(allocator).append(",").parens() |


Singleton tuple types append the element separator after their sole element, leaving a line break before the closing parenthesis. Append only the trailing comma so
(own int,)prints without that break.Move the separator into the multiple-element branch, preserving its existing wrapping behavior.
Validation:
cargo fmt --all -- --check,cargo test --lib(3 passed), andgit diff --check.