Skip to content

Commit

Permalink
Display valid values in --crate-type
Browse files Browse the repository at this point in the history
  • Loading branch information
malezjaa committed Dec 29, 2024
1 parent 32c8a9f commit 0d5087d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
9 changes: 8 additions & 1 deletion compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2678,7 +2678,14 @@ 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: {display}",
display =
["lib", "rlib", "staticlib", "dylib", "cdylib", "bin", "proc-macro"]
.join(", ")
));
}
};
if !crate_types.contains(&new_part) {
crate_types.push(new_part)
Expand Down
4 changes: 4 additions & 0 deletions tests/ui/crate_type_flag.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 2 additions & 0 deletions tests/ui/crate_type_flag.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: unknown crate type: `dynlib`, expected one of: lib, rlib, staticlib, dylib, cdylib, bin, proc-macro

0 comments on commit 0d5087d

Please sign in to comment.