mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-16 14:07:04 +00:00
Show valid crate types when the user passes unknown --crate-type
value
Co-authored-by: Jieyou Xu <jieyouxu@outlook.com>
This commit is contained in:
parent
523c507d26
commit
90bf2b159a
@ -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)
|
||||
|
4
tests/ui/crate_type_flag.rs
Normal file
4
tests/ui/crate_type_flag.rs
Normal file
@ -0,0 +1,4 @@
|
||||
//@ compile-flags: --crate-type dynlib
|
||||
//@ error-pattern: unknown crate type: `dynlib`, expected one of: `lib`, `rlib`, `staticlib`, `dylib`, `cdylib`, `bin`, `proc-macro`
|
||||
|
||||
fn main() {}
|
2
tests/ui/crate_type_flag.stderr
Normal file
2
tests/ui/crate_type_flag.stderr
Normal file
@ -0,0 +1,2 @@
|
||||
error: unknown crate type: `dynlib`, expected one of: `lib`, `rlib`, `staticlib`, `dylib`, `cdylib`, `bin`, `proc-macro`
|
||||
|
@ -1,2 +1,2 @@
|
||||
error: unknown crate type: ``
|
||||
error: unknown crate type: ``, expected one of: `lib`, `rlib`, `staticlib`, `dylib`, `cdylib`, `bin`, `proc-macro`
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
error: unknown crate type: `proc_macro`
|
||||
error: unknown crate type: `proc_macro`, expected one of: `lib`, `rlib`, `staticlib`, `dylib`, `cdylib`, `bin`, `proc-macro`
|
||||
|
||||
|
@ -45,16 +45,16 @@
|
||||
// `proc-macro` is accepted, but `proc_macro` is not.
|
||||
//@ revisions: proc_underscore_macro
|
||||
//@[proc_underscore_macro] compile-flags: --crate-type=proc_macro
|
||||
//@[proc_underscore_macro] error-pattern: "unknown crate type: `proc_macro`"
|
||||
//@[proc_underscore_macro] error-pattern: unknown crate type: `proc_macro`
|
||||
|
||||
// Empty `--crate-type` not accepted.
|
||||
//@ revisions: empty_crate_type
|
||||
//@[empty_crate_type] compile-flags: --crate-type=
|
||||
//@[empty_crate_type] error-pattern: "unknown crate type: ``"
|
||||
//@[empty_crate_type] error-pattern: unknown crate type: ``
|
||||
|
||||
// Random unknown crate type. Also check that we can handle non-ASCII.
|
||||
//@ revisions: unknown
|
||||
//@[unknown] compile-flags: --crate-type=🤡
|
||||
//@[unknown] error-pattern: "unknown crate type: `🤡`"
|
||||
//@[unknown] error-pattern: unknown crate type: `🤡`
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,2 +1,2 @@
|
||||
error: unknown crate type: `🤡`
|
||||
error: unknown crate type: `🤡`, expected one of: `lib`, `rlib`, `staticlib`, `dylib`, `cdylib`, `bin`, `proc-macro`
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user