rust-lang / rust-lang/rust-analyzer
Eagerly expand all macros?
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Today, we use lazy model of macro expansion, and expand macros only when we "need to". In practice, this means that top-level macros are expanded when we look into the crate, and macros in bodies are expanded when we look into the body during lowering.
An alternative solution is to eagerly expand all the macros, and have an expand_crate query, which is run after crate def-map. There are at least two reasons why such eager expansion might be beneficial.
- It allows for correct (in some sense) find usages: https://github.com/rust-analyzer/rust-analyzer/issues/7427
- It works better for cases where expanded code includes some other codes (mods or inlcudes inside macros, procedural macros that use spans from external files)
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 the lazy macro-expansion flow described in the issue, including crate def-map lookup and body lowering. Evaluate the proposed expand_crate query against find-usages and macros containing modules or includes; done requires an agreed architectural direction, since no files or tests are named.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100