Skip to content

Commit 8a9d8bd

Browse files
authored
fix(package): Allow packaging of self-cycles with -Zpackage-workspace (#15626)
### What does this PR try to resolve? Found this as I was preparing for stabilization. As we create a graph of packages to ensure publish order, a self-cycle shouldn't matter, so we can skip tracking it. ### How to test and review this PR?
2 parents 762fbf9 + 876c9fb commit 8a9d8bd

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/cargo/ops/cargo_package/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,11 @@ fn local_deps<T>(packages: impl Iterator<Item = (Package, T)>) -> LocalDependenc
417417
continue;
418418
};
419419

420+
// We don't care about cycles
421+
if dep.source_id() == pkg.package_id().source_id() {
422+
continue;
423+
}
424+
420425
if let Some(dep_pkg) = source_to_pkg.get(&dep.source_id()) {
421426
graph.link(pkg.package_id(), *dep_pkg);
422427
}

tests/testsuite/package.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7560,6 +7560,39 @@ fn unpublished_cyclic_dev_dependencies() {
75607560
);
75617561
}
75627562

7563+
#[cargo_test]
7564+
fn unpublished_cyclic_dev_dependencies_nightly() {
7565+
registry::init();
7566+
let p = project()
7567+
.file(
7568+
"Cargo.toml",
7569+
r#"
7570+
[package]
7571+
name = "foo"
7572+
version = "0.0.1"
7573+
edition = "2015"
7574+
authors = []
7575+
license = "MIT"
7576+
description = "foo"
7577+
documentation = "foo"
7578+
7579+
[dev-dependencies]
7580+
foo = { path = ".", version = "0.0.1" }
7581+
"#,
7582+
)
7583+
.file("src/lib.rs", "")
7584+
.build();
7585+
7586+
p.cargo("package --no-verify --exclude-lockfile -Zpackage-workspace")
7587+
.masquerade_as_nightly_cargo(&["package-workspace"])
7588+
.with_stderr_data(str![[r#"
7589+
[PACKAGING] foo v0.0.1 ([ROOT]/foo)
7590+
[PACKAGED] 3 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
7591+
7592+
"#]])
7593+
.run();
7594+
}
7595+
75637596
// A failing case from <https://github.com/rust-lang/cargo/issues/15059>
75647597
#[cargo_test]
75657598
fn unpublished_dependency() {

0 commit comments

Comments
 (0)