Skip to content

Rust: Skip dependency files outside any module tree - #23343

Open
redsun82 wants to merge 2 commits into
mainfrom
redsun82-potential-spoon
Open

redsun82 wants to merge 2 commits into
mainfrom
redsun82-potential-spoon

Conversation

@redsun82

@redsun82 redsun82 commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 377ca31c7e31f907fc49ab67d637b8118252ac8c

Dimension Assessment Rationale
Change confidence 8.5/10 ↑ Rust QL tests pass locally apart from a type-inference row order that depends on the CLI version (main and this branch order it the same way).
↑ 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 .rs file 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_def finds 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/HardcodedCryptographicValue has the same edges and alerts; three .into() steps now resolve to the blanket <_ as Into>::into model instead of going through an orphan std file, so MaD IDs renumber.

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
@redsun82
redsun82 requested an adaptive review from Copilot December 3, 2026 09:22
@github-actions github-actions Bot added documentation Rust Pull requests that update Rust code labels Dec 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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)

@redsun82
redsun82 marked this pull request as ready for review December 3, 2026 11:53
@redsun82
redsun82 requested review from a team as code owners December 3, 2026 11:53

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants