@@ -157,6 +157,15 @@ enum Kind {
157
157
Normal ,
158
158
}
159
159
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
+
160
169
/// Argument to [`PackageRegistry::patch`] which is information about a `[patch]`
161
170
/// directive that we found in a lockfile, if present.
162
171
pub struct LockedPatchDependency {
@@ -303,14 +312,8 @@ impl<'gctx> PackageRegistry<'gctx> {
303
312
/// The `deps` is an array of all the entries in the `[patch]` section of
304
313
/// the manifest.
305
314
///
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.
314
317
///
315
318
/// Note that the patch list specified here *will not* be available to
316
319
/// [`Registry::query`] until [`PackageRegistry::lock_patches`] is called
@@ -322,7 +325,7 @@ impl<'gctx> PackageRegistry<'gctx> {
322
325
pub fn patch (
323
326
& mut self ,
324
327
url : & Url ,
325
- deps : & [ ( & Dependency , Option < LockedPatchDependency > ) ] ,
328
+ patch_deps : & [ PatchDependency < ' _ > ] ,
326
329
) -> CargoResult < Vec < ( Dependency , PackageId ) > > {
327
330
// NOTE: None of this code is aware of required features. If a patch
328
331
// is missing a required feature, you end up with an "unused patch"
@@ -333,22 +336,22 @@ impl<'gctx> PackageRegistry<'gctx> {
333
336
// Return value of patches that shouldn't be locked.
334
337
let mut unlock_patches = Vec :: new ( ) ;
335
338
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
339
342
// (`patches_available` and `patches`). Instead we're going straight to
340
343
// the source to load information from it.
341
344
//
342
345
// Remember that each dependency listed in `[patch]` has to resolve to
343
346
// precisely one package, so that's why we're just creating a flat list
344
347
// of summaries which should be the same length as `deps` above.
345
348
346
- let mut deps_remaining : Vec < _ > = deps . iter ( ) . collect ( ) ;
349
+ let mut patch_deps_remaining : Vec < _ > = patch_deps . iter ( ) . collect ( ) ;
347
350
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 ;
352
355
353
356
// Use the locked patch if it exists, otherwise use the original.
354
357
let dep = match locked {
@@ -388,7 +391,7 @@ impl<'gctx> PackageRegistry<'gctx> {
388
391
let summaries = match source. query_vec ( dep, QueryKind :: Exact ) ? {
389
392
Poll :: Ready ( deps) => deps,
390
393
Poll :: Pending => {
391
- deps_pending . push ( dep_remaining ) ;
394
+ patch_deps_pending . push ( patch_dep_remaining ) ;
392
395
continue ;
393
396
}
394
397
} ;
@@ -399,7 +402,7 @@ impl<'gctx> PackageRegistry<'gctx> {
399
402
match summary_for_patch ( orig_patch, & locked, summaries, source) {
400
403
Poll :: Ready ( x) => x,
401
404
Poll :: Pending => {
402
- deps_pending . push ( dep_remaining ) ;
405
+ patch_deps_pending . push ( patch_dep_remaining ) ;
403
406
continue ;
404
407
}
405
408
}
@@ -432,7 +435,7 @@ impl<'gctx> PackageRegistry<'gctx> {
432
435
unlocked_summaries. push ( summary) ;
433
436
}
434
437
435
- deps_remaining = deps_pending ;
438
+ patch_deps_remaining = patch_deps_pending ;
436
439
self . block_until_ready ( ) ?;
437
440
}
438
441
@@ -467,7 +470,7 @@ impl<'gctx> PackageRegistry<'gctx> {
467
470
// in the future, but for now it hopefully doesn't cause too much
468
471
// harm...
469
472
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 ) {
471
474
ids. push ( summary. package_id ( ) ) ;
472
475
if let Some ( lock) = lock {
473
476
ids. extend ( lock. alt_package_id ) ;
0 commit comments