@@ -1296,6 +1296,29 @@ impl CrateType {
12961296 CrateType :: Executable | CrateType :: Cdylib | CrateType :: Staticlib => false ,
12971297 }
12981298 }
1299+
1300+ pub fn shorthand ( & self ) -> & ' static str {
1301+ match * self {
1302+ CrateType :: Executable => "bin" ,
1303+ CrateType :: Dylib => "dylib" ,
1304+ CrateType :: Rlib => "rlib" ,
1305+ CrateType :: Staticlib => "lib" ,
1306+ CrateType :: Cdylib => "cdylib" ,
1307+ CrateType :: ProcMacro => "proc-macro" ,
1308+ }
1309+ }
1310+
1311+ fn shorthands_display ( ) -> String {
1312+ format ! (
1313+ "`{}`, `{}`, `{}`, `{}`, `{}`, `{}`" ,
1314+ CrateType :: Executable . shorthand( ) ,
1315+ CrateType :: Dylib . shorthand( ) ,
1316+ CrateType :: Rlib . shorthand( ) ,
1317+ CrateType :: Staticlib . shorthand( ) ,
1318+ CrateType :: Cdylib . shorthand( ) ,
1319+ CrateType :: ProcMacro . shorthand( ) ,
1320+ )
1321+ }
12991322}
13001323
13011324#[ derive( Clone , Hash , Debug , PartialEq , Eq ) ]
@@ -2678,7 +2701,12 @@ pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateTy
26782701 "cdylib" => CrateType :: Cdylib ,
26792702 "bin" => CrateType :: Executable ,
26802703 "proc-macro" => CrateType :: ProcMacro ,
2681- _ => return Err ( format ! ( "unknown crate type: `{part}`" ) ) ,
2704+ _ => {
2705+ return Err ( format ! (
2706+ "unknown crate type: `{part}` - expected one of: {display}" ,
2707+ display = CrateType :: shorthands_display( )
2708+ ) ) ;
2709+ }
26822710 } ;
26832711 if !crate_types. contains ( & new_part) {
26842712 crate_types. push ( new_part)
0 commit comments