Handle function-like attribute macros with generic types in them
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
When using an attribute macro with a function-like syntax:
#[my_macro(Item1, Item2, Item3)]
fn my_fun() {}
rust fmt can give up if the arguments to the macro are types with generic parameters. If the macro line is too long and should be rewritten in several lines, rust fmt doesn't handle the situation at all:
#[my_macro(Item1<u32>, Item2<u32>, Item3<u32>, Item4<u32>, Item5<u32>, Item6<u32>)]
fn my_fun() {}
Workaround: using an alias for those types to not have to write generic parameters in the macro arguments.
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 issue with the #[my_macro(...)] examples, including generic type arguments and a line long enough to require rewriting. Trace rustfmt's handling of function-like attribute macro arguments and verify that the long macro invocation is formatted across multiple lines without changing its contents.
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
- 45/100