Skip to content

fix(rust): link self accesses inside macro arguments for LCOM (#177) - #202

Merged
DaisukeYoda merged 2 commits into
mainfrom
fix/rust-macro-member-access
Oct 10, 2026
Merged

DaisukeYoda merged 2 commits into
mainfrom
fix/rust-macro-member-access

Conversation

@DaisukeYoda

Copy link
Copy Markdown
Member

tree-sitter-rust parses macro arguments as a flat token tree, so self.x and self.m() inside format!, write!, assert! or ready! produced no member. Methods lost their LCOM edges, and a method whose only field accesses were inside a macro was excluded as a stub.

The Rust Members query now also matches the token sequences self . x, self . m (…) and Self :: f (…). The patterns are bare sibling sequences, because a sequence anchored under a token_tree parent matches only once per tree.

The repro in the issue now reports lcom4: 1.

Fixes #177

A query anchor skips punctuation, so self.a, (1) in a macro matched as a
call to a. Members matches may now capture @arguments, which must be the
call name's next sibling. Turbofish calls in macros count as calls.
@DaisukeYoda
DaisukeYoda merged commit 0a418cf into main Oct 10, 2026
4 checks passed
@DaisukeYoda
DaisukeYoda deleted the fix/rust-macro-member-access branch October 10, 2026 14:32
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.

[BUG][auto] rust/rust-macro-args-self-access-not-linked: field reads and self calls inside macro arguments are invisible to LCOM

1 participant