@@ -387,6 +387,7 @@ pub fn resolve_with_previous<'gctx>(
387
387
register_previous_locks ( ws, registry, r, & keep, dev_deps) ;
388
388
389
389
// Prefer to use anything in the previous lock file, aka we want to have conservative updates.
390
+ let _span = tracing:: span!( tracing:: Level :: TRACE , "prefer_package_id" ) . entered ( ) ;
390
391
for id in r. iter ( ) . filter ( keep) {
391
392
debug ! ( "attempting to prefer {}" , id) ;
392
393
version_prefs. prefer_package_id ( id) ;
@@ -397,20 +398,22 @@ pub fn resolve_with_previous<'gctx>(
397
398
registry. lock_patches ( ) ;
398
399
}
399
400
400
- let summaries: Vec < ( Summary , ResolveOpts ) > = ws
401
- . members_with_features ( specs, cli_features) ?
402
- . into_iter ( )
403
- . map ( |( member, features) | {
404
- let summary = registry. lock ( member. summary ( ) . clone ( ) ) ;
405
- (
406
- summary,
407
- ResolveOpts {
408
- dev_deps,
409
- features : RequestedFeatures :: CliFeatures ( features) ,
410
- } ,
411
- )
412
- } )
413
- . collect ( ) ;
401
+ let summaries: Vec < ( Summary , ResolveOpts ) > = {
402
+ let _span = tracing:: span!( tracing:: Level :: TRACE , "registry.lock" ) . entered ( ) ;
403
+ ws. members_with_features ( specs, cli_features) ?
404
+ . into_iter ( )
405
+ . map ( |( member, features) | {
406
+ let summary = registry. lock ( member. summary ( ) . clone ( ) ) ;
407
+ (
408
+ summary,
409
+ ResolveOpts {
410
+ dev_deps,
411
+ features : RequestedFeatures :: CliFeatures ( features) ,
412
+ } ,
413
+ )
414
+ } )
415
+ . collect ( )
416
+ } ;
414
417
415
418
let replace = lock_replacements ( ws, previous, & keep) ;
416
419
@@ -498,6 +501,7 @@ pub fn get_resolved_packages<'gctx>(
498
501
///
499
502
/// Note that this function, at the time of this writing, is basically the
500
503
/// entire fix for issue #4127.
504
+ #[ tracing:: instrument( skip_all) ]
501
505
fn register_previous_locks (
502
506
ws : & Workspace < ' _ > ,
503
507
registry : & mut PackageRegistry < ' _ > ,
@@ -578,60 +582,63 @@ fn register_previous_locks(
578
582
// crates from crates.io* are not locked (aka added to `avoid_locking`).
579
583
// For dependencies like `log` their previous version in the lock file will
580
584
// come up first before newer version, if newer version are available.
581
- let mut path_deps = ws. members ( ) . cloned ( ) . collect :: < Vec < _ > > ( ) ;
582
- let mut visited = HashSet :: new ( ) ;
583
- while let Some ( member) = path_deps. pop ( ) {
584
- if !visited. insert ( member. package_id ( ) ) {
585
- continue ;
586
- }
587
- let is_ws_member = ws. is_member ( & member) ;
588
- for dep in member. dependencies ( ) {
589
- // If this dependency didn't match anything special then we may want
590
- // to poison the source as it may have been added. If this path
591
- // dependencies is **not** a workspace member, however, and it's an
592
- // optional/non-transitive dependency then it won't be necessarily
593
- // be in our lock file. If this shows up then we avoid poisoning
594
- // this source as otherwise we'd repeatedly update the registry.
595
- //
596
- // TODO: this breaks adding an optional dependency in a
597
- // non-workspace member and then simultaneously editing the
598
- // dependency on that crate to enable the feature. For now,
599
- // this bug is better than the always-updating registry though.
600
- if !is_ws_member && ( dep. is_optional ( ) || !dep. is_transitive ( ) ) {
585
+ {
586
+ let _span = tracing:: span!( tracing:: Level :: TRACE , "poison" ) . entered ( ) ;
587
+ let mut path_deps = ws. members ( ) . cloned ( ) . collect :: < Vec < _ > > ( ) ;
588
+ let mut visited = HashSet :: new ( ) ;
589
+ while let Some ( member) = path_deps. pop ( ) {
590
+ if !visited. insert ( member. package_id ( ) ) {
601
591
continue ;
602
592
}
593
+ let is_ws_member = ws. is_member ( & member) ;
594
+ for dep in member. dependencies ( ) {
595
+ // If this dependency didn't match anything special then we may want
596
+ // to poison the source as it may have been added. If this path
597
+ // dependencies is **not** a workspace member, however, and it's an
598
+ // optional/non-transitive dependency then it won't be necessarily
599
+ // be in our lock file. If this shows up then we avoid poisoning
600
+ // this source as otherwise we'd repeatedly update the registry.
601
+ //
602
+ // TODO: this breaks adding an optional dependency in a
603
+ // non-workspace member and then simultaneously editing the
604
+ // dependency on that crate to enable the feature. For now,
605
+ // this bug is better than the always-updating registry though.
606
+ if !is_ws_member && ( dep. is_optional ( ) || !dep. is_transitive ( ) ) {
607
+ continue ;
608
+ }
603
609
604
- // If dev-dependencies aren't being resolved, skip them.
605
- if !dep. is_transitive ( ) && !dev_deps {
606
- continue ;
607
- }
610
+ // If dev-dependencies aren't being resolved, skip them.
611
+ if !dep. is_transitive ( ) && !dev_deps {
612
+ continue ;
613
+ }
608
614
609
- // If this is a path dependency, then try to push it onto our
610
- // worklist.
611
- if let Some ( pkg) = path_pkg ( dep. source_id ( ) ) {
612
- path_deps. push ( pkg) ;
613
- continue ;
614
- }
615
+ // If this is a path dependency, then try to push it onto our
616
+ // worklist.
617
+ if let Some ( pkg) = path_pkg ( dep. source_id ( ) ) {
618
+ path_deps. push ( pkg) ;
619
+ continue ;
620
+ }
615
621
616
- // If we match *anything* in the dependency graph then we consider
617
- // ourselves all ok, and assume that we'll resolve to that.
618
- if resolve. iter ( ) . any ( |id| dep. matches_ignoring_source ( id) ) {
619
- continue ;
620
- }
622
+ // If we match *anything* in the dependency graph then we consider
623
+ // ourselves all ok, and assume that we'll resolve to that.
624
+ if resolve. iter ( ) . any ( |id| dep. matches_ignoring_source ( id) ) {
625
+ continue ;
626
+ }
621
627
622
- // Ok if nothing matches, then we poison the source of these
623
- // dependencies and the previous lock file.
624
- debug ! (
625
- "poisoning {} because {} looks like it changed {}" ,
626
- dep. source_id( ) ,
627
- member. package_id( ) ,
628
- dep. package_name( )
629
- ) ;
630
- for id in resolve
631
- . iter ( )
632
- . filter ( |id| id. source_id ( ) == dep. source_id ( ) )
633
- {
634
- add_deps ( resolve, id, & mut avoid_locking) ;
628
+ // Ok if nothing matches, then we poison the source of these
629
+ // dependencies and the previous lock file.
630
+ debug ! (
631
+ "poisoning {} because {} looks like it changed {}" ,
632
+ dep. source_id( ) ,
633
+ member. package_id( ) ,
634
+ dep. package_name( )
635
+ ) ;
636
+ for id in resolve
637
+ . iter ( )
638
+ . filter ( |id| id. source_id ( ) == dep. source_id ( ) )
639
+ {
640
+ add_deps ( resolve, id, & mut avoid_locking) ;
641
+ }
635
642
}
636
643
}
637
644
}
@@ -661,28 +668,31 @@ fn register_previous_locks(
661
668
let keep = |id : & PackageId | keep ( id) && !avoid_locking. contains ( id) ;
662
669
663
670
registry. clear_lock ( ) ;
664
- for node in resolve. iter ( ) . filter ( keep) {
665
- let deps = resolve
666
- . deps_not_replaced ( node)
667
- . map ( |p| p. 0 )
668
- . filter ( keep)
669
- . collect :: < Vec < _ > > ( ) ;
670
-
671
- // In the v2 lockfile format and prior the `branch=master` dependency
672
- // directive was serialized the same way as the no-branch-listed
673
- // directive. Nowadays in Cargo, however, these two directives are
674
- // considered distinct and are no longer represented the same way. To
675
- // maintain compatibility with older lock files we register locked nodes
676
- // for *both* the master branch and the default branch.
677
- //
678
- // Note that this is only applicable for loading older resolves now at
679
- // this point. All new lock files are encoded as v3-or-later, so this is
680
- // just compat for loading an old lock file successfully.
681
- if let Some ( node) = master_branch_git_source ( node, resolve) {
682
- registry. register_lock ( node, deps. clone ( ) ) ;
683
- }
671
+ {
672
+ let _span = tracing:: span!( tracing:: Level :: TRACE , "register_lock" ) . entered ( ) ;
673
+ for node in resolve. iter ( ) . filter ( keep) {
674
+ let deps = resolve
675
+ . deps_not_replaced ( node)
676
+ . map ( |p| p. 0 )
677
+ . filter ( keep)
678
+ . collect :: < Vec < _ > > ( ) ;
679
+
680
+ // In the v2 lockfile format and prior the `branch=master` dependency
681
+ // directive was serialized the same way as the no-branch-listed
682
+ // directive. Nowadays in Cargo, however, these two directives are
683
+ // considered distinct and are no longer represented the same way. To
684
+ // maintain compatibility with older lock files we register locked nodes
685
+ // for *both* the master branch and the default branch.
686
+ //
687
+ // Note that this is only applicable for loading older resolves now at
688
+ // this point. All new lock files are encoded as v3-or-later, so this is
689
+ // just compat for loading an old lock file successfully.
690
+ if let Some ( node) = master_branch_git_source ( node, resolve) {
691
+ registry. register_lock ( node, deps. clone ( ) ) ;
692
+ }
684
693
685
- registry. register_lock ( node, deps) ;
694
+ registry. register_lock ( node, deps) ;
695
+ }
686
696
}
687
697
688
698
/// Recursively add `node` and all its transitive dependencies to `set`.
0 commit comments