Skip to content

Commit

Permalink
doc(features2): clarify some docs
Browse files Browse the repository at this point in the history
  • Loading branch information
weihanglo committed Oct 7, 2022
1 parent 421ae05 commit f78dbd9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/cargo/core/compiler/unit_dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,7 @@ impl<'a, 'cfg> State<'a, 'cfg> {
}
}

/// See [`ResolvedFeatures::activated_features`].
fn activated_features(
&self,
pkg_id: PackageId,
Expand All @@ -1040,6 +1041,7 @@ impl<'a, 'cfg> State<'a, 'cfg> {
features.activated_features(pkg_id, features_for)
}

/// See [`ResolvedFeatures::is_activated`].
fn is_activated(&self, pkg_id: PackageId, features_for: FeaturesFor) -> bool {
self.features().is_activated(pkg_id, features_for)
}
Expand Down
12 changes: 5 additions & 7 deletions src/cargo/core/resolver/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,9 @@ type ActivateMap = HashMap<PackageFeaturesKey, BTreeSet<InternedString>>;

/// Set of all activated features for all packages in the resolve graph.
pub struct ResolvedFeatures {
/// Map of features activated for each package.
activated_features: ActivateMap,
/// Optional dependencies that should be built.
///
/// The value is the `name_in_toml` of the dependencies.
activated_dependencies: ActivateMap,
/// Options that change how the feature resolver operates.
opts: FeatureOpts,
}

Expand Down Expand Up @@ -315,10 +313,10 @@ impl ResolvedFeatures {
.expect("activated_features for invalid package")
}

/// Returns if the given dependency should be included.
/// Asks the resolved features if the given package should be included.
///
/// This handles dependencies disabled via `cfg` expressions and optional
/// dependencies which are not enabled.
/// One scenario to use this function is to deteremine a optional dependency
/// should be built or not.
pub fn is_activated(&self, pkg_id: PackageId, features_for: FeaturesFor) -> bool {
log::trace!("is_activated {} {features_for}", pkg_id.name());
self.activated_features_unverified(pkg_id, features_for.apply_opts(&self.opts))
Expand Down

0 comments on commit f78dbd9

Please sign in to comment.