Trailing comma removed from multiline attribute
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
I originally had an overly long attribute like this:
#![allow(clippy::needless_pass_by_value, clippy::new_ret_no_self, clippy::new_without_default_derive)]
This got formatted to:
#![allow(
clippy::needless_pass_by_value,
clippy::new_ret_no_self,
clippy::new_without_default_derive
)]
I manually added a comma after the third line, because I expect this list to change in the future.
Expected behavior:
rustfmt keeps the trailing comma.
Actual behavior:
rustfmt removes the trailing comma.
Note that, ideally (IMO), rustfmt would have automatically inserted a trailing comma, or had a setting to specify that behavior. However I don't know if there are situation where the lack of (or presence) of a trailing comma is of semantic significance in (custom) attributes.
If a trailing comma can be significant it should be neither added nor removed automatically, I think. (Unless rustfmt recognizes the specific attribute).
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
Reproduce the issue in rustfmt using the multiline Rust attribute shown in the report, and compare the formatted output with the manually added trailing comma. Determine whether trailing commas in custom attributes can be changed safely, then verify that the final behavior matches the expected or documented policy.
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
- 38/100