@@ -13,7 +13,6 @@ use std::path::{Path, PathBuf};
13
13
use std:: str:: { self , FromStr } ;
14
14
use std:: sync:: LazyLock ;
15
15
use std:: { cmp, fmt, fs, iter} ;
16
-
17
16
use rustc_data_structures:: fx:: { FxHashSet , FxIndexMap } ;
18
17
use rustc_data_structures:: stable_hasher:: { StableOrd , ToStableHashKey } ;
19
18
use rustc_errors:: emitter:: HumanReadableErrorType ;
@@ -1296,6 +1295,29 @@ impl CrateType {
1296
1295
CrateType :: Executable | CrateType :: Cdylib | CrateType :: Staticlib => false ,
1297
1296
}
1298
1297
}
1298
+
1299
+ pub fn shorthand ( & self ) -> & ' static str {
1300
+ match * self {
1301
+ CrateType :: Executable => "bin" ,
1302
+ CrateType :: Dylib => "dylib" ,
1303
+ CrateType :: Rlib => "rlib" ,
1304
+ CrateType :: Staticlib => "lib" ,
1305
+ CrateType :: Cdylib => "cdylib" ,
1306
+ CrateType :: ProcMacro => "proc-macro" ,
1307
+ }
1308
+ }
1309
+
1310
+ fn shorthands_display ( ) -> String {
1311
+ format ! (
1312
+ "`{}`, `{}`, `{}`, `{}`, `{}`, `{}`" ,
1313
+ CrateType :: Executable . shorthand( ) ,
1314
+ CrateType :: Dylib . shorthand( ) ,
1315
+ CrateType :: Rlib . shorthand( ) ,
1316
+ CrateType :: Staticlib . shorthand( ) ,
1317
+ CrateType :: Cdylib . shorthand( ) ,
1318
+ CrateType :: ProcMacro . shorthand( ) ,
1319
+ )
1320
+ }
1299
1321
}
1300
1322
1301
1323
#[ derive( Clone , Hash , Debug , PartialEq , Eq ) ]
@@ -2678,7 +2700,7 @@ pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateTy
2678
2700
"cdylib" => CrateType :: Cdylib ,
2679
2701
"bin" => CrateType :: Executable ,
2680
2702
"proc-macro" => CrateType :: ProcMacro ,
2681
- _ => return Err ( format ! ( "unknown crate type: `{part}`" ) ) ,
2703
+ _ => return Err ( format ! ( "unknown crate type: `{part}` - expected one of: {display}" , display = CrateType :: shorthands_display ( ) ) ) ,
2682
2704
} ;
2683
2705
if !crate_types. contains ( & new_part) {
2684
2706
crate_types. push ( new_part)
0 commit comments