@@ -242,7 +242,7 @@ fn compute_deps(
242
242
}
243
243
244
244
let id = unit. pkg . package_id ( ) ;
245
- let filtered_deps = non_custom_build_and_non_transitive_deps ( unit, state , unit_for) ;
245
+ let filtered_deps = state . deps ( unit, unit_for) ;
246
246
247
247
let mut ret = Vec :: new ( ) ;
248
248
let mut dev_deps = Vec :: new ( ) ;
@@ -349,37 +349,6 @@ fn compute_deps(
349
349
Ok ( ret)
350
350
}
351
351
352
- /// Returns non-custom and non-transitive dependencies.
353
- fn non_custom_build_and_non_transitive_deps < ' a > (
354
- unit : & Unit ,
355
- state : & ' a State < ' _ , ' _ > ,
356
- unit_for : UnitFor ,
357
- ) -> Vec < ( PackageId , & ' a HashSet < Dependency > ) > {
358
- state. deps ( unit, unit_for, & |dep| {
359
- // If this target is a build command, then we only want build
360
- // dependencies, otherwise we want everything *other than* build
361
- // dependencies.
362
- if unit. target . is_custom_build ( ) != dep. is_build ( ) {
363
- return false ;
364
- }
365
-
366
- // If this dependency is **not** a transitive dependency, then it
367
- // only applies to test/example targets.
368
- if !dep. is_transitive ( )
369
- && !unit. target . is_test ( )
370
- && !unit. target . is_example ( )
371
- && !unit. mode . is_doc_scrape ( )
372
- && !unit. mode . is_any_test ( )
373
- {
374
- return false ;
375
- }
376
-
377
- // If we've gotten past all that, then this dependency is
378
- // actually used!
379
- true
380
- } )
381
- }
382
-
383
352
/// Returns the dependencies needed to run a build script.
384
353
///
385
354
/// The `unit` provided must represent an execution of a build script, and
@@ -431,7 +400,7 @@ fn compute_deps_doc(
431
400
state : & mut State < ' _ , ' _ > ,
432
401
unit_for : UnitFor ,
433
402
) -> CargoResult < Vec < UnitDep > > {
434
- let deps = non_custom_build_and_non_transitive_deps ( unit, state , unit_for) ;
403
+ let deps = state . deps ( unit, unit_for) ;
435
404
436
405
// To document a library, we depend on dependencies actually being
437
406
// built. If we're documenting *all* libraries, then we also depend on
@@ -839,22 +808,32 @@ impl<'a, 'cfg> State<'a, 'cfg> {
839
808
}
840
809
841
810
/// Returns a filtered set of dependencies for the given unit.
842
- fn deps (
843
- & self ,
844
- unit : & Unit ,
845
- unit_for : UnitFor ,
846
- filter : & dyn Fn ( & Dependency ) -> bool ,
847
- ) -> Vec < ( PackageId , & HashSet < Dependency > ) > {
811
+ fn deps ( & self , unit : & Unit , unit_for : UnitFor ) -> Vec < ( PackageId , & HashSet < Dependency > ) > {
848
812
let pkg_id = unit. pkg . package_id ( ) ;
849
813
let kind = unit. kind ;
850
814
self . resolve ( )
851
815
. deps ( pkg_id)
852
816
. filter ( |& ( _id, deps) | {
853
817
assert ! ( !deps. is_empty( ) ) ;
854
818
deps. iter ( ) . any ( |dep| {
855
- if !filter ( dep) {
819
+ // If this target is a build command, then we only want build
820
+ // dependencies, otherwise we want everything *other than* build
821
+ // dependencies.
822
+ if unit. target . is_custom_build ( ) != dep. is_build ( ) {
823
+ return false ;
824
+ }
825
+
826
+ // If this dependency is **not** a transitive dependency, then it
827
+ // only applies to test/example targets.
828
+ if !dep. is_transitive ( )
829
+ && !unit. target . is_test ( )
830
+ && !unit. target . is_example ( )
831
+ && !unit. mode . is_doc_scrape ( )
832
+ && !unit. mode . is_any_test ( )
833
+ {
856
834
return false ;
857
835
}
836
+
858
837
// If this dependency is only available for certain platforms,
859
838
// make sure we're only enabling it for that platform.
860
839
if !self . target_data . dep_platform_activated ( dep, kind) {
@@ -870,6 +849,8 @@ impl<'a, 'cfg> State<'a, 'cfg> {
870
849
}
871
850
}
872
851
852
+ // If we've gotten past all that, then this dependency is
853
+ // actually used!
873
854
true
874
855
} )
875
856
} )
0 commit comments