@@ -297,17 +297,13 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> {
297
297
return Ok ( ( ) ) ;
298
298
}
299
299
for ( dep_pkg_id, deps) in self . deps ( pkg_id, for_build) {
300
- for dep in deps {
300
+ for ( dep, dep_for_build ) in deps {
301
301
if dep. is_optional ( ) {
302
302
continue ;
303
303
}
304
304
// Recurse into the dependency.
305
305
let fvs = self . fvs_from_dependency ( dep_pkg_id, dep) ;
306
- self . activate_pkg (
307
- dep_pkg_id,
308
- & fvs,
309
- for_build || ( self . opts . decouple_build_deps && dep. is_build ( ) ) ,
310
- ) ?;
306
+ self . activate_pkg ( dep_pkg_id, & fvs, dep_for_build) ?;
311
307
}
312
308
}
313
309
Ok ( ( ) )
@@ -329,22 +325,18 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> {
329
325
self . activate_rec ( pkg_id, * dep_name, for_build) ?;
330
326
// Activate the optional dep.
331
327
for ( dep_pkg_id, deps) in self . deps ( pkg_id, for_build) {
332
- for dep in deps {
328
+ for ( dep, dep_for_build ) in deps {
333
329
if dep. name_in_toml ( ) == * dep_name {
334
330
let fvs = self . fvs_from_dependency ( dep_pkg_id, dep) ;
335
- self . activate_pkg (
336
- dep_pkg_id,
337
- & fvs,
338
- for_build || ( self . opts . decouple_build_deps && dep. is_build ( ) ) ,
339
- ) ?;
331
+ self . activate_pkg ( dep_pkg_id, & fvs, dep_for_build) ?;
340
332
}
341
333
}
342
334
}
343
335
}
344
336
FeatureValue :: CrateFeature ( dep_name, dep_feature) => {
345
337
// Activate a feature within a dependency.
346
338
for ( dep_pkg_id, deps) in self . deps ( pkg_id, for_build) {
347
- for dep in deps {
339
+ for ( dep, dep_for_build ) in deps {
348
340
if dep. name_in_toml ( ) == * dep_name {
349
341
if dep. is_optional ( ) {
350
342
// Activate the crate on self.
@@ -354,11 +346,7 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> {
354
346
// Activate the feature on the dependency.
355
347
let summary = self . resolve . summary ( dep_pkg_id) ;
356
348
let fv = FeatureValue :: new ( * dep_feature, summary) ;
357
- self . activate_fv (
358
- dep_pkg_id,
359
- & fv,
360
- for_build || ( self . opts . decouple_build_deps && dep. is_build ( ) ) ,
361
- ) ?;
349
+ self . activate_fv ( dep_pkg_id, & fv, dep_for_build) ?;
362
350
}
363
351
}
364
352
}
@@ -438,7 +426,7 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> {
438
426
// Top-level requested features can never apply to
439
427
// build-dependencies, so for_build is `false` here.
440
428
for ( _dep_pkg_id, deps) in self . deps ( pkg_id, false ) {
441
- for dep in deps {
429
+ for ( dep, _dep_for_build ) in deps {
442
430
if dep. is_optional ( ) {
443
431
// This may result in duplicates, but that should be ok.
444
432
fvs. push ( FeatureValue :: Crate ( dep. name_in_toml ( ) ) ) ;
@@ -462,7 +450,11 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> {
462
450
}
463
451
464
452
/// Returns the dependencies for a package, filtering out inactive targets.
465
- fn deps ( & self , pkg_id : PackageId , for_build : bool ) -> Vec < ( PackageId , Vec < & ' a Dependency > ) > {
453
+ fn deps (
454
+ & self ,
455
+ pkg_id : PackageId ,
456
+ for_build : bool ,
457
+ ) -> Vec < ( PackageId , Vec < ( & ' a Dependency , bool ) > ) > {
466
458
// Helper for determining if a platform is activated.
467
459
let platform_activated = |dep : & Dependency | -> bool {
468
460
// We always care about build-dependencies, and they are always
@@ -494,6 +486,11 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> {
494
486
}
495
487
true
496
488
} )
489
+ . map ( |dep| {
490
+ let dep_for_build =
491
+ for_build || ( self . opts . decouple_build_deps && dep. is_build ( ) ) ;
492
+ ( dep, dep_for_build)
493
+ } )
497
494
. collect :: < Vec < _ > > ( ) ;
498
495
( dep_id, deps)
499
496
} )
0 commit comments