Skip to content

Commit 38472bc

Browse files
committed
Auto merge of #10701 - danilhendrasr:master, r=weihanglo
Emit warning upon encountering multiple packages with the same name Fixes: #10669
2 parents ca4edab + e903f7d commit 38472bc

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

src/cargo/ops/cargo_read_manifest.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,11 @@ fn read_nested_packages(
183183
v.insert(pkg);
184184
}
185185
Entry::Occupied(_) => {
186-
info!(
187-
"skipping nested package `{}` found at `{}`",
186+
let _ = config.shell().warn(format!(
187+
"skipping duplicate package `{}` found at `{}`",
188188
pkg.name(),
189189
path.to_string_lossy()
190-
);
190+
));
191191
}
192192
}
193193

tests/testsuite/git.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,52 @@ Caused by:
10231023
.run();
10241024
}
10251025

1026+
#[cargo_test]
1027+
fn dep_ambiguous() {
1028+
let project = project();
1029+
let git_project = git::new("dep", |project| {
1030+
project
1031+
.file("aaa/Cargo.toml", &basic_manifest("bar", "0.5.0"))
1032+
.file("aaa/src/lib.rs", "")
1033+
.file("bbb/Cargo.toml", &basic_manifest("bar", "0.5.0"))
1034+
.file("bbb/src/lib.rs", "")
1035+
.file("ccc/Cargo.toml", &basic_manifest("bar", "0.5.0"))
1036+
.file("ccc/src/lib.rs", "")
1037+
});
1038+
1039+
let p = project
1040+
.file(
1041+
"Cargo.toml",
1042+
&format!(
1043+
r#"
1044+
[project]
1045+
1046+
name = "foo"
1047+
version = "0.5.0"
1048+
authors = ["wycats@example.com"]
1049+
1050+
[dependencies.bar]
1051+
git = '{}'
1052+
"#,
1053+
git_project.url()
1054+
),
1055+
)
1056+
.file("src/main.rs", "fn main() { }")
1057+
.build();
1058+
1059+
p.cargo("build").run();
1060+
p.cargo("run")
1061+
.with_stderr(
1062+
"\
1063+
[WARNING] skipping duplicate package `bar` found at `[..]`
1064+
[WARNING] skipping duplicate package `bar` found at `[..]`
1065+
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
1066+
[RUNNING] `target/debug/foo[EXE]`
1067+
",
1068+
)
1069+
.run();
1070+
}
1071+
10261072
#[cargo_test]
10271073
fn two_deps_only_update_one() {
10281074
let project = project();

tests/testsuite/path.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,7 @@ fn override_and_depend() {
870870
.cwd("b")
871871
.with_stderr(
872872
"\
873+
[WARNING] skipping duplicate package `a2` found at `[..]`
873874
[COMPILING] a2 v0.5.0 ([..])
874875
[COMPILING] a1 v0.5.0 ([..])
875876
[COMPILING] b v0.5.0 ([..])

0 commit comments

Comments
 (0)