Skip to content

Commit ea27499

Browse files
committed
review comments
1 parent dc449bc commit ea27499

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/cargo/ops/common_for_install_and_uninstall.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -616,9 +616,10 @@ where
616616
let examples = candidates
617617
.iter()
618618
.filter(|cand| cand.targets().iter().filter(|t| t.is_example()).count() > 0);
619-
let pkg = match one(binaries, |v| multi_err("binaries", source, v))? {
619+
let git_url = source.source_id().url().to_string();
620+
let pkg = match one(binaries, |v| multi_err("binaries", &git_url, v))? {
620621
Some(p) => p,
621-
None => match one(examples, |v| multi_err("examples", source, v))? {
622+
None => match one(examples, |v| multi_err("examples", &git_url, v))? {
622623
Some(p) => p,
623624
None => bail!(
624625
"no packages found with binaries or \
@@ -629,12 +630,9 @@ where
629630
Ok(pkg.clone())
630631
};
631632

632-
fn multi_err<T>(kind: &str, source: &T, mut pkgs: Vec<&Package>) -> String
633-
where
634-
T: Source,
635-
{
633+
fn multi_err(kind: &str, git_url: &str, mut pkgs: Vec<&Package>) -> String {
636634
pkgs.sort_unstable_by_key(|a| a.name());
637-
let first_pkg = pkgs.iter().nth(0).unwrap();
635+
let first_pkg = pkgs[0];
638636
format!(
639637
"multiple packages with {} found: {}. When installing a git repository, \
640638
cargo will always search the entire repo for any Cargo.toml.\n\
@@ -644,7 +642,7 @@ where
644642
.map(|p| p.name().as_str())
645643
.collect::<Vec<_>>()
646644
.join(", "),
647-
source.source_id().url().as_str(),
645+
git_url,
648646
first_pkg.name()
649647
)
650648
}

tests/testsuite/install.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ Available binaries:
560560
}
561561

562562
#[cargo_test]
563-
fn multiple_binaries_error() {
563+
fn multiple_packages_containing_binaries() {
564564
let p = git::repo(&paths::root().join("foo"))
565565
.file("Cargo.toml", &basic_manifest("foo", "0.1.0"))
566566
.file("src/main.rs", "fn main() {}")
@@ -584,7 +584,7 @@ Please specify a package, e.g. `cargo install --git {git_url} bar`.
584584
}
585585

586586
#[cargo_test]
587-
fn multiple_examples_error() {
587+
fn multiple_packages_matching_example() {
588588
let p = git::repo(&paths::root().join("foo"))
589589
.file("Cargo.toml", &basic_manifest("foo", "0.1.0"))
590590
.file("src/lib.rs", "")

0 commit comments

Comments
 (0)