@@ -170,24 +170,7 @@ impl Context {
170
170
let deps = s. dependencies ( ) ;
171
171
let deps = deps. iter ( ) . filter ( |d| d. is_transitive ( ) || dev_deps) ;
172
172
173
- // Requested features stored in the Method are stored as string references, but we want to
174
- // transform them into FeatureValues here. In order to pass the borrow checker with
175
- // storage of the FeatureValues that outlives the Requirements object, we do the
176
- // transformation here, and pass the FeatureValues to build_requirements().
177
- let values = if let Method :: Required {
178
- all_features : false ,
179
- features : requested,
180
- ..
181
- } = * method
182
- {
183
- requested
184
- . iter ( )
185
- . map ( |& f| FeatureValue :: new ( f, s) )
186
- . collect :: < Vec < FeatureValue > > ( )
187
- } else {
188
- vec ! [ ]
189
- } ;
190
- let reqs = build_requirements ( s, method, & values) ?;
173
+ let reqs = build_requirements ( s, method) ?;
191
174
let mut ret = Vec :: new ( ) ;
192
175
let mut used_features = HashSet :: new ( ) ;
193
176
let default_dep = ( false , Vec :: new ( ) ) ;
@@ -303,13 +286,10 @@ impl Context {
303
286
/// dependency features in a Requirements object, returning it to the resolver.
304
287
fn build_requirements < ' a , ' b : ' a > (
305
288
s : & ' a Summary ,
306
- method : & ' b Method ,
307
- requested : & ' a [ FeatureValue ] ,
289
+ method : & ' b Method
308
290
) -> CargoResult < Requirements < ' a > > {
309
291
let mut reqs = Requirements :: new ( s) ;
310
- for fv in requested. iter ( ) {
311
- reqs. require_value ( fv) ?;
312
- }
292
+
313
293
match * method {
314
294
Method :: Everything
315
295
| Method :: Required {
@@ -322,7 +302,15 @@ fn build_requirements<'a, 'b: 'a>(
322
302
reqs. require_dependency ( dep. name ( ) . as_str ( ) ) ;
323
303
}
324
304
}
325
- _ => { } // Explicitly requested features are handled through `requested`
305
+ Method :: Required {
306
+ all_features : false ,
307
+ features : requested,
308
+ ..
309
+ } => {
310
+ for & f in requested. iter ( ) {
311
+ reqs. require_value ( & FeatureValue :: new ( f, s) ) ?;
312
+ }
313
+ }
326
314
}
327
315
match * method {
328
316
Method :: Everything
@@ -413,12 +401,12 @@ impl<'r> Requirements<'r> {
413
401
Ok ( ( ) )
414
402
}
415
403
416
- fn require_value ( & mut self , fv : & ' r FeatureValue ) -> CargoResult < ( ) > {
417
- match * fv {
418
- FeatureValue :: Feature ( ref feat) => self . require_feature ( feat) ,
419
- FeatureValue :: Crate ( ref dep) => Ok ( self . require_dependency ( dep) ) ,
420
- FeatureValue :: CrateFeature ( ref dep, dep_feat) => {
421
- Ok ( self . require_crate_feature ( dep, dep_feat) )
404
+ fn require_value < ' f > ( & mut self , fv : & ' f FeatureValue ) -> CargoResult < ( ) > {
405
+ match fv {
406
+ FeatureValue :: Feature ( feat) => self . require_feature ( feat. as_str ( ) ) ,
407
+ FeatureValue :: Crate ( dep) => Ok ( self . require_dependency ( dep. as_str ( ) ) ) ,
408
+ FeatureValue :: CrateFeature ( dep, dep_feat) => {
409
+ Ok ( self . require_crate_feature ( dep. as_str ( ) , * dep_feat) )
422
410
}
423
411
}
424
412
}
0 commit comments