Incorrectly and non-idempotently modifies `..` in macro
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Start with this:
fn a() {
a!(b {
c: d,
//
..
});
}
Rust rustfmt, and you get this:
fn a() {
a!(b {
c: d,
//
..
..
});
}
Run it a third time, and you get this:
fn a() {
a!(b {
c: d,
//
....
});
}
And then we have a fixed point.
This can cause rustfmt to break certain macro-using code. The behavior still exists if you substitute a rather than a!, and I guess it's weird if it's not idempotent, but it's a bit of an edge case since that is not syntactically valid rust anyway. But you can write fully-compilable code that exhibits this behavior when formatted with rustfmt, if you're using certain macros like assert_matches!.
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 by reproducing the minimal macro example with rustfmt and compare its output across repeated runs. Trace the formatting path for .. inside macro input, then add a regression test showing that formatting is idempotent and does not duplicate or merge the dots.
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
- Mostly clear
- Newbie friendliness
- 35/100