@@ -57,6 +57,9 @@ type ActivateMap = HashMap<PackageFeaturesKey, BTreeSet<InternedString>>;
57
57
/// Set of all activated features for all packages in the resolve graph.
58
58
pub struct ResolvedFeatures {
59
59
/// Map of features activated for each package.
60
+ ///
61
+ /// The presence of each key also means the package itself is activated,
62
+ /// even its associated set contains no features.
60
63
activated_features : ActivateMap ,
61
64
/// Options that change how the feature resolver operates.
62
65
opts : FeatureOpts ,
@@ -406,8 +409,14 @@ pub struct FeatureResolver<'a, 'cfg> {
406
409
/// Options that change how the feature resolver operates.
407
410
opts : FeatureOpts ,
408
411
/// Map of features activated for each package.
412
+ ///
413
+ /// The presence of each key also means the package itself is activated,
414
+ /// even its associated set contains no features.
409
415
activated_features : ActivateMap ,
410
416
/// Map of optional dependencies activated for each package.
417
+ ///
418
+ /// The key is the package having their dependencies activated.
419
+ /// The value comes from `dep_name` part of the feature syntax `dep:dep_name`.
411
420
activated_dependencies : ActivateMap ,
412
421
/// Keeps track of which packages have had its dependencies processed.
413
422
/// Used to avoid cycles, and to speed up processing.
@@ -497,20 +506,24 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> {
497
506
Ok ( ( ) )
498
507
}
499
508
500
- /// Activates [`FeatureValue`]s on the given package.
509
+ /// Activates a list of [`FeatureValue`] for a given package.
501
510
///
502
- /// This is the main entrance into the recursion of feature activation
503
- /// for a package .
511
+ /// This is the main entrance into the recursion of feature activation for a package.
512
+ /// Other `activate_*` functions would be called inside this function accordingly .
504
513
fn activate_pkg (
505
514
& mut self ,
506
515
pkg_id : PackageId ,
507
516
fk : FeaturesFor ,
508
517
fvs : & [ FeatureValue ] ,
509
518
) -> CargoResult < ( ) > {
510
519
log:: trace!( "activate_pkg {} {}" , pkg_id. name( ) , fk) ;
511
- // Add an empty entry to ensure everything is covered. This is intended for
512
- // finding bugs where the resolver missed something it should have visited.
513
- // Remove this in the future if `activated_features` uses an empty default.
520
+ // Cargo must insert an empty set here as the presence of an (empty) set
521
+ // also means that the dependency is activated.
522
+ // This `is_activated` behavior for dependencies was previously depends on field
523
+ // `activated_dependencies`, which is less useful after rust-lang/cargo#11183.
524
+ //
525
+ // That is, we may keep or remove `activated_dependencies` in the future
526
+ // if figuring out it can completely be replaced with `activated_features`.
514
527
self . activated_features
515
528
. entry ( ( pkg_id, fk. apply_opts ( & self . opts ) ) )
516
529
. or_insert_with ( BTreeSet :: new) ;
0 commit comments