Skip to content

Commit c9d8c28

Browse files
committed
Auto merge of #10767 - danilhendrasr:master, r=epage
Restrict duplicate deps warning only to published packages Fixes #10752
2 parents 5db8295 + 08d1018 commit c9d8c28

File tree

2 files changed

+33
-11
lines changed

2 files changed

+33
-11
lines changed

src/cargo/ops/cargo_read_manifest.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,16 @@ fn read_nested_packages(
183183
v.insert(pkg);
184184
}
185185
Entry::Occupied(_) => {
186-
let _ = config.shell().warn(format!(
187-
"skipping duplicate package `{}` found at `{}`",
188-
pkg.name(),
189-
path.to_string_lossy()
190-
));
186+
// We can assume a package with publish = false isn't intended to be seen
187+
// by users so we can hide the warning about those since the user is unlikely
188+
// to care about those cases.
189+
if pkg.publish().is_none() {
190+
let _ = config.shell().warn(format!(
191+
"skipping duplicate package `{}` found at `{}`",
192+
pkg.name(),
193+
path.display()
194+
));
195+
}
191196
}
192197
}
193198

tests/testsuite/git.rs

+23-6
Original file line numberDiff line numberDiff line change
@@ -1078,16 +1078,34 @@ fn dep_with_skipped_submodule() {
10781078
}
10791079

10801080
#[cargo_test]
1081-
fn dep_ambiguous() {
1081+
fn ambiguous_published_deps() {
10821082
let project = project();
10831083
let git_project = git::new("dep", |project| {
10841084
project
1085-
.file("aaa/Cargo.toml", &basic_manifest("bar", "0.5.0"))
1085+
.file(
1086+
"aaa/Cargo.toml",
1087+
&format!(
1088+
r#"
1089+
[project]
1090+
name = "bar"
1091+
version = "0.5.0"
1092+
publish = true
1093+
"#
1094+
),
1095+
)
10861096
.file("aaa/src/lib.rs", "")
1087-
.file("bbb/Cargo.toml", &basic_manifest("bar", "0.5.0"))
1097+
.file(
1098+
"bbb/Cargo.toml",
1099+
&format!(
1100+
r#"
1101+
[project]
1102+
name = "bar"
1103+
version = "0.5.0"
1104+
publish = true
1105+
"#
1106+
),
1107+
)
10881108
.file("bbb/src/lib.rs", "")
1089-
.file("ccc/Cargo.toml", &basic_manifest("bar", "0.5.0"))
1090-
.file("ccc/src/lib.rs", "")
10911109
});
10921110

10931111
let p = project
@@ -1115,7 +1133,6 @@ fn dep_ambiguous() {
11151133
.with_stderr(
11161134
"\
11171135
[WARNING] skipping duplicate package `bar` found at `[..]`
1118-
[WARNING] skipping duplicate package `bar` found at `[..]`
11191136
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
11201137
[RUNNING] `target/debug/foo[EXE]`
11211138
",

0 commit comments

Comments
 (0)