@@ -7,6 +7,7 @@ use crate::sources::config::SourceConfigMap;
7
7
use crate :: sources:: source:: QueryKind ;
8
8
use crate :: sources:: source:: Source ;
9
9
use crate :: sources:: source:: SourceMap ;
10
+ use crate :: sources:: IndexSummary ;
10
11
use crate :: util:: errors:: CargoResult ;
11
12
use crate :: util:: interning:: InternedString ;
12
13
use crate :: util:: { CanonicalUrl , Config } ;
@@ -23,10 +24,14 @@ pub trait Registry {
23
24
& mut self ,
24
25
dep : & Dependency ,
25
26
kind : QueryKind ,
26
- f : & mut dyn FnMut ( Summary ) ,
27
+ f : & mut dyn FnMut ( IndexSummary ) ,
27
28
) -> Poll < CargoResult < ( ) > > ;
28
29
29
- fn query_vec ( & mut self , dep : & Dependency , kind : QueryKind ) -> Poll < CargoResult < Vec < Summary > > > {
30
+ fn query_vec (
31
+ & mut self ,
32
+ dep : & Dependency ,
33
+ kind : QueryKind ,
34
+ ) -> Poll < CargoResult < Vec < IndexSummary > > > {
30
35
let mut ret = Vec :: new ( ) ;
31
36
self . query ( dep, kind, & mut |s| ret. push ( s) ) . map_ok ( |( ) | ret)
32
37
}
@@ -337,6 +342,8 @@ impl<'cfg> PackageRegistry<'cfg> {
337
342
}
338
343
} ;
339
344
345
+ let summaries = summaries. into_iter ( ) . map ( |s| s. into_summary ( ) ) . collect ( ) ;
346
+
340
347
let ( summary, should_unlock) =
341
348
match summary_for_patch ( orig_patch, & locked, summaries, source) {
342
349
Poll :: Ready ( x) => x,
@@ -481,13 +488,15 @@ impl<'cfg> PackageRegistry<'cfg> {
481
488
Ok ( ( ) )
482
489
}
483
490
484
- fn query_overrides ( & mut self , dep : & Dependency ) -> Poll < CargoResult < Option < Summary > > > {
491
+ fn query_overrides ( & mut self , dep : & Dependency ) -> Poll < CargoResult < Option < IndexSummary > > > {
485
492
for & s in self . overrides . iter ( ) {
486
493
let src = self . sources . get_mut ( s) . unwrap ( ) ;
487
494
let dep = Dependency :: new_override ( dep. package_name ( ) , s) ;
488
- let mut results = ready ! ( src. query_vec( & dep, QueryKind :: Exact ) ) ?;
489
- if !results. is_empty ( ) {
490
- return Poll :: Ready ( Ok ( Some ( results. remove ( 0 ) ) ) ) ;
495
+
496
+ let mut results = None ;
497
+ ready ! ( src. query( & dep, QueryKind :: Exact , & mut |s| results = Some ( s) ) ) ?;
498
+ if results. is_some ( ) {
499
+ return Poll :: Ready ( Ok ( results) ) ;
491
500
}
492
501
}
493
502
Poll :: Ready ( Ok ( None ) )
@@ -575,7 +584,7 @@ impl<'cfg> Registry for PackageRegistry<'cfg> {
575
584
& mut self ,
576
585
dep : & Dependency ,
577
586
kind : QueryKind ,
578
- f : & mut dyn FnMut ( Summary ) ,
587
+ f : & mut dyn FnMut ( IndexSummary ) ,
579
588
) -> Poll < CargoResult < ( ) > > {
580
589
assert ! ( self . patches_locked) ;
581
590
let ( override_summary, n, to_warn) = {
@@ -607,9 +616,9 @@ impl<'cfg> Registry for PackageRegistry<'cfg> {
607
616
if patches. len ( ) == 1 && dep. is_locked ( ) {
608
617
let patch = patches. remove ( 0 ) ;
609
618
match override_summary {
610
- Some ( summary) => ( summary, 1 , Some ( patch) ) ,
619
+ Some ( summary) => ( summary, 1 , Some ( IndexSummary :: Candidate ( patch) ) ) ,
611
620
None => {
612
- f ( patch) ;
621
+ f ( IndexSummary :: Candidate ( patch) ) ;
613
622
return Poll :: Ready ( Ok ( ( ) ) ) ;
614
623
}
615
624
}
@@ -646,7 +655,7 @@ impl<'cfg> Registry for PackageRegistry<'cfg> {
646
655
// everything upstairs after locking the summary
647
656
( None , Some ( source) ) => {
648
657
for patch in patches. iter ( ) {
649
- f ( patch. clone ( ) ) ;
658
+ f ( IndexSummary :: Candidate ( patch. clone ( ) ) ) ;
650
659
}
651
660
652
661
// Our sources shouldn't ever come back to us with two
@@ -658,14 +667,18 @@ impl<'cfg> Registry for PackageRegistry<'cfg> {
658
667
// already selected, then we skip this `summary`.
659
668
let locked = & self . locked ;
660
669
let all_patches = & self . patches_available ;
661
- let callback = & mut |summary : Summary | {
670
+ let callback = & mut |summary : IndexSummary | {
662
671
for patch in patches. iter ( ) {
663
672
let patch = patch. package_id ( ) . version ( ) ;
664
673
if summary. package_id ( ) . version ( ) == patch {
665
674
return ;
666
675
}
667
676
}
668
- f ( lock ( locked, all_patches, summary) )
677
+ f ( IndexSummary :: Candidate ( lock (
678
+ locked,
679
+ all_patches,
680
+ summary. into_summary ( ) ,
681
+ ) ) )
669
682
} ;
670
683
return source. query ( dep, kind, callback) ;
671
684
}
@@ -702,9 +715,12 @@ impl<'cfg> Registry for PackageRegistry<'cfg> {
702
715
"found an override with a non-locked list"
703
716
) ) ) ;
704
717
} else if let Some ( summary) = to_warn {
705
- self . warn_bad_override ( & override_summary, & summary) ?;
718
+ self . warn_bad_override ( override_summary. as_summary ( ) , summary. as_summary ( ) ) ?;
706
719
}
707
- f ( self . lock ( override_summary) ) ;
720
+ f ( IndexSummary :: Candidate (
721
+ self . lock ( override_summary. into_summary ( ) ) ,
722
+ ) ) ;
723
+
708
724
Poll :: Ready ( Ok ( ( ) ) )
709
725
}
710
726
@@ -887,6 +903,8 @@ fn summary_for_patch(
887
903
Vec :: new ( )
888
904
} ) ;
889
905
906
+ let orig_matches = orig_matches. into_iter ( ) . map ( |s| s. into_summary ( ) ) . collect ( ) ;
907
+
890
908
let summary = ready ! ( summary_for_patch( orig_patch, & None , orig_matches, source) ) ?;
891
909
892
910
// The unlocked version found a match. This returns a value to
@@ -907,7 +925,7 @@ fn summary_for_patch(
907
925
} ) ;
908
926
let mut vers = name_summaries
909
927
. iter ( )
910
- . map ( |summary| summary. version ( ) )
928
+ . map ( |summary| summary. as_summary ( ) . version ( ) )
911
929
. collect :: < Vec < _ > > ( ) ;
912
930
let found = match vers. len ( ) {
913
931
0 => format ! ( "" ) ,
0 commit comments