Skip to content

[Feature]: Rust: x.method() and self.field.method() get no calls edge across files, and in-file they bind by bare name #4296

Open

Description

@rohit-jsfreaky

Problem or use case

Rust method calls on anything other than self are never resolved across files: the shared pass skips every member call, and _resolve_rust_self_member_calls handles only self.m() ("a non-self receiver needs local type inference this pass does not attempt, left for a future extension"). Inside one file, x.m() binds to whichever method named m the file defines, with no regard for x's type.

// src/search.rs
use crate::matcher::Matcher;

pub struct Searcher { matcher: Matcher }

impl Searcher {
    pub fn search(&self) -> usize { self.matcher.find() }   // no edge
}

pub fn by_param(m: &Matcher) -> usize { m.find() }          // no edge

pub fn by_let() -> usize {
    let m = Matcher::new();
    m.find()                                                // no edge
}

Measured against rust-analyzer (go-to-definition at every call inside every fn), 0.9.84:

repo x.m() calls found self.field.m() calls found all calls found calls edges that are wrong
ripgrep 225 / 1029 (21.9%) 54 / 255 (21.2%) 48.2% 532 of 2808 (18.9%)
bat 29 / 84 (34.5%) 1 / 11 71.5% 36 of 722
fd 10 / 177 (5.6%) 1 / 2 35.8% 9 of 166

Most of the remaining wrong edges in ripgrep (502 of 532) are in-file bare-name matches of x.m() / self.field.m() / expr.m().

Proposed solution

The type of a receiver is usually written in the source: a typed parameter (m: &Matcher), a let with a type or with Type::new() / Type { .. }, a struct field (matcher: Arc<Matcher>), or the declared return type of the function or method that produced it (-> Self, -> io::Result<Matcher> followed by ?). Record those facts in the extractor and resolve x.m() to that type's method in a corpus pass next to the self. one, the same way the Python, TS, C# and C++ resolvers use declared types. A receiver whose type is not known gets no edge rather than a bare-name guess.

Alternatives considered

  • Running rust-analyzer: heavy, needs a toolchain and a cargo build graph, not deterministic across environments.
  • Keeping the in-file bare-name match as a fallback: on ripgrep, after typing, the matches it still makes are right 45 times and wrong 125 times.

Area

Extraction or language support

Are you willing to submit a PR?

Yes, I can work on this

Compatibility / behavior impact

Rust only. No node or edge ids change. .rs nodes gain three attributes (_rust_ret, _rust_ret_ok, _rust_fields) and Rust raw calls a rust_receiver field, so the AST cache schema goes 7 -> 8 to retire entries written without them, and the three markers are forwarded on changed-files rebuilds next to _rust_impl_key (changed-files rebuild == full build on ripgrep and fd). Rust calls edges change: new INFERRED edges for typed receivers, and an untyped x.m() no longer gets an EXTRACTED in-file bare-name edge. No generated skills or MCP output format change.

Additional context

Follow-up to #4237 / #4238 (in-file Rust call binding, shipped in 0.9.82). PR right after this issue.

Activity

  1. added
    enhancement
    on Oct 10, 2026
  2. github-actions commented on Oct 10, 2026

    @github-actions

    Thanks for opening this issue, @rohit-jsfreaky. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions