flag to dump proc-macro's generated tokenstream to file for debugging
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I think it would be useful for rustc to have flags to dump a proc-macro's generated tokenstream to a file when rustc generates an error or if you choose to always dump the macro's output.
the existing Zunpretty=expanded flag is not suitable because it fails if rustc can't parse the generated tokenstream, it expands all macros in the generated tokenstream instead of showing exactly what the proc-macro generated, and it usually generates a huge amount of output which makes finding the output of any particular proc macro invocation very annoying.
This came up here where the workaround I'm currently using is inspired by iirc https://github.com/drahnr/expander where the proc-macro writes an output file itself and generates include!("path/to/generated/file.rs")
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 tracing rustc's existing Zunpretty=expanded handling and the proc-macro expansion path. Compare their behavior with the stated needs: preserve the exact generated tokenstream, support dumping on errors or on demand, and avoid expanding all nested macros; completion should include a clear flag design and compiler tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100