@@ -127,20 +127,14 @@ pub fn resolve(
127
127
print_warnings : bool ,
128
128
check_public_visible_dependencies : bool ,
129
129
) -> CargoResult < Resolve > {
130
- let cx = Context :: new ( ) ;
130
+ let cx = Context :: new ( check_public_visible_dependencies ) ;
131
131
let _p = profile:: start ( "resolving" ) ;
132
132
let minimal_versions = match config {
133
133
Some ( config) => config. cli_unstable ( ) . minimal_versions ,
134
134
None => false ,
135
135
} ;
136
136
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) ?;
144
138
145
139
let mut cksums = HashMap :: new ( ) ;
146
140
for summary in cx. activations . values ( ) . flat_map ( |v| v. iter ( ) ) {
@@ -188,7 +182,6 @@ fn activate_deps_loop(
188
182
registry : & mut RegistryQueryer < ' _ > ,
189
183
summaries : & [ ( Summary , Method < ' _ > ) ] ,
190
184
config : Option < & Config > ,
191
- check_public_visible_dependencies : bool ,
192
185
) -> CargoResult < Context > {
193
186
let mut backtrack_stack = Vec :: new ( ) ;
194
187
let mut remaining_deps = RemainingDeps :: new ( ) ;
@@ -204,14 +197,7 @@ fn activate_deps_loop(
204
197
summary : summary. clone ( ) ,
205
198
replace : None ,
206
199
} ;
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) ;
215
201
match res {
216
202
Ok ( Some ( ( frame, _) ) ) => remaining_deps. push ( frame) ,
217
203
Ok ( None ) => ( ) ,
@@ -288,7 +274,6 @@ fn activate_deps_loop(
288
274
& cx,
289
275
& dep,
290
276
parent. package_id ( ) ,
291
- check_public_visible_dependencies,
292
277
) ;
293
278
294
279
let ( candidate, has_another) = next. ok_or ( ( ) ) . or_else ( |_| {
@@ -328,7 +313,6 @@ fn activate_deps_loop(
328
313
& parent,
329
314
backtracked,
330
315
& conflicting_activations,
331
- check_public_visible_dependencies,
332
316
) {
333
317
Some ( ( candidate, has_another, frame) ) => {
334
318
// Reset all of our local variables used with the
@@ -405,14 +389,7 @@ fn activate_deps_loop(
405
389
dep. package_name( ) ,
406
390
candidate. summary. version( )
407
391
) ;
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) ;
416
393
417
394
let successfully_activated = match res {
418
395
// Success! We've now activated our `candidate` in our context
@@ -527,7 +504,6 @@ fn activate_deps_loop(
527
504
& parent,
528
505
backtracked,
529
506
& conflicting_activations,
530
- check_public_visible_dependencies,
531
507
)
532
508
. is_none ( )
533
509
}
@@ -625,7 +601,6 @@ fn activate(
625
601
parent : Option < ( & Summary , & Dependency ) > ,
626
602
candidate : Candidate ,
627
603
method : & Method < ' _ > ,
628
- check_public_visible_dependencies : bool ,
629
604
) -> ActivateResult < Option < ( DepsFrame , Duration ) > > {
630
605
let candidate_pid = candidate. summary . package_id ( ) ;
631
606
if let Some ( ( parent, dep) ) = parent {
@@ -638,13 +613,12 @@ fn activate(
638
613
)
639
614
// and associate dep with that edge
640
615
. push ( dep. clone ( ) ) ;
641
- if check_public_visible_dependencies {
616
+ if let Some ( public_dependency ) = cx . public_dependency . as_mut ( ) {
642
617
// one tricky part is that `candidate_pid` may already be active and
643
618
// have public dependencies of its own. So we not only need to mark
644
619
// `candidate_pid` as visible to its parents but also all of its existing
645
620
// public dependencies.
646
- let existing_public_deps: Vec < PackageId > = cx
647
- . public_dependency
621
+ let existing_public_deps: Vec < PackageId > = public_dependency
648
622
. get ( & candidate_pid)
649
623
. iter ( )
650
624
. flat_map ( |x| x. values ( ) )
@@ -656,7 +630,7 @@ fn activate(
656
630
// for each (transitive) parent that can newly see `t`
657
631
let mut stack = vec ! [ ( parent_pid, dep. is_public( ) ) ] ;
658
632
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 ( ) ) {
660
634
im_rc:: hashmap:: Entry :: Occupied ( mut o) => {
661
635
// the (transitive) parent can already see something by `c`s name, it had better be `c`.
662
636
assert_eq ! ( o. get( ) . 0 , c) ;
@@ -784,7 +758,6 @@ impl RemainingCandidates {
784
758
cx : & Context ,
785
759
dep : & Dependency ,
786
760
parent : PackageId ,
787
- check_public_visible_dependencies : bool ,
788
761
) -> Option < ( Candidate , bool ) > {
789
762
let prev_active = cx. prev_active ( dep) ;
790
763
@@ -828,9 +801,8 @@ impl RemainingCandidates {
828
801
// we have to reject this candidate. Additionally this candidate may already have been
829
802
// activated and have public dependants of its own,
830
803
// 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
834
806
. get ( & b. summary . package_id ( ) )
835
807
. iter ( )
836
808
. flat_map ( |x| x. values ( ) )
@@ -843,8 +815,7 @@ impl RemainingCandidates {
843
815
let mut stack = vec ! [ ( parent, dep. is_public( ) ) ] ;
844
816
while let Some ( ( p, public) ) = stack. pop ( ) {
845
817
// 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 ( ) ) ) {
848
819
if o. 0 != t {
849
820
// the (transitive) parent can already see a different version by `t`s name.
850
821
// So, adding `b` will cause `p` to have a public dependency conflict on `t`.
@@ -915,15 +886,13 @@ fn find_candidate(
915
886
parent : & Summary ,
916
887
backtracked : bool ,
917
888
conflicting_activations : & ConflictMap ,
918
- check_public_visible_dependencies : bool ,
919
889
) -> Option < ( Candidate , bool , BacktrackFrame ) > {
920
890
while let Some ( mut frame) = backtrack_stack. pop ( ) {
921
891
let next = frame. remaining_candidates . next (
922
892
& mut frame. conflicting_activations ,
923
893
& frame. context ,
924
894
& frame. dep ,
925
895
frame. parent . package_id ( ) ,
926
- check_public_visible_dependencies,
927
896
) ;
928
897
let ( candidate, has_another) = match next {
929
898
Some ( pair) => pair,
0 commit comments