Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict duplicate deps warning only to published packages #10767

Merged
merged 1 commit into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/cargo/ops/cargo_read_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,16 @@ fn read_nested_packages(
v.insert(pkg);
}
Entry::Occupied(_) => {
let _ = config.shell().warn(format!(
"skipping duplicate package `{}` found at `{}`",
pkg.name(),
path.to_string_lossy()
));
// We can assume a package with publish = false isn't intended to be seen
// by users so we can hide the warning about those since the user is unlikely
// to care about those cases.
if pkg.publish().is_none() {
let _ = config.shell().warn(format!(
"skipping duplicate package `{}` found at `{}`",
pkg.name(),
path.display()
));
}
}
}

Expand Down
29 changes: 23 additions & 6 deletions tests/testsuite/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1078,16 +1078,34 @@ fn dep_with_skipped_submodule() {
}

#[cargo_test]
fn dep_ambiguous() {
fn ambiguous_published_deps() {
let project = project();
let git_project = git::new("dep", |project| {
project
.file("aaa/Cargo.toml", &basic_manifest("bar", "0.5.0"))
.file(
"aaa/Cargo.toml",
&format!(
r#"
[project]
name = "bar"
version = "0.5.0"
publish = true
"#
),
)
.file("aaa/src/lib.rs", "")
.file("bbb/Cargo.toml", &basic_manifest("bar", "0.5.0"))
.file(
"bbb/Cargo.toml",
&format!(
r#"
[project]
name = "bar"
version = "0.5.0"
publish = true
"#
),
)
.file("bbb/src/lib.rs", "")
.file("ccc/Cargo.toml", &basic_manifest("bar", "0.5.0"))
.file("ccc/src/lib.rs", "")
});

let p = project
Expand Down Expand Up @@ -1115,7 +1133,6 @@ fn dep_ambiguous() {
.with_stderr(
"\
[WARNING] skipping duplicate package `bar` found at `[..]`
[WARNING] skipping duplicate package `bar` found at `[..]`
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
[RUNNING] `target/debug/foo[EXE]`
",
Expand Down