@@ -636,139 +636,126 @@ impl<'gctx> Registry for PackageRegistry<'gctx> {
636
636
f : & mut dyn FnMut ( IndexSummary ) ,
637
637
) -> Poll < CargoResult < ( ) > > {
638
638
assert ! ( self . patches_locked) ;
639
- let ( override_summary, n, to_warn) = {
640
- // Look for an override and get ready to query the real source.
641
- let override_summary = ready ! ( self . query_overrides( dep) ) ?;
642
-
643
- // Next up on our list of candidates is to check the `[patch]`
644
- // section of the manifest. Here we look through all patches
645
- // relevant to the source that `dep` points to, and then we match
646
- // name/version. Note that we don't use `dep.matches(..)` because
647
- // the patches, by definition, come from a different source.
648
- // This means that `dep.matches(..)` will always return false, when
649
- // what we really care about is the name/version match.
650
- let mut patches = Vec :: < Summary > :: new ( ) ;
651
- if let Some ( extra) = self . patches . get ( dep. source_id ( ) . canonical_url ( ) ) {
652
- patches. extend (
653
- extra
654
- . iter ( )
655
- . filter ( |s| dep. matches_ignoring_source ( s. package_id ( ) ) )
656
- . cloned ( ) ,
657
- ) ;
658
- }
639
+ // Look for an override and get ready to query the real source.
640
+ let override_summary = ready ! ( self . query_overrides( dep) ) ?;
641
+
642
+ // Next up on our list of candidates is to check the `[patch]` section
643
+ // of the manifest. Here we look through all patches relevant to the
644
+ // source that `dep` points to, and then we match name/version. Note
645
+ // that we don't use `dep.matches(..)` because the patches, by definition,
646
+ // come from a different source. This means that `dep.matches(..)` will
647
+ // always return false, when what we really care about is the name/version match.
648
+ let mut patches = Vec :: < Summary > :: new ( ) ;
649
+ if let Some ( extra) = self . patches . get ( dep. source_id ( ) . canonical_url ( ) ) {
650
+ patches. extend (
651
+ extra
652
+ . iter ( )
653
+ . filter ( |s| dep. matches_ignoring_source ( s. package_id ( ) ) )
654
+ . cloned ( ) ,
655
+ ) ;
656
+ }
659
657
660
- // A crucial feature of the `[patch]` feature is that we *don't*
661
- // query the actual registry if we have a "locked" dependency. A
662
- // locked dep basically just means a version constraint of `=a.b.c`,
663
- // and because patches take priority over the actual source then if
664
- // we have a candidate we're done.
665
- if patches. len ( ) == 1 && dep. is_locked ( ) {
666
- let patch = patches. remove ( 0 ) ;
667
- match override_summary {
668
- Some ( summary) => ( summary, 1 , Some ( IndexSummary :: Candidate ( patch) ) ) ,
669
- None => {
670
- f ( IndexSummary :: Candidate ( patch) ) ;
671
- return Poll :: Ready ( Ok ( ( ) ) ) ;
672
- }
673
- }
674
- } else {
675
- if !patches. is_empty ( ) {
676
- debug ! (
677
- "found {} patches with an unlocked dep on `{}` at {} \
678
- with `{}`, \
679
- looking at sources",
680
- patches. len( ) ,
681
- dep. package_name( ) ,
682
- dep. source_id( ) ,
683
- dep. version_req( )
684
- ) ;
658
+ // A crucial feature of the `[patch]` feature is that we don't query the
659
+ // actual registry if we have a "locked" dependency. A locked dep basically
660
+ // just means a version constraint of `=a.b.c`, and because patches take
661
+ // priority over the actual source then if we have a candidate we're done.
662
+ if patches. len ( ) == 1 && dep. is_locked ( ) {
663
+ let patch = patches. remove ( 0 ) ;
664
+ match override_summary {
665
+ Some ( override_summary) => {
666
+ let override_summary = override_summary. into_summary ( ) ;
667
+ self . warn_bad_override ( & override_summary, & patch) ?;
668
+ f ( IndexSummary :: Candidate ( self . lock ( override_summary) ) ) ;
685
669
}
670
+ None => f ( IndexSummary :: Candidate ( patch) ) ,
671
+ }
686
672
687
- // Ensure the requested source_id is loaded
688
- self . ensure_loaded ( dep. source_id ( ) , Kind :: Normal )
689
- . with_context ( || {
690
- format ! (
691
- "failed to load source for dependency `{}`" ,
692
- dep. package_name( )
693
- )
694
- } ) ?;
673
+ return Poll :: Ready ( Ok ( ( ) ) ) ;
674
+ }
695
675
696
- let source = self . sources . get_mut ( dep. source_id ( ) ) ;
697
- match ( override_summary, source) {
698
- ( Some ( _) , None ) => {
699
- return Poll :: Ready ( Err ( anyhow:: anyhow!( "override found but no real ones" ) ) )
700
- }
701
- ( None , None ) => return Poll :: Ready ( Ok ( ( ) ) ) ,
676
+ if !patches. is_empty ( ) {
677
+ debug ! (
678
+ "found {} patches with an unlocked dep on `{}` at {} \
679
+ with `{}`, \
680
+ looking at sources",
681
+ patches. len( ) ,
682
+ dep. package_name( ) ,
683
+ dep. source_id( ) ,
684
+ dep. version_req( )
685
+ ) ;
686
+ }
702
687
703
- // If we don't have an override then we just ship
704
- // everything upstairs after locking the summary
705
- ( None , Some ( source) ) => {
706
- for patch in patches. iter ( ) {
707
- f ( IndexSummary :: Candidate ( patch. clone ( ) ) ) ;
708
- }
688
+ // Ensure the requested source_id is loaded
689
+ self . ensure_loaded ( dep. source_id ( ) , Kind :: Normal )
690
+ . with_context ( || {
691
+ format ! (
692
+ "failed to load source for dependency `{}`" ,
693
+ dep. package_name( )
694
+ )
695
+ } ) ?;
709
696
710
- // Our sources shouldn't ever come back to us with two
711
- // summaries that have the same version. We could,
712
- // however, have an `[patch]` section which is in use
713
- // to override a version in the registry. This means
714
- // that if our `summary` in this loop has the same
715
- // version as something in `patches` that we've
716
- // already selected, then we skip this `summary`.
717
- let locked = & self . locked ;
718
- let all_patches = & self . patches_available ;
719
- let callback = & mut |summary : IndexSummary | {
720
- for patch in patches. iter ( ) {
721
- let patch = patch. package_id ( ) . version ( ) ;
722
- if summary. package_id ( ) . version ( ) == patch {
723
- return ;
724
- }
725
- }
726
- f ( IndexSummary :: Candidate ( lock (
727
- locked,
728
- all_patches,
729
- summary. into_summary ( ) ,
730
- ) ) )
731
- } ;
732
- return source. query ( dep, kind, callback) ;
733
- }
697
+ let source = self . sources . get_mut ( dep. source_id ( ) ) ;
698
+ match ( override_summary, source) {
699
+ ( Some ( _) , None ) => {
700
+ return Poll :: Ready ( Err ( anyhow:: anyhow!( "override found but no real ones" ) ) )
701
+ }
702
+ ( None , None ) => return Poll :: Ready ( Ok ( ( ) ) ) ,
734
703
735
- // If we have an override summary then we query the source
736
- // to sanity check its results. We don't actually use any of
737
- // the summaries it gives us though.
738
- ( Some ( override_summary) , Some ( source) ) => {
739
- if !patches. is_empty ( ) {
740
- return Poll :: Ready ( Err ( anyhow:: anyhow!(
741
- "found patches and a path override"
742
- ) ) ) ;
743
- }
744
- let mut n = 0 ;
745
- let mut to_warn = None ;
746
- {
747
- let callback = & mut |summary| {
748
- n += 1 ;
749
- to_warn = Some ( summary) ;
750
- } ;
751
- let pend = source. query ( dep, kind, callback) ;
752
- if pend. is_pending ( ) {
753
- return Poll :: Pending ;
754
- }
704
+ // If we don't have an override then we just ship everything upstairs after locking the summary
705
+ ( None , Some ( source) ) => {
706
+ for patch in patches. iter ( ) {
707
+ f ( IndexSummary :: Candidate ( patch. clone ( ) ) ) ;
708
+ }
709
+
710
+ // Our sources shouldn't ever come back to us with two summaries
711
+ // that have the same version. We could, however, have an `[patch]`
712
+ // section which is in use to override a version in the registry.
713
+ // This means that if our `summary` in this loop has the same
714
+ // version as something in `patches` that we've already selected,
715
+ // then we skip this `summary`.
716
+ let locked = & self . locked ;
717
+ let all_patches = & self . patches_available ;
718
+ let callback = & mut |summary : IndexSummary | {
719
+ for patch in patches. iter ( ) {
720
+ let patch = patch. package_id ( ) . version ( ) ;
721
+ if summary. package_id ( ) . version ( ) == patch {
722
+ return ;
755
723
}
756
- ( override_summary, n, to_warn)
757
724
}
725
+ let summary = summary. into_summary ( ) ;
726
+ f ( IndexSummary :: Candidate ( lock ( locked, all_patches, summary) ) )
727
+ } ;
728
+ return source. query ( dep, kind, callback) ;
729
+ }
730
+
731
+ // If we have an override summary then we query the source to sanity check its results.
732
+ // We don't actually use any of the summaries it gives us though.
733
+ ( Some ( override_summary) , Some ( source) ) => {
734
+ if !patches. is_empty ( ) {
735
+ return Poll :: Ready ( Err ( anyhow:: anyhow!( "found patches and a path override" ) ) ) ;
736
+ }
737
+ let mut n = 0 ;
738
+ let mut to_warn = None ;
739
+ let callback = & mut |summary| {
740
+ n += 1 ;
741
+ to_warn = Some ( summary) ;
742
+ } ;
743
+ let pend = source. query ( dep, kind, callback) ;
744
+ if pend. is_pending ( ) {
745
+ return Poll :: Pending ;
746
+ }
747
+ if n > 1 {
748
+ return Poll :: Ready ( Err ( anyhow:: anyhow!(
749
+ "found an override with a non-locked list"
750
+ ) ) ) ;
751
+ }
752
+ let override_summary = override_summary. into_summary ( ) ;
753
+ if let Some ( to_warn) = to_warn {
754
+ self . warn_bad_override ( & override_summary, to_warn. as_summary ( ) ) ?;
758
755
}
756
+ f ( IndexSummary :: Candidate ( self . lock ( override_summary) ) ) ;
759
757
}
760
- } ;
761
-
762
- if n > 1 {
763
- return Poll :: Ready ( Err ( anyhow:: anyhow!(
764
- "found an override with a non-locked list"
765
- ) ) ) ;
766
- } else if let Some ( summary) = to_warn {
767
- self . warn_bad_override ( override_summary. as_summary ( ) , summary. as_summary ( ) ) ?;
768
758
}
769
- f ( IndexSummary :: Candidate (
770
- self . lock ( override_summary. into_summary ( ) ) ,
771
- ) ) ;
772
759
773
760
Poll :: Ready ( Ok ( ( ) ) )
774
761
}
0 commit comments