rust-lang / rust-lang/rust-analyzer

Implement the remaining unimplemented proc-macro APIs in the proc-macro server

Open
#15,950 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-proc-macro C-tracking-issue E-unknown
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

Note: This will have to wait until after my token map rewrite.

We have no issue tracking this yet so I figured making a barebones one should be good for any discussions involved as it is already known that this is gonna be a difficult thing to do.

To describe the problem in simple terms, a lot of the API exposes state of the world to proc-macros, an example being asking for the source of a span. In rustc, this is fine as the proc-macro server runs inside the main rustc process, but in rust-analyzer, the server is a separate process that rust-analyzer communicates to via a a json RPC interface. This worked out fine so far as we only need to ask the server to expand a proc-macro with a given token stream and giving back the expanded one. To serve these unimplemented APIs otoh, we need to allow the server to communicate back to the client (rust-analyzer) to ask for certain information / properties about the program (and potentially in the future even ask about expanding macros which requires name resolution 😭). In theory, this should be straight forward but we might run into problems wrt the client-server architecture of the proc-macro bridge. That's the main open question to solve once this is being worked on.

We also need to be able to inspect our used spans after https://github.com/rust-lang/rust-analyzer/pull/15959, so that our syntax fixup stuff can continue working. That is we need to special case the span setting functions such that fixup IDs are not copied over resulting in removed code.

Blocked on https://github.com/rust-lang/rust-analyzer/issues/19205

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the proc-macro server architecture and the blocking issue #19205, then review the client-server concerns described here. Also inspect PR #15959 to understand the span inspection and syntax-fixup requirements. Done means the remaining proc-macro APIs work across the bridge and span fixup behavior continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
18/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.