Expand description
Resolves conditional compilation for features
section in the manifest.
This is a new feature resolver that runs independently of the main dependency resolver. It has several options which can enable new feature resolution behavior.
One of its key characteristics is that it can avoid unifying features for
shared dependencies in some situations. See FeatureOpts
for the
different behaviors that can be enabled. If no extra options are enabled,
then it should behave exactly the same as the dependency resolver’s
feature resolution.
The preferred way to engage this new resolver is via resolve_ws_with_opts
.
This does not replace feature resolution in the dependency resolver, but instead acts as a second pass which can narrow the features selected in the dependency resolver. The dependency resolver still needs to do its own feature resolution in order to avoid selecting optional dependencies that are never enabled. The dependency resolver could, in theory, just assume all optional dependencies on all packages are enabled (and remove all knowledge of features), but that could introduce new requirements that might change old behavior or cause conflicts. Maybe some day in the future we could experiment with that, but it seems unlikely to work or be all that helpful.
§Assumptions
There are many assumptions made about the dependency resolver:
- Assumes feature validation has already been done during the construction of feature maps, so the feature resolver doesn’t do that validation at all.
- Assumes
dev-dependencies
within a dependency have been removed in the givenResolve
.
There are probably other assumptions that I am forgetting.
Structs§
- CliFeatures
- Features specified on the command-line.
- Feature
Opts - Options for how the feature resolver works.
- Feature
Resolver - The new feature resolver that
resolve
s your project. - Resolved
Features - Set of all activated features for all packages in the resolve graph.
Enums§
- Features
For - Flag to indicate if features are requested for a certain type of dependency.
- Force
AllTargets - Flag to indicate that target-specific filtering should be disabled.
- HasDev
Units - Flag to indicate if Cargo is building any dev units (tests, examples, etc.).
- Requested
Features - Features flags requested for a package.
Type Aliases§
- Activate
Map 🔒 - Map of activated features.
- DiffMap
- Map of differences.
- Package
Features 🔒Key - The key used in various places to store features for a particular dependency.
The actual discrimination happens with the
FeaturesFor
type.