Bad formatting for nested tuple field accesses on `style_edition` < 2024 when the accesses are formatted on different lines.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
The following is output of rustfmt:
fn f() {
x.f()
.0
.0
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa();
}
Note that the second .0 is offset by a single space. I know that this is because of compatibility with old rustc versions that lexed .0.0 as a float (i.e. https://github.com/rust-lang/rustfmt/issues/4355#issuecomment-723764276).
However, in this case, the additional space is not needed -- they are on different lines (and in fact have multiple spaces just because of the indentation).
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 running rustfmt on the nested tuple-field example in the issue with style_edition below 2024, then trace the formatting path for chained field accesses. Done means the second .0 is not given the extra one-space offset when accesses are placed on different lines, while existing float-lexing compatibility remains intact.
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
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100