diff --git a/src/cargo/ops/cargo_run.rs b/src/cargo/ops/cargo_run.rs index d95b0185176..6e8712ff09e 100644 --- a/src/cargo/ops/cargo_run.rs +++ b/src/cargo/ops/cargo_run.rs @@ -55,10 +55,11 @@ pub fn run( if bins.len() > 1 { if !options.filter.is_specific() { - let names: Vec<&str> = bins + let mut names: Vec<&str> = bins .into_iter() .map(|(_pkg, target)| target.name()) .collect(); + names.sort(); anyhow::bail!( "`cargo run` could not determine which binary to run. \ Use the `--bin` option to specify a binary, \ diff --git a/tests/testsuite/required_features.rs b/tests/testsuite/required_features.rs index eabc9aaf289..55f650d4b3d 100644 --- a/tests/testsuite/required_features.rs +++ b/tests/testsuite/required_features.rs @@ -1169,6 +1169,11 @@ fn run_default_multiple_required_features() { path = "src/foo1.rs" required-features = ["a"] + [[bin]] + name = "foo3" + path = "src/foo3.rs" + required-features = ["b"] + [[bin]] name = "foo2" path = "src/foo2.rs" @@ -1177,6 +1182,7 @@ fn run_default_multiple_required_features() { ) .file("src/lib.rs", "") .file("src/foo1.rs", "extern crate foo; fn main() {}") + .file("src/foo3.rs", "extern crate foo; fn main() {}") .file("src/foo2.rs", "extern crate foo; fn main() {}") .build(); @@ -1185,7 +1191,7 @@ fn run_default_multiple_required_features() { .with_stderr( "\ error: `cargo run` could not determine which binary to run[..] -available binaries: foo1, foo2", +available binaries: foo1, foo2, foo3", ) .run(); }