Skip to content

fix: count Rust super:: and self:: from the enclosing inline mod - #1111

Merged
vitali87 merged 1 commit into
fix/rust-super-self-prefix-resolutionfrom
fix/rust-inline-mod-super-path
Aug 8, 2026
Merged

vitali87 merged 1 commit into
fix/rust-super-self-prefix-resolutionfrom
fix/rust-inline-mod-super-path

Conversation

@vitali87

@vitali87 vitali87 commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Closes #1086.

Stacked on #1110 (issue #1093) — it edits the same bail in _resolve_rust_prefixed_path, so this targets that branch rather than main. Merge #1110 first and this retargets cleanly.

Change

_resolve_rust_prefixed_path declined every caller nested below the file module, so the call fell to the enclosing-scope walk, which matches the tail by NAME against each ancestor of the FILE's own qn — right whenever the file sits where its module sits, wrong the moment a #[path] moved it.

An inline mod block's qn is the effective module the written path counts from, which is exactly the "effective module" the use-declaration half already passes to _rewrite_rust_local_use_path (its docstring has said so all along). So instead of bailing, pass that qn down. Everything else — the #[path] climb via _rust_super_base/_rust_logical_parent — already works.

The impl-block filtering from #1093 does the rest: impl targets add no module level and are filtered out, so mod_scopes[0] is the innermost genuine mod.

Tests

codebase_rag/tests/test_rust_inline_mod_super_path.py:

  • the issue's exact corpus — super::super::sib::run() from an inline mod in a #[path] target, where src/fixtures/sib.rs is declared by nobody and only sits in a physical ancestor
  • one super:: from an inline mod reaches the FILE module, not its parent
  • self:: stays in the inline mod rather than picking the same-named file-module item
  • #[cfg(test)] mod tests { ... super::helper() }, the shape this hits most often in practice
  • nested inline mods pop exactly one level each (super:: → outer, super::super:: → the file module)

Three of the five fail without the change — including the nested case, which was resolving super::helper() from inner to engine.helper instead of outer.helper.

Rust suite: 880 passed.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: eaf6173e-7b46-41e2-a1dd-758f37ac7148

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This change fixes Rust qualified-call resolution inside inline modules so self:: and super:: follow logical module ancestry, including modules loaded through #[path].

Focused execution confirmed that redirected-module calls resolve to the declared logical target rather than a same-named function beside the physical source file. Inline self::, single super::, and nested super::super:: paths also resolved to the expected modules, and the equivalent Cargo fixture passed. No defects were found.

Confidence Score: 5/5

Safe to merge based on focused execution of the changed Rust resolution behavior and a matching compiled Rust fixture.

The exercised paths covered the central correctness concern: logical module ancestry must win over physical-file ancestry for #[path] targets, while self:: and repeated super:: hops retain their Rust semantics. All observed targets matched the expected logical modules.

Files Needing Attention: No follow-up changes are needed. The resolver implementation in codebase_rag/parsers/call_resolver.py and its focused regression coverage in codebase_rag/tests/test_rust_inline_mod_super_path.py were exercised.

T-Rex T-Rex Logs

What T-Rex did

  • Executed a focused resolver harness for a #[path]-redirected inline module, confirmed the resolver maps to super::super::sib -> inline_resolution.src.engine.sib.run, super -> inline_resolution.src.fixtures.rig.helper, self -> inline_resolution.src.fixtures.rig.inner.helper, and nested super::super -> inline_resolution.src.fixtures.rig.helper, and verified the redirected-module fixture passed with 1 passed; 0 failed.
  • Observed the same resolver outputs and re-ran the redirected-module test; the validation reported VALIDATION PASSED: changed resolver and rustc agree on logical ancestry.

T-Rex Ran code and verified through T-Rex

Reviews (1): Last reviewed commit: "fix: count Rust super:: and self:: from ..." | Re-trigger Greptile

@vitali87
vitali87 force-pushed the fix/rust-inline-mod-super-path branch from b94f6fc to 3858dd9 Compare August 8, 2026 21:55
@vitali87
vitali87 merged commit c64b253 into fix/rust-super-self-prefix-resolution Aug 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant