@@ -127,20 +127,14 @@ pub fn resolve(
127127 print_warnings : bool ,
128128 check_public_visible_dependencies : bool ,
129129) -> CargoResult < Resolve > {
130- let cx = Context :: new ( ) ;
130+ let cx = Context :: new ( check_public_visible_dependencies ) ;
131131 let _p = profile:: start ( "resolving" ) ;
132132 let minimal_versions = match config {
133133 Some ( config) => config. cli_unstable ( ) . minimal_versions ,
134134 None => false ,
135135 } ;
136136 let mut registry = RegistryQueryer :: new ( registry, replacements, try_to_use, minimal_versions) ;
137- let cx = activate_deps_loop (
138- cx,
139- & mut registry,
140- summaries,
141- config,
142- check_public_visible_dependencies,
143- ) ?;
137+ let cx = activate_deps_loop ( cx, & mut registry, summaries, config) ?;
144138
145139 let mut cksums = HashMap :: new ( ) ;
146140 for summary in cx. activations . values ( ) . flat_map ( |v| v. iter ( ) ) {
@@ -188,7 +182,6 @@ fn activate_deps_loop(
188182 registry : & mut RegistryQueryer < ' _ > ,
189183 summaries : & [ ( Summary , Method < ' _ > ) ] ,
190184 config : Option < & Config > ,
191- check_public_visible_dependencies : bool ,
192185) -> CargoResult < Context > {
193186 let mut backtrack_stack = Vec :: new ( ) ;
194187 let mut remaining_deps = RemainingDeps :: new ( ) ;
@@ -204,14 +197,7 @@ fn activate_deps_loop(
204197 summary : summary. clone ( ) ,
205198 replace : None ,
206199 } ;
207- let res = activate (
208- & mut cx,
209- registry,
210- None ,
211- candidate,
212- method,
213- check_public_visible_dependencies,
214- ) ;
200+ let res = activate ( & mut cx, registry, None , candidate, method) ;
215201 match res {
216202 Ok ( Some ( ( frame, _) ) ) => remaining_deps. push ( frame) ,
217203 Ok ( None ) => ( ) ,
@@ -288,7 +274,6 @@ fn activate_deps_loop(
288274 & cx,
289275 & dep,
290276 parent. package_id ( ) ,
291- check_public_visible_dependencies,
292277 ) ;
293278
294279 let ( candidate, has_another) = next. ok_or ( ( ) ) . or_else ( |_| {
@@ -328,7 +313,6 @@ fn activate_deps_loop(
328313 & parent,
329314 backtracked,
330315 & conflicting_activations,
331- check_public_visible_dependencies,
332316 ) {
333317 Some ( ( candidate, has_another, frame) ) => {
334318 // Reset all of our local variables used with the
@@ -405,14 +389,7 @@ fn activate_deps_loop(
405389 dep. package_name( ) ,
406390 candidate. summary. version( )
407391 ) ;
408- let res = activate (
409- & mut cx,
410- registry,
411- Some ( ( & parent, & dep) ) ,
412- candidate,
413- & method,
414- check_public_visible_dependencies,
415- ) ;
392+ let res = activate ( & mut cx, registry, Some ( ( & parent, & dep) ) , candidate, & method) ;
416393
417394 let successfully_activated = match res {
418395 // Success! We've now activated our `candidate` in our context
@@ -527,7 +504,6 @@ fn activate_deps_loop(
527504 & parent,
528505 backtracked,
529506 & conflicting_activations,
530- check_public_visible_dependencies,
531507 )
532508 . is_none ( )
533509 }
@@ -625,7 +601,6 @@ fn activate(
625601 parent : Option < ( & Summary , & Dependency ) > ,
626602 candidate : Candidate ,
627603 method : & Method < ' _ > ,
628- check_public_visible_dependencies : bool ,
629604) -> ActivateResult < Option < ( DepsFrame , Duration ) > > {
630605 let candidate_pid = candidate. summary . package_id ( ) ;
631606 if let Some ( ( parent, dep) ) = parent {
@@ -638,13 +613,12 @@ fn activate(
638613 )
639614 // and associate dep with that edge
640615 . push ( dep. clone ( ) ) ;
641- if check_public_visible_dependencies {
616+ if let Some ( public_dependency ) = cx . public_dependency . as_mut ( ) {
642617 // one tricky part is that `candidate_pid` may already be active and
643618 // have public dependencies of its own. So we not only need to mark
644619 // `candidate_pid` as visible to its parents but also all of its existing
645620 // public dependencies.
646- let existing_public_deps: Vec < PackageId > = cx
647- . public_dependency
621+ let existing_public_deps: Vec < PackageId > = public_dependency
648622 . get ( & candidate_pid)
649623 . iter ( )
650624 . flat_map ( |x| x. values ( ) )
@@ -656,7 +630,7 @@ fn activate(
656630 // for each (transitive) parent that can newly see `t`
657631 let mut stack = vec ! [ ( parent_pid, dep. is_public( ) ) ] ;
658632 while let Some ( ( p, public) ) = stack. pop ( ) {
659- match cx . public_dependency . entry ( p) . or_default ( ) . entry ( c. name ( ) ) {
633+ match public_dependency. entry ( p) . or_default ( ) . entry ( c. name ( ) ) {
660634 im_rc:: hashmap:: Entry :: Occupied ( mut o) => {
661635 // the (transitive) parent can already see something by `c`s name, it had better be `c`.
662636 assert_eq ! ( o. get( ) . 0 , c) ;
@@ -784,7 +758,6 @@ impl RemainingCandidates {
784758 cx : & Context ,
785759 dep : & Dependency ,
786760 parent : PackageId ,
787- check_public_visible_dependencies : bool ,
788761 ) -> Option < ( Candidate , bool ) > {
789762 let prev_active = cx. prev_active ( dep) ;
790763
@@ -828,9 +801,8 @@ impl RemainingCandidates {
828801 // we have to reject this candidate. Additionally this candidate may already have been
829802 // activated and have public dependants of its own,
830803 // all of witch also need to be checked the same way.
831- if check_public_visible_dependencies {
832- let existing_public_deps: Vec < PackageId > = cx
833- . public_dependency
804+ if let Some ( public_dependency) = cx. public_dependency . as_ref ( ) {
805+ let existing_public_deps: Vec < PackageId > = public_dependency
834806 . get ( & b. summary . package_id ( ) )
835807 . iter ( )
836808 . flat_map ( |x| x. values ( ) )
@@ -843,8 +815,7 @@ impl RemainingCandidates {
843815 let mut stack = vec ! [ ( parent, dep. is_public( ) ) ] ;
844816 while let Some ( ( p, public) ) = stack. pop ( ) {
845817 // TODO: dont look at the same thing more then once
846- if let Some ( o) = cx. public_dependency . get ( & p) . and_then ( |x| x. get ( & t. name ( ) ) )
847- {
818+ if let Some ( o) = public_dependency. get ( & p) . and_then ( |x| x. get ( & t. name ( ) ) ) {
848819 if o. 0 != t {
849820 // the (transitive) parent can already see a different version by `t`s name.
850821 // So, adding `b` will cause `p` to have a public dependency conflict on `t`.
@@ -915,15 +886,13 @@ fn find_candidate(
915886 parent : & Summary ,
916887 backtracked : bool ,
917888 conflicting_activations : & ConflictMap ,
918- check_public_visible_dependencies : bool ,
919889) -> Option < ( Candidate , bool , BacktrackFrame ) > {
920890 while let Some ( mut frame) = backtrack_stack. pop ( ) {
921891 let next = frame. remaining_candidates . next (
922892 & mut frame. conflicting_activations ,
923893 & frame. context ,
924894 & frame. dep ,
925895 frame. parent . package_id ( ) ,
926- check_public_visible_dependencies,
927896 ) ;
928897 let ( candidate, has_another) = match next {
929898 Some ( pair) => pair,
0 commit comments