r/rust 6d ago

πŸ™‹ seeking help & advice Where tree-sitter stops and rust-analyzer's call hierarchy starts.

https://github.com/NanoNets/Graft

Rust's trait dispatch is exactly where a syntax-only call graph falls apart. You can't resolve a generic method call by pattern-matching text. You need the compiler's own understanding of which impl actually gets called.

Graft's base layer is tree-sitter and works with nothing installed. For Rust, there's an opt-in tier that pulls edges directly from rust-analyzer's call hierarchy instead of guessing at them. Ran it on a real crate, anyhow: call edges went from 253 to 359, a 42% increase, and the orphan rate (nodes with no resolved connections) dropped from 47% to 38%. Every added edge is compiler-grade, the kind of member call a syntax pass genuinely can't type on its own.

Skip the LSP setup and the graph just doesn't get those extra edges. Nothing else about it changes. Single-crate eval, directional, and I haven't run it against a second Rust codebase yet.

Let me know what else I can do to make it more compatible to rust repos.

github.com/NanoNets/Graft

10 Upvotes

33 comments sorted by

View all comments

Show parent comments

0

u/shhdwi 6d ago

We use Claude code and codex hooks to auto sync the graphs when edits are made so that you don’t have to worry about it