Skip to content

Commit

Permalink
Auto merge of #10767 - danilhendrasr:master, r=epage
Browse files Browse the repository at this point in the history
Restrict duplicate deps warning only to published packages

Fixes #10752
  • Loading branch information
bors committed Jun 21, 2022
2 parents 5db8295 + 08d1018 commit c9d8c28
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
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

0 comments on commit c9d8c28

Please sign in to comment.