Configuration for trailing commas does not affect macros defined with lists
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Formatting for vec! macros will always follow a trailing_comma = "Vertical" style. Lists small enough to fit into one line will ignore a setting of "Always", while lists large enough to be displayed vertically will ignore "Never".
With no other configuration changes this code block will always be formatted to the following regardless of the setting for trailing commas:
let short = vec![1.0, 2.0, 3.0];
let long = vec![
1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0,
17.0, 18.0, 19.0, 20.0,
];
This likely applies to any other macro defined by a list as well, but vec! was what I found the issue with and I'm not sure off the top of my head if there are other macros defined by rust that engage with lists in this way.
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 reported vec! formatting with trailing_comma set to "Always", "Never", and "Vertical" in rustfmt. Check whether other list-like macros show the same behavior, and consider the issue done when short and vertically formatted lists consistently follow each setting.
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
- 30/100