mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
fix(rustc): Don't panic on unknown bins
This takes the most surgical, direct route to addressing the problem. Alternatively, we could look into why `cargo rustc` and `cargo check` are different. Fixes #15493
This commit is contained in:
parent
981ea84bdc
commit
f83e11acfe
@ -296,16 +296,11 @@ impl<'a> UnitGenerator<'a, '_> {
|
||||
Packages::Default | Packages::OptOut(_) | Packages::All(_) => {
|
||||
" in default-run packages".to_owned()
|
||||
}
|
||||
Packages::Packages(packages) => {
|
||||
let first = packages
|
||||
.first()
|
||||
.expect("The number of packages must be at least 1");
|
||||
if packages.len() == 1 {
|
||||
format!(" in `{}` package", first)
|
||||
} else {
|
||||
format!(" in `{}`, ... packages", first)
|
||||
}
|
||||
}
|
||||
Packages::Packages(packages) => match packages.len() {
|
||||
0 => String::new(),
|
||||
1 => format!(" in `{}` package", packages[0]),
|
||||
_ => format!(" in `{}`, ... packages", packages[0]),
|
||||
},
|
||||
};
|
||||
|
||||
let named = if is_glob { "matches pattern" } else { "named" };
|
||||
|
@ -547,9 +547,9 @@ fn fail_with_bad_bin_no_package() {
|
||||
p.cargo("rustc --bin main")
|
||||
.with_status(101)
|
||||
.with_stderr_data(str![[r#"
|
||||
|
||||
thread 'main' panicked [..]:
|
||||
The number of packages must be at least 1
|
||||
[ERROR] no bin target named `main`
|
||||
[HELP] available bin targets:
|
||||
foo
|
||||
...
|
||||
|
||||
"#]])
|
||||
|
Loading…
x
Reference in New Issue
Block a user