Skip to content

fix: claim nothing for an unrepresentable Rust #[path] target - #1112

Merged
vitali87 merged 2 commits into
fix/rust-super-self-prefix-resolutionfrom
fix/rust-unrepresentable-path-target
Aug 8, 2026
Merged

vitali87 merged 2 commits into
fix/rust-super-self-prefix-resolutionfrom
fix/rust-unrepresentable-path-target

Conversation

@vitali87

@vitali87 vitali87 commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Closes #1082.

Stacked on #1111 (issue #1086) → #1110 (issue #1093), which touch adjacent lines in the same resolver. Merge in that order and each retargets cleanly.

Change

The issue's framing was the design: both sites classify the same thing, so both must be able to say "no qn names this module" rather than return a spelling.

_rust_walk_mods conflated the two cases in one condition:

if redirect is None or target is None:      # attach by name

They are not the same. No redirect means attach by name; a redirect whose target the qn scheme cannot key means nothing here is the module's referent. Split, and return None for the second. _rust_attach had the identical fall-through and gets the identical treatment.

None then propagates through _rust_join_mods → _rust_resolve_relative / _rust_rewrite_crate_path → _rewrite_rust_local_use_path, and each consumer does the right thing with it:

Tests

codebase_rag/tests/test_rust_unrepresentable_path_target.py covers all three unrepresentable forms path_attribute_qn_parts rejects — absolute path, Windows separator, climb above the repo root — each asserting no edge to the undeclared src/helpers.rs shadow, plus two controls:

  • a representable in-tree redirect still keys under the file it names
  • a declaration with no #[path] at all still binds the named module — the case the buggy branch conflated it with

Three fail without the fix; both controls pass either way.

Rust + import-parsing + class-ingest suites: 952 passed. ty clean.

@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: 28619763-57ab-4227-934f-7ab1b923dfee

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

Rust #[path] resolution now keeps unrepresentable redirect targets from creating relationships through matching symbol names.

Confidence Score: 5/5

No blocking failure remains.

No accepted blocking findings remain.

T-Rex T-Rex Logs

What T-Rex did

  • Reviewed trait-resolution and test-module candidate guards in codebase_rag/parsers/class_ingest/mixin.py.
  • Attempted the focused Rust parser tests and a two-path updater harness covering same-named trait handling and inline cfg(test) redirect handling, but setup halted before parser execution due to a cmake-build blocker in pymgclient==1.5.1.
  • Documented the current line ranges for trait resolution and IMPLEMENTS gating in mixin.py (277-286 and 1287-1320) and the inline cfg(test) guard (1761-1769).
  • Observed the cmake-related failure across runs, with the error Cannot found suitable cmake reported by pymgclient==1.5.1 builds.

T-Rex Ran code and verified through T-Rex

Reviews (2): Last reviewed commit: "fix: drop the trait binding when a Rust ..." | Re-trigger Greptile

@vitali87

vitali87 commented Aug 7, 2026

Copy link
Copy Markdown
Owner Author

Both findings addressed in b03a062, but they landed differently — one I could prove, one I could not.

Trait fallback binds unrelated names — confirmed and fixed.

You were right, and it is the same shadow-binding this PR exists to stop, just in the trait lane. _resolve_rust_trait_qn now returns no trait qn at all for an unrepresentable path, instead of falling back to the name-anchored candidate:

Regression test added: two same-named Base traits, one behind an unrepresentable redirect, asserting no IMPLEMENTS edge is recorded. Verified RED without the fix.

Inline chains retain shadow candidates — guard applied, but unproven.

_rust_cfg_test_candidates now returns an empty set when relative is None, rather than falling through to the name-derived spellings. I believe that is correct by construction.

However, I could not build a fixture that actually reaches it, and I want to be straight about that rather than imply otherwise. In the shapes I tried, the chain branch only runs for a declaration nested in an inline mod, and there _rust_module_decls finds no file backing the inline scope, so _rust_walk_mods extends by name and relative comes back non-None — the guard never fires. I wrote a test for it, saw it pass with and without the change, and deleted it rather than ship a test that proves nothing.

So: the guard is in as defence-in-depth. If you have a corpus shape that reaches it, I would like to see it and will turn it into a real test.

Rust + class-ingest + trait/override suites: 1097 passed. ty clean.

@vitali87

vitali87 commented Aug 8, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@greptile-apps review

All review threads on this PR have been answered inline: findings implemented, or explicitly rebutted with the reasoning. Please re-assess against the current head and confirm whether this is ready to merge.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Rate Limit Exceeded

@vitali87 have exceeded the limit for the number of chat messages per hour. Please wait 35 minutes and 5 seconds before sending another message.

@vitali87
vitali87 force-pushed the fix/rust-unrepresentable-path-target branch from b03a062 to 6c1aebd Compare August 8, 2026 21:55
Base automatically changed from fix/rust-inline-mod-super-path to fix/rust-super-self-prefix-resolution August 8, 2026 21:55
@vitali87
vitali87 force-pushed the fix/rust-unrepresentable-path-target branch from 6c1aebd to 3ec045a Compare August 8, 2026 21:55
@vitali87
vitali87 merged commit cb3c93a into fix/rust-super-self-prefix-resolution Aug 8, 2026
1 check passed
@vitali87
vitali87 deleted the fix/rust-unrepresentable-path-target branch August 8, 2026 21:56
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