Skip to content

Commit

Permalink
Auto merge of #10701 - danilhendrasr:master, r=weihanglo
Browse files Browse the repository at this point in the history
Emit warning upon encountering multiple packages with the same name

Fixes: #10669
  • Loading branch information
bors committed May 31, 2022
2 parents ca4edab + e903f7d commit 38472bc
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/cargo/ops/cargo_read_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,11 @@ fn read_nested_packages(
v.insert(pkg);
}
Entry::Occupied(_) => {
info!(
"skipping nested package `{}` found at `{}`",
let _ = config.shell().warn(format!(
"skipping duplicate package `{}` found at `{}`",
pkg.name(),
path.to_string_lossy()
);
));
}
}

Expand Down
46 changes: 46 additions & 0 deletions tests/testsuite/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,52 @@ Caused by:
.run();
}

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

let p = project
.file(
"Cargo.toml",
&format!(
r#"
[project]
name = "foo"
version = "0.5.0"
authors = ["[email protected]"]
[dependencies.bar]
git = '{}'
"#,
git_project.url()
),
)
.file("src/main.rs", "fn main() { }")
.build();

p.cargo("build").run();
p.cargo("run")
.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]`
",
)
.run();
}

#[cargo_test]
fn two_deps_only_update_one() {
let project = project();
Expand Down
1 change: 1 addition & 0 deletions tests/testsuite/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,7 @@ fn override_and_depend() {
.cwd("b")
.with_stderr(
"\
[WARNING] skipping duplicate package `a2` found at `[..]`
[COMPILING] a2 v0.5.0 ([..])
[COMPILING] a1 v0.5.0 ([..])
[COMPILING] b v0.5.0 ([..])
Expand Down

0 comments on commit 38472bc

Please sign in to comment.