@@ -348,7 +348,7 @@ fn upgrade_dependency(
348
348
return Ok ( dependency) ;
349
349
}
350
350
351
- let Some ( new_req_string) = upgrade_requirement ( & current. to_string ( ) , latest) ? else {
351
+ let Some ( ( new_req_string, _ ) ) = upgrade_requirement ( & current. to_string ( ) , latest) ? else {
352
352
trace ! ( "skipping dependency `{name}` because the version requirement didn't change" ) ;
353
353
return Ok ( dependency) ;
354
354
} ;
@@ -369,8 +369,17 @@ fn upgrade_dependency(
369
369
Ok ( dep)
370
370
}
371
371
372
- /// Update manifests with upgraded versions, and write to disk. Based on cargo-edit.
373
- /// Returns true if any file has changed.
372
+ /// Update manifests with upgraded versions, and write to disk. Based on
373
+ /// cargo-edit. Returns true if any file has changed.
374
+ ///
375
+ /// Some of the checks here are duplicating checks already done in
376
+ /// upgrade_manifests/upgrade_dependency. Why? Let's say upgrade_dependency has
377
+ /// found that dependency foo was eligible for an upgrade. But foo can occur in
378
+ /// multiple manifest files, and even multiple times in the same manifest file,
379
+ /// and may be pinned, renamed, etc. in some of the instances. So we still need
380
+ /// to check here which dependencies to actually modify. So why not drop the
381
+ /// upgrade map and redo all checks here? Because then we'd have to query the
382
+ /// registries again to find the latest versions.
374
383
pub fn write_manifest_upgrades (
375
384
ws : & Workspace < ' _ > ,
376
385
upgrades : & UpgradeMap ,
@@ -407,6 +416,11 @@ pub fn write_manifest_upgrades(
407
416
) ?;
408
417
let name = & dependency. name ;
409
418
419
+ if let Some ( renamed_to) = dependency. rename {
420
+ trace ! ( "skipping dependency renamed from `{name}` to `{renamed_to}`" ) ;
421
+ continue ;
422
+ }
423
+
410
424
let Some ( current) = dependency. version ( ) else {
411
425
trace ! ( "skipping dependency without a version: {name}" ) ;
412
426
continue ;
@@ -424,13 +438,27 @@ pub fn write_manifest_upgrades(
424
438
continue ;
425
439
} ;
426
440
427
- let Some ( new_req_string) = upgrade_requirement ( current, latest) ? else {
441
+ let Some ( ( new_req_string, new_req ) ) = upgrade_requirement ( current, latest) ? else {
428
442
trace ! (
429
443
"skipping dependency `{name}` because the version requirement didn't change"
430
444
) ;
431
445
continue ;
432
446
} ;
433
447
448
+ let [ comparator] = & new_req. comparators [ ..] else {
449
+ trace ! (
450
+ "skipping dependency `{}` with multiple version comparators: {:?}" ,
451
+ name,
452
+ new_req. comparators
453
+ ) ;
454
+ continue ;
455
+ } ;
456
+
457
+ if comparator. op != Op :: Caret {
458
+ trace ! ( "skipping non-caret dependency `{}`: {}" , name, comparator) ;
459
+ continue ;
460
+ }
461
+
434
462
let mut dep = dependency. clone ( ) ;
435
463
let mut source = source. clone ( ) ;
436
464
source. version = new_req_string;
0 commit comments