@@ -264,16 +264,14 @@ fn compute_deps(
264
264
265
265
let id = unit. pkg . package_id ( ) ;
266
266
267
- let dep_filter = & non_custom_and_non_transitive_deps;
268
- let filtered_deps = state. deps ( unit, unit_for, dep_filter) ;
267
+ let filtered_deps = state. deps ( unit, unit_for) ;
269
268
270
269
let mut ret = Vec :: new ( ) ;
271
270
let mut dev_deps = Vec :: new ( ) ;
272
271
for ( dep_pkg_id, deps) in filtered_deps {
273
272
let dep_pkg = state. get ( dep_pkg_id) ;
274
- let ( could_have_non_artifact_lib, has_artifact_lib) = calc_artifact_deps (
275
- unit, unit_for, dep_pkg_id, deps, state, dep_filter, & mut ret,
276
- ) ?;
273
+ let ( could_have_non_artifact_lib, has_artifact_lib) =
274
+ calc_artifact_deps ( unit, unit_for, dep_pkg_id, deps, state, & mut ret) ?;
277
275
278
276
let lib = package_lib ( dep_pkg, could_have_non_artifact_lib, has_artifact_lib) ;
279
277
let dep_lib = match lib {
@@ -421,7 +419,6 @@ fn calc_artifact_deps(
421
419
dep_id : PackageId ,
422
420
deps : & HashSet < Dependency > ,
423
421
state : & State < ' _ , ' _ > ,
424
- filter : & dyn Fn ( & Unit , & Dependency ) -> bool ,
425
422
ret : & mut Vec < UnitDep > ,
426
423
) -> CargoResult < ( bool , bool ) > {
427
424
let mut has_artifact_lib = false ;
@@ -431,7 +428,7 @@ fn calc_artifact_deps(
431
428
for ( dep, artifact) in deps
432
429
. iter ( )
433
430
. filter ( |dep| {
434
- if filter ( unit, dep) {
431
+ if non_custom_and_non_transitive_deps ( unit, dep) {
435
432
deps_past_filter += 1 ;
436
433
true
437
434
} else {
@@ -522,7 +519,7 @@ fn compute_deps_custom_build(
522
519
//
523
520
// This is essentially the same as `calc_artifact_deps`, but there are some
524
521
// subtle differences that require this to be implemented differently.
525
- let artifact_build_deps = state. deps ( unit, script_unit_for, & |_unit, dep| {
522
+ let artifact_build_deps = state. deps_filtered ( unit, script_unit_for, & |_unit, dep| {
526
523
dep. kind ( ) == DepKind :: Build && dep. artifact ( ) . is_some ( )
527
524
} ) ;
528
525
@@ -666,16 +663,15 @@ fn compute_deps_doc(
666
663
state : & mut State < ' _ , ' _ > ,
667
664
unit_for : UnitFor ,
668
665
) -> CargoResult < Vec < UnitDep > > {
669
- let dep_filter = & non_custom_and_non_transitive_deps;
670
- let deps = state. deps ( unit, unit_for, dep_filter) ;
666
+ let deps = state. deps ( unit, unit_for) ;
671
667
672
668
// To document a library, we depend on dependencies actually being
673
669
// built. If we're documenting *all* libraries, then we also depend on
674
670
// the documentation of the library being built.
675
671
let mut ret = Vec :: new ( ) ;
676
672
for ( id, deps) in deps {
677
673
let ( could_have_non_artifact_lib, has_artifact_lib) =
678
- calc_artifact_deps ( unit, unit_for, id, deps, state, dep_filter , & mut ret) ?;
674
+ calc_artifact_deps ( unit, unit_for, id, deps, state, & mut ret) ?;
679
675
680
676
let dep_pkg = state. get ( id) ;
681
677
let lib = package_lib ( dep_pkg, could_have_non_artifact_lib, has_artifact_lib) ;
@@ -1102,8 +1098,13 @@ impl<'a, 'cfg> State<'a, 'cfg> {
1102
1098
. unwrap_or_else ( |_| panic ! ( "expected {} to be downloaded" , id) )
1103
1099
}
1104
1100
1101
+ /// Returns a set of dependencies for the given unit, with a default filter.
1102
+ fn deps ( & self , unit : & Unit , unit_for : UnitFor ) -> Vec < ( PackageId , & HashSet < Dependency > ) > {
1103
+ self . deps_filtered ( unit, unit_for, & non_custom_and_non_transitive_deps)
1104
+ }
1105
+
1105
1106
/// Returns a filtered set of dependencies for the given unit.
1106
- fn deps (
1107
+ fn deps_filtered (
1107
1108
& self ,
1108
1109
unit : & Unit ,
1109
1110
unit_for : UnitFor ,
0 commit comments