18
18
use crate :: core:: compiler:: unit_graph:: { UnitDep , UnitGraph } ;
19
19
use crate :: core:: compiler:: UnitInterner ;
20
20
use crate :: core:: compiler:: { CompileKind , CompileMode , RustcTargetData , Unit } ;
21
- use crate :: core:: dependency:: DepKind ;
22
21
use crate :: core:: profiles:: { Profile , Profiles , UnitFor } ;
23
22
use crate :: core:: resolver:: features:: { FeaturesFor , ResolvedFeatures } ;
24
23
use crate :: core:: resolver:: Resolve ;
@@ -243,29 +242,7 @@ fn compute_deps(
243
242
}
244
243
245
244
let id = unit. pkg . package_id ( ) ;
246
- let filtered_deps = state. deps ( unit, unit_for, & |dep| {
247
- // If this target is a build command, then we only want build
248
- // dependencies, otherwise we want everything *other than* build
249
- // dependencies.
250
- if unit. target . is_custom_build ( ) != dep. is_build ( ) {
251
- return false ;
252
- }
253
-
254
- // If this dependency is **not** a transitive dependency, then it
255
- // only applies to test/example targets.
256
- if !dep. is_transitive ( )
257
- && !unit. target . is_test ( )
258
- && !unit. target . is_example ( )
259
- && !unit. mode . is_doc_scrape ( )
260
- && !unit. mode . is_any_test ( )
261
- {
262
- return false ;
263
- }
264
-
265
- // If we've gotten past all that, then this dependency is
266
- // actually used!
267
- true
268
- } ) ;
245
+ let filtered_deps = state. deps ( unit, unit_for) ;
269
246
270
247
let mut ret = Vec :: new ( ) ;
271
248
let mut dev_deps = Vec :: new ( ) ;
@@ -423,7 +400,7 @@ fn compute_deps_doc(
423
400
state : & mut State < ' _ , ' _ > ,
424
401
unit_for : UnitFor ,
425
402
) -> CargoResult < Vec < UnitDep > > {
426
- let deps = state. deps ( unit, unit_for, & |dep| dep . kind ( ) == DepKind :: Normal ) ;
403
+ let deps = state. deps ( unit, unit_for) ;
427
404
428
405
// To document a library, we depend on dependencies actually being
429
406
// built. If we're documenting *all* libraries, then we also depend on
@@ -831,22 +808,32 @@ impl<'a, 'cfg> State<'a, 'cfg> {
831
808
}
832
809
833
810
/// Returns a filtered set of dependencies for the given unit.
834
- fn deps (
835
- & self ,
836
- unit : & Unit ,
837
- unit_for : UnitFor ,
838
- filter : & dyn Fn ( & Dependency ) -> bool ,
839
- ) -> Vec < ( PackageId , & HashSet < Dependency > ) > {
811
+ fn deps ( & self , unit : & Unit , unit_for : UnitFor ) -> Vec < ( PackageId , & HashSet < Dependency > ) > {
840
812
let pkg_id = unit. pkg . package_id ( ) ;
841
813
let kind = unit. kind ;
842
814
self . resolve ( )
843
815
. deps ( pkg_id)
844
816
. filter ( |& ( _id, deps) | {
845
817
assert ! ( !deps. is_empty( ) ) ;
846
818
deps. iter ( ) . any ( |dep| {
847
- 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 ( ) {
848
823
return false ;
849
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
+ {
834
+ return false ;
835
+ }
836
+
850
837
// If this dependency is only available for certain platforms,
851
838
// make sure we're only enabling it for that platform.
852
839
if !self . target_data . dep_platform_activated ( dep, kind) {
@@ -862,6 +849,8 @@ impl<'a, 'cfg> State<'a, 'cfg> {
862
849
}
863
850
}
864
851
852
+ // If we've gotten past all that, then this dependency is
853
+ // actually used!
865
854
true
866
855
} )
867
856
} )
0 commit comments