fix: bind each cfg/impl twin module's functions through their own use (#1017) - #1163
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughRust inline-module imports now fan out into enclosing function scopes for both pure and non-pure chains. Regression tests verify that duplicate impl-local and cfg-gated modules keep separate helper imports. ChangesRust inline-module import resolution
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Greptile SummaryThis change keeps Rust call resolution scoped to each inline module body when multiple bodies share the same qualified name. A before-and-after check reproduced the former cfg-gated module cross-binding, then confirmed that cfg-gated twins and method-local modules each resolve their helper call through their own Confidence Score: 5/5The change is safe to merge based on isolated end-to-end call-resolution checks and the passing focused Rust linking suite. The tested duplicate-module scenarios now preserve lexical import isolation, and no remaining correctness defects were found. Files Needing Attention: No files need further attention;
What T-Rex did
Reviews (1): Last reviewed commit: "fix: bind each cfg/impl twin module's fu..." | Re-trigger Greptile |
|



Closes the remaining observable mis-binding in #1017.
Context
Most of #1017 is already handled on
mainvia span-gating + cross-file arbitration (not module-qn dedup, which would breaksuper::/self::/crate::path resolution). The common colliding shapes have passing tests. This closes the one shape that still mis-bound and had no test.The bug
When two bodied modules share one qn — two mutually-exclusive cfg twins, or two impls of one type each with a method-local
mod inner— both are indexed and their mod-scopeusemaps merge onto the sharedimport_mapping[qn](last writer wins). A function in the earlier twin then binds through the later twin's imports:gawrongly resolved tobeta::helperinstead ofalpha::helper.Fix
_parse_rust_use_declarationalready fans an inline-mod use out to its own functions' spans as weak fn-scope entries — but only for non-pure chains (fn-local mods). Pure twins skipped it, so they merged on the shared key. Dropping theif not pure_chain:guard makes every inline-mod use also register span-gated per its own functions, so each function binds through its enclosing mod body regardless of what the merged key holds.enclosing_mod_fn_spansreturns spans only for a use sitting directly in an inlinemod {}body, so file-level andmod foo;uses are untouched — the change is confined to inline bodied mods, exactly where twins occur.Tests (both RED-verified)
test_two_bodied_cfg_twin_mods_keep_separate_uses— the cfg-twin case above; each twin's fn binds its own helper. Reverting the fix flipsgatobeta.test_two_impls_method_local_mod_inner_keep_separate_uses— two impls ofS, each a method-localmod innerimporting a different helper.test_rust_crate_path_trait_linking.py: 139 passed, 2 skipped, no regressions. Block-item suites: 11 passed. Lint + type-check clean.Summary by CodeRabbit