diff --git a/src/cargo/ops/cargo_read_manifest.rs b/src/cargo/ops/cargo_read_manifest.rs index aee5897d086..2dfe900860f 100644 --- a/src/cargo/ops/cargo_read_manifest.rs +++ b/src/cargo/ops/cargo_read_manifest.rs @@ -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() + )); + } } } diff --git a/tests/testsuite/git.rs b/tests/testsuite/git.rs index 54dd8dcb05d..96cabeed231 100644 --- a/tests/testsuite/git.rs +++ b/tests/testsuite/git.rs @@ -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 @@ -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]` ",