rust-lang / rust-lang/rust-analyzer

Typing inside proc-macro only changing trivia tokens re-expands proc-macro

Open
#17,213 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-perf A-proc-macro C-Architecture C-enhancement E-hard
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

#[foo]
fn f() {
    // comment
}

Changing the comment content here currently invalidates relative spans in the macro input, invalidating the macro argument subtree as the contained spans change, and as such we re-expand the proc-macro even though logically the macro can't really observe this change unless it actually uses the proc-macro API to introspect spans. We should fix this by having the proc-macro server record whether an expansion did introspection or not and somehow instruct salsa that it shouldnt need to re-expand these queries in those cases.

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

The issue names no files, tests, or entry points. Start by tracing proc-macro server expansion, span introspection, and the related salsa queries. Determine how expansions record whether spans were inspected, then verify that changing only trivia avoids re-expansion when no introspection occurred.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.