Skip to content

Commit 8378e32

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

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
@@ -991,14 +991,11 @@ rustdns.workspace = true
991991
p.change_file("Cargo.toml", &workspace_toml.replace("2.29.8", "2.29.81"));
992992

993993
p.cargo("update -p rootcrate")
994-
.with_stderr(&format!(
994+
.with_stderr(
995995
"\
996-
[UPDATING] git repository `{}`
997996
[UPDATING] rootcrate v2.29.8 ([CWD]/rootcrate) -> v2.29.81
998-
[UPDATING] rustdns v0.5.0 ([..]) -> [..]
999997
[UPDATING] subcrate v2.29.8 ([CWD]/subcrate) -> v2.29.81",
1000-
git_project.url(),
1001-
))
998+
)
1002999
.run();
10031000
}
10041001

0 commit comments

Comments
 (0)