Repository navigation
fix: bare module::func() call resolution for src-less Rust crates nested in a picked folder - #25
Merged
Merged
Conversation
…ted in a picked folder A src-less Rust tree is treated as one crate named "crate", with every module one level below the crate root - but when such a tree sits nested under a picked folder (a monorepo containing several flat-layout crates, say), the whole nesting prefix ends up inside every module name instead, and the bare-module-path resolver's one-level-below-crate-root guess (module::func() with no use needed) silently misses. The use-imported branch just above it already falls back to a crate-wide search when its own guess misses; the bare-path branch gets the same fallback now, tightened to require base itself be a real, unique submodule of the crate (not just any function of that name anywhere in it) - a bare std type call like Vec::new() must not get wired to an unrelated same-named top-level function elsewhere in the crate. Added sample_rust_nested_project/ as a minimal src-less two-file regression fixture, nested one level under app/ so picking the fixture's own root folder reproduces the bug directly. Closes #22
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #22.
A
src/-less Rust tree is treated as one crate named "crate", with every module one level below the crate root - but when such a tree sits nested under a picked folder (a monorepo containing several flat-layout crates, say), the whole nesting prefix ends up inside every module name instead, and the bare-module-path resolver's one-level-below-crate-root guess (module::func()with nouseneeded) silently misses.The fix
The
use-imported branch already falls back to a crate-wide search (_find_fn_in_crate) when its own guess misses. The bare-path branch now gets an equivalent fallback (_find_submodule_in_crate), deliberately tighter: it requiresbaseitself to be a real, unique submodule of the crate - not just any function of that name anywhere in it. A bare std-type call likeVec::new()must not get wired to an unrelated same-named top-level function elsewhere in the crate; matching on the module's own leaf name, rather than searching by the called function's name, avoids that.A whole sibling crate nested deeper than expected (as opposed to a submodule of the current crate) stays explicitly out of scope, same as the issue's own "Cargo-workspace-aware crate detection beyond what already exists" exclusion - that branch now bails out honestly instead of attempting a fallback search that could never match.
Fixture
Added
sample_rust_nested_project/: a minimal src-less two-file project (app/a.rscallingapp/b.rs's function via a bare module path, nouse), nested one level underapp/so picking the fixture's own root folder reproduces the bug directly through the normal CLI - no need to merge multiple projects by hand to trigger it.Verification
sample_project,sample_rust_project,sample_typescript_projectinto one request under folder prefixes): all 6 ofsample_rust_project's edges present, including the two previously-droppedmain::main -> processing::clean/-> processing::aggregatecalls.sample_rust_nested_projecton its own: 0 edges before the fix, 1 edge after - confirms the fixture actually exercises the bug and the fix closes it.python -m backend.analyzerbefore/after on the three canonical fixtures, byte-identical (not just counts):sample_project16/17,sample_rust_project(unnested) 8/6,sample_typescript_project21/18 - satisfies all three acceptance criteria./code-review, each catching something real before landing here: a false-positive risk in the first fallback (fixed by requiring a unique submodule match), then a copy-paste variable bug in the module-alias branch's own fallback and dead logic in the sibling-crate case (both fixed), then a clean pass.