Skip to content

Commit c7a1105

Browse files
committed
Fix another issue of poisoning too eagerly
This commit extends the fix in #5288 by moving the logic added farther up in the loop over package dependencies. This means that we won't recursively look at optional/dev path dependencies which aren't members of the workspace. This should fix the new issue that came up in #5257 Closes #5257
1 parent d83f113 commit c7a1105

File tree

2 files changed

+75
-16
lines changed

2 files changed

+75
-16
lines changed

src/cargo/ops/resolve.rs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -445,21 +445,6 @@ fn register_previous_locks<'a>(
445445
continue;
446446
}
447447
for dep in member.dependencies() {
448-
let source = dep.source_id();
449-
450-
// If this is a path dependency then try to push it onto our
451-
// worklist
452-
if let Some(pkg) = path_pkg(source) {
453-
path_deps.push(pkg);
454-
continue;
455-
}
456-
457-
// If we match *anything* in the dependency graph then we consider
458-
// ourselves A-OK and assume that we'll resolve to that.
459-
if resolve.iter().any(|id| dep.matches_ignoring_source(id)) {
460-
continue;
461-
}
462-
463448
// If this dependency didn't match anything special then we may want
464449
// to poison the source as it may have been added. If this path
465450
// dependencies is *not* a workspace member, however, and it's an
@@ -479,9 +464,26 @@ fn register_previous_locks<'a>(
479464
continue;
480465
}
481466

467+
// If this is a path dependency then try to push it onto our
468+
// worklist
469+
if let Some(pkg) = path_pkg(dep.source_id()) {
470+
path_deps.push(pkg);
471+
continue;
472+
}
473+
474+
// If we match *anything* in the dependency graph then we consider
475+
// ourselves A-OK and assume that we'll resolve to that.
476+
if resolve.iter().any(|id| dep.matches_ignoring_source(id)) {
477+
continue;
478+
}
479+
482480
// Ok if nothing matches, then we poison the source of this
483481
// dependencies and the previous lock file.
484-
for id in resolve.iter().filter(|id| id.source_id() == source) {
482+
debug!("poisoning {} because {} looks like it changed {}",
483+
dep.source_id(),
484+
member.package_id(),
485+
dep.name());
486+
for id in resolve.iter().filter(|id| id.source_id() == dep.source_id()) {
485487
add_deps(resolve, id, &mut avoid_locking);
486488
}
487489
}

tests/testsuite/freshness.rs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,3 +1065,60 @@ fn unused_optional_dep() {
10651065
execs().with_status(0).with_stderr("[FINISHED] [..]"),
10661066
);
10671067
}
1068+
1069+
#[test]
1070+
fn path_dev_dep_registry_updates() {
1071+
Package::new("registry1", "0.1.0").publish();
1072+
Package::new("registry2", "0.1.0").publish();
1073+
1074+
let p = project("p")
1075+
.file(
1076+
"Cargo.toml",
1077+
r#"
1078+
[package]
1079+
name = "p"
1080+
authors = []
1081+
version = "0.1.0"
1082+
1083+
[dependencies]
1084+
foo = { path = "foo" }
1085+
"#,
1086+
)
1087+
.file("src/lib.rs", "")
1088+
.file(
1089+
"foo/Cargo.toml",
1090+
r#"
1091+
[package]
1092+
name = "foo"
1093+
version = "0.1.1"
1094+
authors = []
1095+
1096+
[dependencies]
1097+
registry1 = "*"
1098+
1099+
[dev-dependencies]
1100+
bar = { path = "../bar"}
1101+
"#,
1102+
)
1103+
.file("foo/src/lib.rs", "")
1104+
.file(
1105+
"bar/Cargo.toml",
1106+
r#"
1107+
[package]
1108+
name = "bar"
1109+
version = "0.1.1"
1110+
authors = []
1111+
1112+
[dependencies]
1113+
registry2 = "*"
1114+
"#,
1115+
)
1116+
.file("bar/src/lib.rs", "")
1117+
.build();
1118+
1119+
assert_that(p.cargo("build"), execs().with_status(0));
1120+
assert_that(
1121+
p.cargo("build"),
1122+
execs().with_status(0).with_stderr("[FINISHED] [..]"),
1123+
);
1124+
}

0 commit comments

Comments
 (0)