fix(ingestion): dedupe Rust mod items per #[path] value - #2943
Pushpak731 wants to merge 2 commits into
Conversation
… loop A defer immediately followed by a return, or by a break that exits the for loop (not a switch/select case, and not only an inner loop of a nest), is reached at most once per entry, so the deferred call cannot pile up per iteration. Unlabeled break resolution walks to the innermost breakable statement; a labeled break counts only when the label names a for statement with no further loop above it up to the function scope. Everything else - a call between the defer and the exit, continue, switch/select-case breaks, labels naming inner statements, nested-loop breaks - keeps firing, and the existing fixture count is unchanged. Closes repowise-dev#2938
A mod_item's raw text excludes its outer attributes, so two #[cfg]-gated 'mod imp;' declarations targeting different #[path] files collide in the raw-statement dedup and the second file loses its import edge - and is then reported as unreachable with its exports unused (the ripgrep index/mod.rs shape). Qualify the dedup key with the #[path] value for mod items; true duplicates (same raw text, same or no path) still dedupe. Closes repowise-dev#2935
|
🔍 1 thing to check
✅ Health of changed files: 2.3 → 3.9 (+1.6) 👀 Suggested reviewers @RaghavChamadiya 📊 See the full report for this PR Settings and updatesUpdated 2026-10-02 13:39 UTC |
Repowise checks
Tests: which tests reach the changed files (inferred)
Inferred from the code graph of the last indexed commit ( Doc drift
Configure checks: bot settings |
|
Thanks @Pushpak731, qualifying the dedup key with the One thing before I can merge: this branch carries a second commit, the Go |
Summary
mod_itemis now qualified with its#[path]attribute value:mod imp;has the same raw text under two#[cfg]gates, but with different#[path]targets it is a feature-flag twin, not a duplicate. The file named by the second declaration previously lost its import edge and was then reported as unreachable with its exports unused (the ripgrepcrates/core/index/mod.rsshape from the issue).usestatements and all other languages are untouched. Implementation follows the issue's suggestion of a Rust-specific key, like the existing Pascal/Elixir/F# pre-dedup precedent.Related Issues
Closes #2935
Test Plan
pytest)ruff check .)New
tests/unit/ingestion/test_rust_mod_path_dedup.py(30 tests): parser-level dedup semantics (the ripgrep and platform-twin shapes, same-path and no-path dedup guards, attribute order, doc comments, visibility modifiers, three-way gates, subdirectory paths, nearest-of-two path attributes, mixeduse/mod) and end-to-end graph/dead-code assertions (both twin files get importer edges, neither is flagged unreachable/unused-export, no double edges for real duplicates, plainmoddefault-layout resolution unchanged). Fulltests/unit/ingestion/: 4125 passed, 5 skipped, 2 xfailed;ruff checkclean.Checklist