Skip to content

Commit b27debc

Browse files
committed
fix(resolver): Make resolver behavior independent or package order
This address one of the problems mentioned in #12599
1 parent f87928a commit b27debc

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/cargo/ops/resolve.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,15 +642,19 @@ fn register_previous_locks(
642642
// if they changed.
643643
let mut avoid_locking = HashSet::new();
644644
registry.add_to_yanked_whitelist(resolve.iter().filter(keep));
645+
// We must check `path_pkg` first so we don't recursively walk them via `add_deps`
645646
for node in resolve.iter() {
646-
if !keep(&node) {
647-
add_deps(resolve, node, &mut avoid_locking);
648-
} else if let Some(pkg) = path_pkg(node.source_id()) {
647+
if let Some(pkg) = path_pkg(node.source_id()) {
649648
if pkg.package_id() != node {
650649
avoid_locking.insert(node);
651650
}
652651
}
653652
}
653+
for node in resolve.iter() {
654+
if !keep(&node) {
655+
add_deps(resolve, node, &mut avoid_locking);
656+
}
657+
}
654658

655659
// Ok, but the above loop isn't the entire story! Updates to the dependency
656660
// graph can come from two locations, the `cargo update` command or

tests/testsuite/update.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -954,14 +954,11 @@ rustdns.workspace = true
954954
p.change_file("Cargo.toml", &workspace_toml.replace("2.29.8", "2.29.81"));
955955

956956
p.cargo("update -p rootcrate")
957-
.with_stderr(&format!(
957+
.with_stderr(
958958
"\
959-
[UPDATING] git repository `{}`
960959
[UPDATING] rootcrate v2.29.8 ([CWD]/rootcrate) -> v2.29.81
961-
[UPDATING] rustdns v0.5.0 ([..]) -> [..]
962960
[UPDATING] subcrate v2.29.8 ([CWD]/subcrate) -> v2.29.81",
963-
git_project.url(),
964-
))
961+
)
965962
.run();
966963
}
967964

0 commit comments

Comments
 (0)