Separate function parameter from its attributes by a newline
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Context
Hi, I'm the author of the crate bon. It exposes a proc macro that generates a builder for a function. Every function parameter can be configured with additional #[builder(...)] options.
Problem
For example, this function declares 4 parameters, two of which are optional (they have default values). As for me, the way rustfmt formatted this code doesn't look nice:
#[bon::builder]
fn example(
#[builder(default = 1)] foo: u32,
bar: u32,
#[builder(default = 3)] baz: u32,
fizz: u32,
) {
}
The attribute on the function's parameter was formatted on the same line with the parameter itself, even though the signature of the function already takes up multiple lines. It is harder to read the signature this way because names of function parameters aren't aligned
I'd expect the following formatting for this example of code instead:
#[bon::builder]
fn example(
#[builder(default = 1)]
foo: u32,
bar: u32,
#[builder(default = 3)]
baz: u32,
fizz: u32,
) {
}
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 using the Rust function examples in the report, then trace rustfmt's parameter and attribute formatting entry points. Done means multiline signatures place each parameter attribute on its own line before the parameter, matching the expected output.
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
- Clearly specified
- Newbie friendliness
- 45/100