1818use crate :: core:: compiler:: unit_graph:: { UnitDep , UnitGraph } ;
1919use crate :: core:: compiler:: UnitInterner ;
2020use crate :: core:: compiler:: { CompileKind , CompileMode , RustcTargetData , Unit } ;
21- use crate :: core:: dependency:: DepKind ;
2221use crate :: core:: profiles:: { Profile , Profiles , UnitFor } ;
2322use crate :: core:: resolver:: features:: { FeaturesFor , ResolvedFeatures } ;
2423use crate :: core:: resolver:: Resolve ;
@@ -243,29 +242,7 @@ fn compute_deps(
243242 }
244243
245244 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) ;
269246
270247 let mut ret = Vec :: new ( ) ;
271248 let mut dev_deps = Vec :: new ( ) ;
@@ -423,7 +400,7 @@ fn compute_deps_doc(
423400 state : & mut State < ' _ , ' _ > ,
424401 unit_for : UnitFor ,
425402) -> CargoResult < Vec < UnitDep > > {
426- let deps = state. deps ( unit, unit_for, & |dep| dep . kind ( ) == DepKind :: Normal ) ;
403+ let deps = state. deps ( unit, unit_for) ;
427404
428405 // To document a library, we depend on dependencies actually being
429406 // built. If we're documenting *all* libraries, then we also depend on
@@ -831,22 +808,32 @@ impl<'a, 'cfg> State<'a, 'cfg> {
831808 }
832809
833810 /// 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 > ) > {
840812 let pkg_id = unit. pkg . package_id ( ) ;
841813 let kind = unit. kind ;
842814 self . resolve ( )
843815 . deps ( pkg_id)
844816 . filter ( |& ( _id, deps) | {
845817 assert ! ( !deps. is_empty( ) ) ;
846818 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 ( ) {
848823 return false ;
849824 }
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+
850837 // If this dependency is only available for certain platforms,
851838 // make sure we're only enabling it for that platform.
852839 if !self . target_data . dep_platform_activated ( dep, kind) {
@@ -862,6 +849,8 @@ impl<'a, 'cfg> State<'a, 'cfg> {
862849 }
863850 }
864851
852+ // If we've gotten past all that, then this dependency is
853+ // actually used!
865854 true
866855 } )
867856 } )
0 commit comments