pub struct FeatureResolver<'a, 'cfg> {
    ws: &'a Workspace<'cfg>,
    target_data: &'a mut RustcTargetData<'cfg>,
    requested_targets: &'a [CompileKind],
    resolve: &'a Resolve,
    package_set: &'a PackageSet<'cfg>,
    opts: FeatureOpts,
    activated_features: HashMap<(PackageId, FeaturesFor), BTreeSet<InternedString>>,
    activated_dependencies: HashMap<(PackageId, FeaturesFor), BTreeSet<InternedString>>,
    processed_deps: HashSet<(PackageId, FeaturesFor)>,
    track_for_host: bool,
    deferred_weak_dependencies: HashMap<(PackageId, FeaturesFor, InternedString), HashSet<InternedString>>,
}
Expand description

The new feature resolver that resolves your project.

For more information, please see the module-level documentation.

Fields§

§ws: &'a Workspace<'cfg>§target_data: &'a mut RustcTargetData<'cfg>§requested_targets: &'a [CompileKind]

The platforms to build for, requested by the user.

§resolve: &'a Resolve§package_set: &'a PackageSet<'cfg>§opts: FeatureOpts

Options that change how the feature resolver operates.

§activated_features: HashMap<(PackageId, FeaturesFor), BTreeSet<InternedString>>

Map of features activated for each package.

§activated_dependencies: HashMap<(PackageId, FeaturesFor), BTreeSet<InternedString>>

Map of optional dependencies activated for each package.

§processed_deps: HashSet<(PackageId, FeaturesFor)>

Keeps track of which packages have had its dependencies processed. Used to avoid cycles, and to speed up processing.

§track_for_host: bool

If this is true, then a non-default feature_key needs to be tracked while traversing the graph.

This is only here to avoid calling is_proc_macro when all feature options are disabled (because is_proc_macro can trigger downloads). This has to be separate from FeatureOpts.decouple_host_deps because for_host tracking is also needed for itarget to work properly.

§deferred_weak_dependencies: HashMap<(PackageId, FeaturesFor, InternedString), HashSet<InternedString>>

dep_name?/feat_name features that will be activated if dep_name is ever activated.

The key is the (package, for_host, dep_name) of the package whose dependency will trigger the addition of new features. The value is the set of features to activate.

Implementations§

source§

impl<'a, 'cfg> FeatureResolver<'a, 'cfg>

source

pub fn resolve( ws: &Workspace<'cfg>, target_data: &'a mut RustcTargetData<'cfg>, resolve: &Resolve, package_set: &'a PackageSet<'cfg>, cli_features: &CliFeatures, specs: &[PackageIdSpec], requested_targets: &[CompileKind], opts: FeatureOpts ) -> CargoResult<ResolvedFeatures>

Runs the resolution algorithm and returns a new ResolvedFeatures with the result.

source

fn do_resolve( &mut self, specs: &[PackageIdSpec], cli_features: &CliFeatures ) -> CargoResult<()>

Performs the process of resolving all features for the resolve graph.

source

fn activate_pkg( &mut self, pkg_id: PackageId, fk: FeaturesFor, fvs: &[FeatureValue] ) -> CargoResult<()>

Activates FeatureValues on the given package.

This is the main entrance into the recursion of feature activation for a package.

source

fn activate_fv( &mut self, pkg_id: PackageId, fk: FeaturesFor, fv: &FeatureValue ) -> CargoResult<()>

Activate a single FeatureValue for a package.

source

fn activate_rec( &mut self, pkg_id: PackageId, fk: FeaturesFor, feature_to_enable: InternedString ) -> CargoResult<()>

Activate the given feature for the given package, and then recursively activate any other features that feature enables.

source

fn activate_dependency( &mut self, pkg_id: PackageId, fk: FeaturesFor, dep_name: InternedString ) -> CargoResult<()>

Activate a dependency (dep:dep_name syntax).

source

fn activate_dep_feature( &mut self, pkg_id: PackageId, fk: FeaturesFor, dep_name: InternedString, dep_feature: InternedString, weak: bool ) -> CargoResult<()>

Activate a feature within a dependency (dep_name/feat_name syntax).

source

fn fvs_from_dependency( &self, dep_id: PackageId, dep: &Dependency ) -> Vec<FeatureValue>

Returns Vec of FeatureValues from a Dependency definition.

source

fn fvs_from_requested( &self, pkg_id: PackageId, cli_features: &CliFeatures ) -> Vec<FeatureValue>

Returns Vec of FeatureValues from a set of command-line features.

source

fn deps( &mut self, pkg_id: PackageId, fk: FeaturesFor ) -> CargoResult<Vec<(PackageId, Vec<(&'a Dependency, FeaturesFor)>)>>

Returns the dependencies for a package, filtering out inactive targets.

source

fn compare(&self)

Compare the activated features to the resolver. Used for testing.

source

fn is_proc_macro(&self, package_id: PackageId) -> bool

Auto Trait Implementations§

§

impl<'a, 'cfg> !RefUnwindSafe for FeatureResolver<'a, 'cfg>

§

impl<'a, 'cfg> !Send for FeatureResolver<'a, 'cfg>

§

impl<'a, 'cfg> !Sync for FeatureResolver<'a, 'cfg>

§

impl<'a, 'cfg> Unpin for FeatureResolver<'a, 'cfg>

§

impl<'a, 'cfg> !UnwindSafe for FeatureResolver<'a, 'cfg>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 248 bytes