Rust resolver: module-alias qualified calls (use a::b as lp; lp::foo()) stay unresolved although imports records alias = "lp" #367

Closed
opened 2026-10-13 22:39:57 +02:00 by buildagent · 1 comment
Member

Observed (0.37.1 / 8df22f69, dogfood on code-index)

In commit 8df22f69 (PR #365), four exported functions were added to crates/core/src/lang_profile.rs and called from crates/mcp-server/src/server.rs through a module import alias (use code_index_core::lang_profile as lp; at crates/mcp-server/src/server.rs:3182):

  • nearest_spellings (id: 564804, crates/core/src/lang_profile.rs:1088):
    • changed_symbols(base="HEAD~1") reports ref_count: 2, direct_callers: 2, name_fallback_count: 2.
    • find_references(symbol_id: 564804) shows the only 2 resolved refs are unit tests inside crates/core/src/lang_profile.rs (lines 1647, 1651).
    • Both production call sites in crates/mcp-server/src/server.rs (line 9014 lp::nearest_spellings(...) and line 19945 lp::nearest_spellings(...)) remain unresolved (resolution: "name_fallback", target_id: null, qualifier: "lp").
  • The same happens for the other lp::* calls in crates/mcp-server/src/server.rs:
    • is_local_shaped (564800): ref_count: 4, name_fallback_count: 1
    • filter_admits (564802): ref_count: 13, name_fallback_count: 2
    • ambiguous_filter (564803): ref_count: 5, name_fallback_count: 1

The index already holds the alias fact

get_dependencies(target="crates/mcp-server/src/server.rs", direction="out") returns:

{
  "file": "crates/mcp-server/src/server.rs",
  "module": "code_index_core::lang_profile",
  "alias": "lp",
  "line": 3182
}

So imports already records that in crates/mcp-server/src/server.rs, qualifier lp aliases code_index_core::lang_profile (one of the 1,451 refs counted by project_overview.count_basis.alias_qualified_refs).

Impact

  • context_pack(symbol_ids: [564804]) lists only the unit test nearest_spellings_rank_related_local_ids_first in dependents and omits crates/mcp-server/src/server.rs from dependents (disclosed via evidence_gaps.unfollowed_name_fallback: count: 2).
  • change_impact and review_diff cannot traverse across lp::* edges into crates/mcp-server/src/server.rs.

To check

  • Whether Tier 1Q (crates/indexer/src/index.rs) can expand a single-segment qualifier q through the calling file's imports row where imports.alias = q (rewriting lp → code_index_core::lang_profile / suffix lang_profile) before matching candidate module paths, without introducing phantoms on the corpus suites.
## Observed (0.37.1 / 8df22f69, dogfood on `code-index`) In commit `8df22f69` (PR #365), four exported functions were added to `crates/core/src/lang_profile.rs` and called from `crates/mcp-server/src/server.rs` through a module import alias (`use code_index_core::lang_profile as lp;` at `crates/mcp-server/src/server.rs:3182`): - `nearest_spellings` (`id: 564804`, `crates/core/src/lang_profile.rs:1088`): - `changed_symbols(base="HEAD~1")` reports `ref_count: 2`, `direct_callers: 2`, `name_fallback_count: 2`. - `find_references(symbol_id: 564804)` shows the only 2 `resolved` refs are unit tests inside `crates/core/src/lang_profile.rs` (lines 1647, 1651). - Both production call sites in `crates/mcp-server/src/server.rs` (line 9014 `lp::nearest_spellings(...)` and line 19945 `lp::nearest_spellings(...)`) remain unresolved (`resolution: "name_fallback"`, `target_id: null`, `qualifier: "lp"`). - The same happens for the other `lp::*` calls in `crates/mcp-server/src/server.rs`: - `is_local_shaped` (`564800`): `ref_count: 4, name_fallback_count: 1` - `filter_admits` (`564802`): `ref_count: 13, name_fallback_count: 2` - `ambiguous_filter` (`564803`): `ref_count: 5, name_fallback_count: 1` ## The index already holds the alias fact `get_dependencies(target="crates/mcp-server/src/server.rs", direction="out")` returns: ```json { "file": "crates/mcp-server/src/server.rs", "module": "code_index_core::lang_profile", "alias": "lp", "line": 3182 } ``` So `imports` already records that in `crates/mcp-server/src/server.rs`, qualifier `lp` aliases `code_index_core::lang_profile` (one of the `1,451` refs counted by `project_overview.count_basis.alias_qualified_refs`). ## Impact - `context_pack(symbol_ids: [564804])` lists only the unit test `nearest_spellings_rank_related_local_ids_first` in `dependents` and omits `crates/mcp-server/src/server.rs` from dependents (disclosed via `evidence_gaps.unfollowed_name_fallback: count: 2`). - `change_impact` and `review_diff` cannot traverse across `lp::*` edges into `crates/mcp-server/src/server.rs`. ## To check - Whether Tier 1Q (`crates/indexer/src/index.rs`) can expand a single-segment qualifier `q` through the calling file's `imports` row where `imports.alias = q` (rewriting `lp` → `code_index_core::lang_profile` / suffix `lang_profile`) before matching candidate module paths, without introducing phantoms on the corpus suites.
Author
Member

Fixed in v0.37.2 (PR #373, master ccb77e68, release run 1144 green).

  • Fix: an aliased module is now expanded when its head is a workspace crate (rust_use_head_is_workspace, the same check use paths already use). The same-file and duplicate-alias gates are unchanged.
  • Upgrade: schema 82 (m0082) re-resolves an existing index once on upgrade, without re-parsing.
  • Measured:
    • rust-analyzer +50 tier1q_alias binds, all hand-checked correct.
    • This repo +68, with a 40/40 sample correct.
    • The other pinned repos are identical.
    • precision_gate 7/7, phantom 0, with a new alias probe.
  • Dogfood: with the release binary, find_callers(nearest_spellings) returns 4/4 resolved, including both lp:: calls in server.rs.

Not covered here, measured and left for later: prefix-qualified aliases (lp::Type::f), and external-package aliases in other languages. Closing.

Fixed in **v0.37.2** (PR #373, master ccb77e68, release run 1144 green). - **Fix:** an aliased module is now expanded when its head is a workspace crate (`rust_use_head_is_workspace`, the same check `use` paths already use). The same-file and duplicate-alias gates are unchanged. - **Upgrade:** schema 82 (m0082) re-resolves an existing index once on upgrade, without re-parsing. - **Measured:** - rust-analyzer +50 `tier1q_alias` binds, all hand-checked correct. - This repo +68, with a 40/40 sample correct. - The other pinned repos are identical. - `precision_gate` 7/7, phantom 0, with a new alias probe. - **Dogfood:** with the release binary, `find_callers(nearest_spellings)` returns 4/4 resolved, including both `lp::` calls in `server.rs`. Not covered here, measured and left for later: prefix-qualified aliases (`lp::Type::f`), and external-package aliases in other languages. Closing.
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#367
No description provided.