Format macro calls (not definitions)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Hello,
I haven't been able to find this in the issue tracker. If it is there, sorry for missing it!
On IRC, someone wanted to auto-format a big match-like macro, like:
match_any_type!(var, {
Foo::A => a,
Foo::B => {
bar();
b
}
// etc.
})
The use case appears to make sense to me, but I don't think any rust formatting tool is currently able to handle this, as it is completely macro-dependent.
However, @thepowersgang proposed a solution:
Mutabah | [snip] Re getting auto-formatting of macro input - I don't know if there's formatting tools that can do that... a
| powerful one could possibly look at the macro signature and guess at formatting for fragements
IOW, rustfmt could (theoretically) check the macro signature and figure out what parts are of what type, to then try to indent them correctly.
I don't know if this is actually doable within reasonable complexity, but thought this idea was great and deserved to be tracked :)
Anyway, thank you for your work on rustfmt!
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 files, tests, or entry points are named. Start by assessing whether rustfmt can inspect macro signatures and infer fragment types for macro calls; done would require a defined, feasible approach to formatting macro input rather than only macro definitions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100