Rust: a .method() call binds to an associated fn with no self (tier3 import-key edge) — 32 of PoolAdmit::prepare's 35 callers are rusqlite conn.prepare(sql) #378

Closed
opened 2026-10-15 07:58:57 +02:00 by buildagent · 1 comment
Member

Found dogfooding v0.38.0 (4ab97367) on this repo.

Observed

  • find_callers(PoolAdmit::prepare) (crates/indexer/src/capabilities.rs:748) reports total_resolved: 35.
  • 32 of the 35 are method_calls such as tx.prepare(&format!(…)) (index/constant_lookup.rs:858) and conn.prepare("SELECT …") (tests/generation_promotion.rs:1116, mcp-server/src/server.rs:8505). Every one is rusqlite's Connection::prepare.
  • resolved_by: tier3_import_boost. The files use crate::capabilities::PoolAdmit, so the import-key edge makes PoolAdmit's members candidates for any x.prepare().
  • Only the PoolAdmit::prepare(…) path calls (tier1q_pass1) are correct.
  • change_impact on PoolAdmit::prepare is inflated by these phantom edges.

Why it is wrong by construction

pub fn prepare(conn: &Connection, target: PoolGeneration) -> Result<Self, …> has no self receiver. In Rust, method syntax x.f() can only call a function whose first parameter is self, &self, &mut self or self: …. So no method_call can be a call to it, whatever the receiver is.

Not covered elsewhere

  • #189's receiver gate rightly keeps tier 3's import-key edge for Rust (recv_proof::CAPTURED). rust-ripgrep's dir.create(..) ×334 through use crate::util::Dir are correct binds and must stay.
  • What is missing is a fact about the CANDIDATE: whether it can be method-called at all.
  • This is not one of #300's six shapes.

Direction

  • One candidate-side fact: a function or method that takes a receiver.
  • One gate: a method_call whose receiver is not self or Self binds only to a receiver-taking candidate, in the languages whose dot syntax requires an instance. That is Rust for certain.
  • C#, JS/TS, Ruby and PHP allow Type.staticMethod() with the type itself as the receiver, so for them the gate is not sound without knowing the receiver. Measure before extending.
  • Builtin and package (guest) extractors must agree on the fact.
  • Measure the corpus bind by bind (join on path, line, col, kind, occurrence; split by resolved_by). Report every lost bind and read it at source.

Tool gap

No MCP tool can answer "how many binds of rule X land on a candidate of shape Y", so this class could not be sized through our own tools.

Found dogfooding v0.38.0 (4ab97367) on this repo. ## Observed - `find_callers(PoolAdmit::prepare)` (`crates/indexer/src/capabilities.rs:748`) reports `total_resolved: 35`. - 32 of the 35 are `method_call`s such as `tx.prepare(&format!(…))` (`index/constant_lookup.rs:858`) and `conn.prepare("SELECT …")` (`tests/generation_promotion.rs:1116`, `mcp-server/src/server.rs:8505`). Every one is rusqlite's `Connection::prepare`. - `resolved_by: tier3_import_boost`. The files `use crate::capabilities::PoolAdmit`, so the import-key edge makes `PoolAdmit`'s members candidates for any `x.prepare()`. - Only the `PoolAdmit::prepare(…)` path calls (`tier1q_pass1`) are correct. - `change_impact` on `PoolAdmit::prepare` is inflated by these phantom edges. ## Why it is wrong by construction `pub fn prepare(conn: &Connection, target: PoolGeneration) -> Result<Self, …>` has no `self` receiver. In Rust, method syntax `x.f()` can only call a function whose first parameter is `self`, `&self`, `&mut self` or `self: …`. So no `method_call` can be a call to it, whatever the receiver is. ## Not covered elsewhere - #189's receiver gate rightly keeps tier 3's import-key edge for Rust (`recv_proof::CAPTURED`). rust-ripgrep's `dir.create(..)` ×334 through `use crate::util::Dir` are correct binds and must stay. - What is missing is a fact about the CANDIDATE: whether it can be method-called at all. - This is not one of #300's six shapes. ## Direction - One candidate-side fact: a function or method that takes a receiver. - One gate: a `method_call` whose receiver is not `self` or `Self` binds only to a receiver-taking candidate, in the languages whose dot syntax requires an instance. That is Rust for certain. - C#, JS/TS, Ruby and PHP allow `Type.staticMethod()` with the type itself as the receiver, so for them the gate is not sound without knowing the receiver. Measure before extending. - Builtin and package (guest) extractors must agree on the fact. - Measure the corpus bind by bind (join on path, line, col, kind, occurrence; split by `resolved_by`). Report every lost bind and read it at source. ## Tool gap No MCP tool can answer "how many binds of rule X land on a candidate of shape Y", so this class could not be sized through our own tools.
Author
Member

Released in v0.39.0 (PR #386, 25a45918).

  • What changed: Rust extractors record which functions take no receiver. A method call decided onto one is refused, whichever resolver rule proposed it. This covers the builtin path, and the package path through the optional ABI tag in de.h-dv.rust 0.1.4.
  • Other tools: the same fact keeps those calls out of the name-fallback rows of find_callers/find_references, and out of same_name_unresolved in check_rename/safe_delete. Those two ship same_name_shape_excluded only where a proof applies.
  • Measured:
    • PoolAdmit::prepare: 35 resolved callers → the 3 real ones.
    • rust-analyzer: 485 wrong binds removed, 0 correct binds lost.
    • ripgrep: unchanged.
  • Other languages: C#, JavaScript, TypeScript, Ruby, PHP and Python are unchanged by design.

Follow-ups (macros recorded as calls, bare calls vs impl members) are tracked in #385.

Released in [v0.39.0](https://git.h-dv.de/h-dv/code-index/releases/tag/v0.39.0) (PR #386, 25a45918). - **What changed:** Rust extractors record which functions take no receiver. A method call decided onto one is refused, whichever resolver rule proposed it. This covers the builtin path, and the package path through the optional ABI tag in `de.h-dv.rust` 0.1.4. - **Other tools:** the same fact keeps those calls out of the name-fallback rows of `find_callers`/`find_references`, and out of `same_name_unresolved` in `check_rename`/`safe_delete`. Those two ship `same_name_shape_excluded` only where a proof applies. - **Measured:** - `PoolAdmit::prepare`: 35 resolved callers → the 3 real ones. - rust-analyzer: 485 wrong binds removed, 0 correct binds lost. - ripgrep: unchanged. - **Other languages:** C#, JavaScript, TypeScript, Ruby, PHP and Python are unchanged by design. Follow-ups (macros recorded as calls, bare calls vs impl members) are tracked in #385.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
h-dv/code-index#378
No description provided.