Comment before semicolon prevents formatting expression
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
This code:
let unformatted = { 1}
// comment
;
or this:
let unformatted = { 1} // comment
;
will pass through rustfmt unchanged. Removing the comment causes the code to be formatted correctly, and other expressions are not affected.
You may be asking "why would anybody want to do this?" I keep a semicolon on its own line in a long chain of builder methods that I frequently have to modify, e.g.
builder
.configure(cfg_fn1)
.configure(cfg_fn2)
// .configure(cfg_fn3)
;
Occurs in rustfmt 1.5.1-nightly (b44197a 2022-09-05) and rustfmt 1.5.1-stable (4b91a6e 2022-08-08).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal examples in the issue or the linked Rust Playground, using the reported rustfmt versions to reproduce the behavior. Trace how rustfmt handles a comment before a semicolon in an expression, then verify that both examples are formatted while the builder-chain case remains supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100