@@ -157,6 +157,15 @@ enum Kind {
157157 Normal ,
158158}
159159
160+ /// This tuple is an argument to [`PackageRegistry::patch`].
161+ ///
162+ /// * The first element is the patch definition straight from the manifest.
163+ /// * The second element is an optional variant where the patch has been locked.
164+ /// It is the patch locked to a specific version found in Cargo.lock.
165+ /// This will be `None` if `Cargo.lock` doesn't exist,
166+ /// or the patch did not match any existing entries in `Cargo.lock`.
167+ pub type PatchDependency < ' a > = ( & ' a Dependency , Option < LockedPatchDependency > ) ;
168+
160169/// Argument to [`PackageRegistry::patch`] which is information about a `[patch]`
161170/// directive that we found in a lockfile, if present.
162171pub struct LockedPatchDependency {
@@ -303,14 +312,8 @@ impl<'gctx> PackageRegistry<'gctx> {
303312 /// The `deps` is an array of all the entries in the `[patch]` section of
304313 /// the manifest.
305314 ///
306- /// Here the `deps` will be resolved to a precise version and stored
307- /// internally for future calls to `query` below. `deps` should be a tuple
308- /// where the first element is the patch definition straight from the
309- /// manifest, and the second element is an optional variant where the
310- /// patch has been locked. This locked patch is the patch locked to
311- /// a specific version found in Cargo.lock. This will be `None` if
312- /// `Cargo.lock` doesn't exist, or the patch did not match any existing
313- /// entries in `Cargo.lock`.
315+ /// Here the `patch_deps` will be resolved to a precise version and stored
316+ /// internally for future calls to `query` below.
314317 ///
315318 /// Note that the patch list specified here *will not* be available to
316319 /// [`Registry::query`] until [`PackageRegistry::lock_patches`] is called
@@ -322,7 +325,7 @@ impl<'gctx> PackageRegistry<'gctx> {
322325 pub fn patch (
323326 & mut self ,
324327 url : & Url ,
325- deps : & [ ( & Dependency , Option < LockedPatchDependency > ) ] ,
328+ patch_deps : & [ PatchDependency < ' _ > ] ,
326329 ) -> CargoResult < Vec < ( Dependency , PackageId ) > > {
327330 // NOTE: None of this code is aware of required features. If a patch
328331 // is missing a required feature, you end up with an "unused patch"
@@ -333,22 +336,22 @@ impl<'gctx> PackageRegistry<'gctx> {
333336 // Return value of patches that shouldn't be locked.
334337 let mut unlock_patches = Vec :: new ( ) ;
335338
336- // First up we need to actually resolve each `deps ` specification to
337- // precisely one summary. We're not using the `query` method below as it
338- // internally uses maps we're building up as part of this method
339+ // First up we need to actually resolve each `patch_deps ` specification
340+ // to precisely one summary. We're not using the `query` method below
341+ // as it internally uses maps we're building up as part of this method
339342 // (`patches_available` and `patches`). Instead we're going straight to
340343 // the source to load information from it.
341344 //
342345 // Remember that each dependency listed in `[patch]` has to resolve to
343346 // precisely one package, so that's why we're just creating a flat list
344347 // of summaries which should be the same length as `deps` above.
345348
346- let mut deps_remaining : Vec < _ > = deps . iter ( ) . collect ( ) ;
349+ let mut patch_deps_remaining : Vec < _ > = patch_deps . iter ( ) . collect ( ) ;
347350 let mut unlocked_summaries = Vec :: new ( ) ;
348- while !deps_remaining . is_empty ( ) {
349- let mut deps_pending = Vec :: new ( ) ;
350- for dep_remaining in deps_remaining {
351- let ( orig_patch, locked) = dep_remaining ;
351+ while !patch_deps_remaining . is_empty ( ) {
352+ let mut patch_deps_pending = Vec :: new ( ) ;
353+ for patch_dep_remaining in patch_deps_remaining {
354+ let ( orig_patch, locked) = patch_dep_remaining ;
352355
353356 // Use the locked patch if it exists, otherwise use the original.
354357 let dep = match locked {
@@ -388,7 +391,7 @@ impl<'gctx> PackageRegistry<'gctx> {
388391 let summaries = match source. query_vec ( dep, QueryKind :: Exact ) ? {
389392 Poll :: Ready ( deps) => deps,
390393 Poll :: Pending => {
391- deps_pending . push ( dep_remaining ) ;
394+ patch_deps_pending . push ( patch_dep_remaining ) ;
392395 continue ;
393396 }
394397 } ;
@@ -399,7 +402,7 @@ impl<'gctx> PackageRegistry<'gctx> {
399402 match summary_for_patch ( orig_patch, & locked, summaries, source) {
400403 Poll :: Ready ( x) => x,
401404 Poll :: Pending => {
402- deps_pending . push ( dep_remaining ) ;
405+ patch_deps_pending . push ( patch_dep_remaining ) ;
403406 continue ;
404407 }
405408 }
@@ -432,7 +435,7 @@ impl<'gctx> PackageRegistry<'gctx> {
432435 unlocked_summaries. push ( summary) ;
433436 }
434437
435- deps_remaining = deps_pending ;
438+ patch_deps_remaining = patch_deps_pending ;
436439 self . block_until_ready ( ) ?;
437440 }
438441
@@ -467,7 +470,7 @@ impl<'gctx> PackageRegistry<'gctx> {
467470 // in the future, but for now it hopefully doesn't cause too much
468471 // harm...
469472 let mut ids = Vec :: new ( ) ;
470- for ( summary, ( _, lock) ) in unlocked_summaries. iter ( ) . zip ( deps ) {
473+ for ( summary, ( _, lock) ) in unlocked_summaries. iter ( ) . zip ( patch_deps ) {
471474 ids. push ( summary. package_id ( ) ) ;
472475 if let Some ( lock) = lock {
473476 ids. extend ( lock. alt_package_id ) ;
0 commit comments