Skip to content

rust: index the items written inside item-level macro bodies - #6

Merged
tabladrum merged 1 commit into
mainfrom
feat/rust-macro-items
Oct 12, 2026
Merged

tabladrum merged 1 commit into
mainfrom
feat/rust-macro-items

Conversation

@tabladrum

Copy link
Copy Markdown
Contributor

tree-sitter leaves a macro body as an unparsed token tree, so every item tokio writes inside cfg_rt! { ... }, pin_project! { ... } and similar wrappers had no symbol (AsyncReadExt, TcpStream::set_zero_linger, FramedWrite).

A brace body at item level is now re-parsed as Rust over its own byte range (positions stay those of the file) and visited like any item list; nested wrappers recurse on a strictly smaller range. Not read: bodies inside function bodies, macro_rules templates, and call-like m!(a, b) arguments. A name a macro generates (rgtest!(r16, ..) -> fn r16) is left to grove's rust-analyzer pass.

  • tokio: 12,021 -> 13,277 symbols; extraction 1.06s -> 1.12s; index 2.8s -> 3.3s.
  • Tests: TestRustItemMacroBodiesAreIndexed, TestRustItemMacroBodyWithHelperMacro; full suite green; grove's full suite green against this branch; engine gate (all invariants incl. decoy) held.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KXa6Cv1ZUXcdMqXcJfQFhX

tree-sitter leaves a macro invocation's body as an unparsed token tree, so
every item tokio writes inside cfg_rt! { ... }, pin_project! { ... } and
similar wrappers had no symbol (AsyncReadExt, TcpStream::set_zero_linger,
FramedWrite). A brace body at item level is now re-parsed as Rust over its
own byte range, so positions stay those of the file, and visited like any
item list; nested wrappers recurse on a strictly smaller range. Bodies
inside function bodies and macro_rules templates are not read, and neither
are call-like m!(a, b) arguments: a name a macro generates (rgtest!(r16, ..)
-> fn r16) is left to the compiler pass.

tokio: 12021 -> 13277 symbols; extraction 1.06s -> 1.12s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KXa6Cv1ZUXcdMqXcJfQFhX
@tabladrum
tabladrum merged commit a56291a into main Oct 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant