Skip to content

Rust: Prefer richer feature configurations when extracting dependencies - #22847

Draft
paldepind wants to merge 6 commits into
mainfrom
rust/inconsistent-feature
Draft

paldepind wants to merge 6 commits into
mainfrom
rust/inconsistent-feature

Conversation

@paldepind

@paldepind paldepind commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem: When a project under extraction contains multiple Cargo.toml files, the Cargo.toml files might specify overlapping dependencies but enable different features for the dependencies.

The extractor previously extracted each dependency file using whichever Cargo.toml it encountered first in a hash-map. This made extraction non-deterministic.

Fix: This PR defers dependency extraction until all Cargo.toml files have been examined, then selects a configuration per file, preferring the one with more enabled features and using deterministic tie-breaking based on paths. Once that is done, the "winning" manifests are reloaded to extract the dependency files for which they "won".

Note to reviewer:

  • The first three commits are simple refactors.
  • The key change is in the main function, specifically how we now have two for loops over manifests and in the first pass defer extracting dependency files and instead call dependencies.add_file.
  • The added tests might be a bit annoying to figure out. The doc comment for test_dependency_features.py attempt to give an overview.

@github-actions github-actions Bot added the Rust Pull requests that update Rust code label Oct 20, 2026
Defer dependency extraction until all workspaces have been considered,
prefer configurations enabling more Cargo features, and use
deterministic tie-breaking.
Add tests for extraction of dependency files with different features
enabled in different manifest files.
Regenerate existing integration-test expectations to account for
manifest reloads in the deferred dependency extraction pass.
@paldepind
paldepind force-pushed the rust/inconsistent-feature branch from 3b50eaf to a3e8174 Compare October 20, 2026 11:25

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

Rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant