Repository navigation
Conversation
cburgdorf
force-pushed
the
fe_fmt_fix
branch
4 times, most recently
from
September 29, 2026 22:03
308d519 to
22bdb58
Compare
Collaborator
|
Thanks for this PR. I added a few commits on top of yours, without changing your commit, for cases where
Checked with the full test suite and clippy, each commit building on its own, and a merge into current master with the formatter tests passing there. Formatting every Feel free to reshape, squash or drop any of these. |
cburgdorf
force-pushed
the
fe_fmt_fix
branch
2 times, most recently
from
October 4, 2026 22:37
33a33b5 to
e0c6059
Compare
Keep line breaks after parser-ambiguous operators, separate nested qualified-type angle brackets, and retain restricted visibility modifiers. Handle item-leading trivia without accumulating blank lines, and add corpus round-trip and regression coverage for reparsing and idempotence.
Master keeps attributes on for loops now; this adds cases it does not cover: several attributes stacked on one loop, attributes on a nested loop, and irregular spacing in the loop header.
…tributes Inner attributes of a nested module (`#![...]`) were printed from a separate path that dropped the blank line between them and the first item. Render them like other attribute lists instead: keep the line breaks that follow them, and print `#![` for inner attributes in `NormalAttr`. This also lets the next change keep comments placed among inner attributes.
An attribute list was formatted from its attributes only, so a plain comment between doc comments and attributes was deleted (as in `std/src/abi/sol.fe`). A comment right after the attribute list belongs to the item node, so it sent the whole item through the comment-preserving fallback, which printed it with a leading space. Such comments are now kept with the attribute list, one per line, and the item is formatted as usual.
The one-element tuple rule also applied to tuple variants, so `Some(T)` and the pattern `Some(x)` were written as `Some(T,)` and `Some(x,)`. Only a one-element tuple type or pattern needs that comma.
`pub(ingot)` and `pub(super)` still parse after being widened to `pub`, so only a snapshot catches that regression. Cover functions, structs, fields, impl functions, consts, enums, traits, type aliases, modules, `use` and extern functions, with and without comments inside the item.
The corpus test only checked that formatted files parse and are stable, which passes when the formatter deletes an attribute, a comment or a visibility restriction. Also compare the tokens of each file before and after formatting, ignoring whitespace, separator commas and the braces added around `return` match arm bodies.
The visibility, for loop attribute and inner attribute fixes already ship from master with their own entry, so only mention what this branch adds.
This branch has not been deployed
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.
Keep line breaks after parser-ambiguous operators, separate nested qualified-type angle brackets, and retain restricted visibility modifiers.
Handle item-leading trivia without accumulating blank lines, and add corpus round-trip and regression coverage for reparsing and idempotence.