1- use std:: collections:: { HashMap , HashSet } ;
1+ use std:: collections:: HashMap ;
22use std:: num:: NonZeroU64 ;
33use std:: rc:: Rc ;
44
@@ -20,6 +20,7 @@ use super::types::{ConflictMap, DepInfo, Method};
2020pub use super :: encode:: { EncodableDependency , EncodablePackageId , EncodableResolve } ;
2121pub use super :: encode:: { Metadata , WorkspaceResolve } ;
2222pub use super :: resolve:: Resolve ;
23+ use std:: collections:: btree_set:: BTreeSet ;
2324
2425// A `Context` is basically a bunch of local resolution information which is
2526// kept around for all `BacktrackFrame` instances. As a result, this runs the
@@ -29,7 +30,7 @@ pub use super::resolve::Resolve;
2930pub struct Context {
3031 pub activations : Activations ,
3132 /// list the features that are activated for each package
32- pub resolve_features : im_rc:: HashMap < PackageId , Rc < HashSet < InternedString > > > ,
33+ pub resolve_features : im_rc:: HashMap < PackageId , Rc < BTreeSet < InternedString > > > ,
3334 /// get the package that will be linking to a native library by its links attribute
3435 pub links : im_rc:: HashMap < InternedString , PackageId > ,
3536 /// for each package the list of names it can see,
@@ -102,7 +103,7 @@ impl Context {
102103 /// Activate this summary by inserting it into our list of known activations.
103104 ///
104105 /// Returns `true` if this summary with the given method is already activated.
105- pub fn flag_activated ( & mut self , summary : & Summary , method : & Method < ' _ > ) -> CargoResult < bool > {
106+ pub fn flag_activated ( & mut self , summary : & Summary , method : & Method ) -> CargoResult < bool > {
106107 let id = summary. package_id ( ) ;
107108 let age: ContextAge = self . age ( ) ;
108109 match self . activations . entry ( id. as_activations_key ( ) ) {
@@ -127,7 +128,7 @@ impl Context {
127128 }
128129 }
129130 debug ! ( "checking if {} is already activated" , summary. package_id( ) ) ;
130- let ( features, use_default) = match * method {
131+ let ( features, use_default) = match method {
131132 Method :: Everything
132133 | Method :: Required {
133134 all_features : true , ..
@@ -142,7 +143,7 @@ impl Context {
142143 let has_default_feature = summary. features ( ) . contains_key ( "default" ) ;
143144 Ok ( match self . resolve_features . get ( & id) {
144145 Some ( prev) => {
145- features. iter ( ) . all ( |f| prev. contains ( f ) )
146+ features. is_subset ( prev)
146147 && ( !use_default || prev. contains ( "default" ) || !has_default_feature)
147148 }
148149 None => features. is_empty ( ) && ( !use_default || !has_default_feature) ,
@@ -154,7 +155,7 @@ impl Context {
154155 registry : & mut dep_cache:: RegistryQueryer < ' _ > ,
155156 parent : Option < PackageId > ,
156157 candidate : & Summary ,
157- method : & Method < ' _ > ,
158+ method : & Method ,
158159 ) -> ActivateResult < Vec < DepInfo > > {
159160 // First, figure out our set of dependencies based on the requested set
160161 // of features. This also calculates what features we're going to enable
@@ -166,7 +167,7 @@ impl Context {
166167 Rc :: make_mut (
167168 self . resolve_features
168169 . entry ( candidate. package_id ( ) )
169- . or_insert_with ( || Rc :: new ( HashSet :: with_capacity ( used_features . len ( ) ) ) ) ,
170+ . or_insert_with ( Rc :: default ) ,
170171 )
171172 . extend ( used_features) ;
172173 }
0 commit comments