Rollup merge of #134720 - malezjaa:feat/crate-type-valid-values, r=jieyouxu
Display valid crate types in error message for --crate-type flag This PR improves the error message for the --crate-type flag. When an invalid crate type is provided, the compiler will now show a list of valid options. ### Before  ### After  I based the implementation on `OutputType::shorthands_display` Closes #70183
This commit is contained in:
commit
f8842bd752
7 changed files with 18 additions and 7 deletions
|
@ -2709,7 +2709,12 @@ pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateTy
|
|||
"cdylib" => CrateType::Cdylib,
|
||||
"bin" => CrateType::Executable,
|
||||
"proc-macro" => CrateType::ProcMacro,
|
||||
_ => return Err(format!("unknown crate type: `{part}`")),
|
||||
_ => {
|
||||
return Err(format!(
|
||||
"unknown crate type: `{part}`, expected one of: \
|
||||
`lib`, `rlib`, `staticlib`, `dylib`, `cdylib`, `bin`, `proc-macro`",
|
||||
));
|
||||
}
|
||||
};
|
||||
if !crate_types.contains(&new_part) {
|
||||
crate_types.push(new_part)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue