@@ -1296,6 +1296,29 @@ impl CrateType {
1296
1296
CrateType :: Executable | CrateType :: Cdylib | CrateType :: Staticlib => false ,
1297
1297
}
1298
1298
}
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 :: Cdylib . shorthand( ) ,
1316
+ CrateType :: Dylib . shorthand( ) ,
1317
+ CrateType :: Staticlib . shorthand( ) ,
1318
+ CrateType :: ProcMacro . shorthand( ) ,
1319
+ CrateType :: Rlib . shorthand( ) ,
1320
+ )
1321
+ }
1299
1322
}
1300
1323
1301
1324
#[ derive( Clone , Hash , Debug , PartialEq , Eq ) ]
@@ -2678,7 +2701,12 @@ pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateTy
2678
2701
"cdylib" => CrateType :: Cdylib ,
2679
2702
"bin" => CrateType :: Executable ,
2680
2703
"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
+ }
2682
2710
} ;
2683
2711
if !crate_types. contains ( & new_part) {
2684
2712
crate_types. push ( new_part)
0 commit comments