@@ -7,6 +7,7 @@ use crate::sources::config::SourceConfigMap;
77use crate :: sources:: source:: QueryKind ;
88use crate :: sources:: source:: Source ;
99use crate :: sources:: source:: SourceMap ;
10+ use crate :: sources:: IndexSummary ;
1011use crate :: util:: errors:: CargoResult ;
1112use crate :: util:: interning:: InternedString ;
1213use crate :: util:: { CanonicalUrl , Config } ;
@@ -23,10 +24,14 @@ pub trait Registry {
2324 & mut self ,
2425 dep : & Dependency ,
2526 kind : QueryKind ,
26- f : & mut dyn FnMut ( Summary ) ,
27+ f : & mut dyn FnMut ( IndexSummary ) ,
2728 ) -> Poll < CargoResult < ( ) > > ;
2829
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 > > > {
3035 let mut ret = Vec :: new ( ) ;
3136 self . query ( dep, kind, & mut |s| ret. push ( s) ) . map_ok ( |( ) | ret)
3237 }
@@ -337,6 +342,8 @@ impl<'cfg> PackageRegistry<'cfg> {
337342 }
338343 } ;
339344
345+ let summaries = summaries. into_iter ( ) . map ( |s| s. into_summary ( ) ) . collect ( ) ;
346+
340347 let ( summary, should_unlock) =
341348 match summary_for_patch ( orig_patch, & locked, summaries, source) {
342349 Poll :: Ready ( x) => x,
@@ -481,13 +488,15 @@ impl<'cfg> PackageRegistry<'cfg> {
481488 Ok ( ( ) )
482489 }
483490
484- fn query_overrides ( & mut self , dep : & Dependency ) -> Poll < CargoResult < Option < Summary > > > {
491+ fn query_overrides ( & mut self , dep : & Dependency ) -> Poll < CargoResult < Option < IndexSummary > > > {
485492 for & s in self . overrides . iter ( ) {
486493 let src = self . sources . get_mut ( s) . unwrap ( ) ;
487494 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) ) ;
491500 }
492501 }
493502 Poll :: Ready ( Ok ( None ) )
@@ -575,7 +584,7 @@ impl<'cfg> Registry for PackageRegistry<'cfg> {
575584 & mut self ,
576585 dep : & Dependency ,
577586 kind : QueryKind ,
578- f : & mut dyn FnMut ( Summary ) ,
587+ f : & mut dyn FnMut ( IndexSummary ) ,
579588 ) -> Poll < CargoResult < ( ) > > {
580589 assert ! ( self . patches_locked) ;
581590 let ( override_summary, n, to_warn) = {
@@ -607,9 +616,9 @@ impl<'cfg> Registry for PackageRegistry<'cfg> {
607616 if patches. len ( ) == 1 && dep. is_locked ( ) {
608617 let patch = patches. remove ( 0 ) ;
609618 match override_summary {
610- Some ( summary) => ( summary, 1 , Some ( patch) ) ,
619+ Some ( summary) => ( summary, 1 , Some ( IndexSummary :: Candidate ( patch) ) ) ,
611620 None => {
612- f ( patch) ;
621+ f ( IndexSummary :: Candidate ( patch) ) ;
613622 return Poll :: Ready ( Ok ( ( ) ) ) ;
614623 }
615624 }
@@ -646,7 +655,7 @@ impl<'cfg> Registry for PackageRegistry<'cfg> {
646655 // everything upstairs after locking the summary
647656 ( None , Some ( source) ) => {
648657 for patch in patches. iter ( ) {
649- f ( patch. clone ( ) ) ;
658+ f ( IndexSummary :: Candidate ( patch. clone ( ) ) ) ;
650659 }
651660
652661 // Our sources shouldn't ever come back to us with two
@@ -658,14 +667,18 @@ impl<'cfg> Registry for PackageRegistry<'cfg> {
658667 // already selected, then we skip this `summary`.
659668 let locked = & self . locked ;
660669 let all_patches = & self . patches_available ;
661- let callback = & mut |summary : Summary | {
670+ let callback = & mut |summary : IndexSummary | {
662671 for patch in patches. iter ( ) {
663672 let patch = patch. package_id ( ) . version ( ) ;
664673 if summary. package_id ( ) . version ( ) == patch {
665674 return ;
666675 }
667676 }
668- f ( lock ( locked, all_patches, summary) )
677+ f ( IndexSummary :: Candidate ( lock (
678+ locked,
679+ all_patches,
680+ summary. into_summary ( ) ,
681+ ) ) )
669682 } ;
670683 return source. query ( dep, kind, callback) ;
671684 }
@@ -702,9 +715,12 @@ impl<'cfg> Registry for PackageRegistry<'cfg> {
702715 "found an override with a non-locked list"
703716 ) ) ) ;
704717 } 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 ( ) ) ?;
706719 }
707- f ( self . lock ( override_summary) ) ;
720+ f ( IndexSummary :: Candidate (
721+ self . lock ( override_summary. into_summary ( ) ) ,
722+ ) ) ;
723+
708724 Poll :: Ready ( Ok ( ( ) ) )
709725 }
710726
@@ -887,6 +903,8 @@ fn summary_for_patch(
887903 Vec :: new ( )
888904 } ) ;
889905
906+ let orig_matches = orig_matches. into_iter ( ) . map ( |s| s. into_summary ( ) ) . collect ( ) ;
907+
890908 let summary = ready ! ( summary_for_patch( orig_patch, & None , orig_matches, source) ) ?;
891909
892910 // The unlocked version found a match. This returns a value to
@@ -907,7 +925,7 @@ fn summary_for_patch(
907925 } ) ;
908926 let mut vers = name_summaries
909927 . iter ( )
910- . map ( |summary| summary. version ( ) )
928+ . map ( |summary| summary. as_summary ( ) . version ( ) )
911929 . collect :: < Vec < _ > > ( ) ;
912930 let found = match vers. len ( ) {
913931 0 => format ! ( "" ) ,
0 commit comments