Pure Macros
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.5k
- Forks
- 31
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
I hope you having a wonderful day, First off let me thank you for your awesome projects; I'm a fan of your work.
I was wondering have you ever tried to cache the `TokenStream` based on the input? So maybe we can mark a procedural macro as `#[pure]` and get the results cached based on the input?
I have recently forked proc-macro2 and serde (to remove its dependency on proc-macro2) and bootstrapped a simple serializable TokenStream, But It means that I would still spend a lot of time compiling and running a noop macro that just reads the cache and returns it.
Then I came around to this article a few days ago https://www.coderemote.dev/blog/faster-rust-compiler-macro-expansion-caching/
It sounded promising to me, So that's when I started thinking about using Watt as both the runtime and cache server to prevent the redundant time spent on the macro execution by short-circuiting from the cache auto-magically.
So what I want to ask you is, Have you ever tried this? What are your thoughts? Do you think Watt can be a good place to do this kind of caching? Or do you prefer me to not submit such a PR and instead work on a standalone solution?
I also would like to know about the current situation with the `Compiler` and `Fallback` variants of the token stream and whether are they going to both be kept in or one is a temporary transition period solution. But I think that's another question for another repo.
#### Note: while this text is written with @dtolnay as the recipient the question remains open for everyone to discuss. Sorry if it felt more like an email than an issue, I just noticed the tone as I'm about to submit😅
Contributor guide
No contributing guide indexed for this repository
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
The issue identifies no repository files, tests, or entry points to inspect. Start by reviewing Watt's current runtime and token-stream handling, then compare the proposed cache-server approach with the linked article and clarify whether caching belongs in Watt; done requires an agreed scope and design rather than an implementation target.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, wasm
- Domain
- compilers, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100