Repository navigation
Conversation
Dependency files that rust-analyzer does not map to a module (tests, examples, cfg-disabled modules) are no longer extracted. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: bb7e46bf6f724fbdb6c49ed3dd2d72fd
There was a problem hiding this comment.
🔵 Needs a closer look
Dependency AST filtering affects analysis-wide declaration and model resolution, macro-included file reachability, and workspace configuration fallback, exceeding the limited-impact scope for automated approval.
No open issues 🎉
What changed in this PR
This PR reduces Rust extraction work and database size by skipping dependency files outside every module tree, while preserving retries under alternative configurations.
Changes:
- Filter unmapped dependency files in both extraction paths.
- Extend integration coverage with an orphan dependency file.
- Update generated expectations and document the improvement.
| File | Description |
|---|---|
rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected |
Updates model references while preserving edges and alerts. |
rust/ql/test/library-tests/type-inference/type-inference.expected |
Reorders two tied result rows. |
rust/ql/lib/change-notes/2026-12-02-skip-orphan-dependency-files.md |
Documents reduced dependency extraction. |
rust/ql/integration-tests/dependency-features/test_dependency_features.py |
Documents the orphan-file test scenario. |
rust/ql/integration-tests/dependency-features/inactive-module.ql |
Checks for incorrectly extracted orphan functions. |
rust/ql/integration-tests/dependency-features/dependencies/alpha/src/orphan.rs |
Adds an unmapped dependency fixture. |
rust/extractor/src/main.rs |
Skips unmapped dependency files while retaining configuration retries. |
Review effort: Balanced (adaptive)
The row swap came from the local CLI version, not from this change. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: bb7e46bf6f724fbdb6c49ed3dd2d72fd
There was a problem hiding this comment.
🔵 Needs a closer look
Dependency AST pruning changes call resolution and model matching across configurations and macro/include reachability, creating interacting semantic effects beyond straightforward review scope.
No open issues 🎉
Review effort: Balanced (adaptive)
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
377ca31c7e31f907fc49ab67d637b8118252ac8c↑ CI reproduced the CWE-798 expected change.
↑ Extractor unit tests pass.
↑ New dependency-features check fails on main (orphan.rs extracted in all 4 variants) and passes here.
↑ Earlier spike: identical alerts on 3 real projects.
↓ Integration tests not run end to end locally (no rust-src, pack resolution issues); CI pending.
↓ Library files reachable only via
include!/#[path]from unmapped files could lose AST (not observed).The extractor extracted every
.rsfile in a dependency's source root, including files rust-analyzer does not map to any module (tests, examples, benches, cfg-disabled modules). These add extraction time and DB size but contribute nothing reachable from analysed code.Now dependency files are only extracted when
file_to_module_deffinds a module, on both the single-workspace fast path and the multi-workspace loop. In the loop, a file with no module still gets retried under alternative configurations before being dropped.In earlier measurements, this cut extracted files by 40-58% and wall time by about 26-34% on sample projects, with identical alerts.
Expected-file change:
CWE-798/HardcodedCryptographicValuehas the same edges and alerts; three.into()steps now resolve to the blanket<_ as Into>::intomodel instead of going through an orphan std file, so MaD IDs renumber.