Comments in match partially aligned when using `hard_tabs`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
When using the hard_tabs option the last two comments are aligned, but none of the previous ones:
fn year_path(year: u16) -> Option<&'static str> {
Some(match year {
2020.. => "Current", // https://www.indianamap.org/datasets/INMap::indiana-current-imagery/about
2016.. => "2016_2019", // https://www.indianamap.org/datasets/INMap::indiana-2016-2019-imagery/about
2011.. => "2011_2013", // https://www.indianamap.org/datasets/INMap::indiana-imagery-2011-2013/about
2005.. => "2005", // https://www.indianamap.org/datasets/INMap::indiana-2005-imagery/about
_ => return None,
})
}
Adding a character in "2011_2013" causes the comment in the line below to also move one space to the right. Adding two more characters to the string however causes this "bond" to break.
Disabling the hard_tabs option causes the formatting to be more consistent again:
fn year_path(year: u16) -> Option<&'static str> {
Some(match year {
2020.. => "Current", // https://www.indianamap.org/datasets/INMap::indiana-current-imagery/about
2016.. => "2016_2019", // https://www.indianamap.org/datasets/INMap::indiana-2016-2019-imagery/about
2011.. => "2011_2013", // https://www.indianamap.org/datasets/INMap::indiana-imagery-2011-2013/about
2005.. => "2005", // https://www.indianamap.org/datasets/INMap::indiana-2005-imagery/about
_ => return None,
})
}
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
No source file or test is named. Start by reproducing the provided Rust snippet with the hard_tabs option, then trace rustfmt's comment-alignment behavior for match arms. Done means comment alignment remains consistent when string lengths change, with a regression test covering the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100