@@ -1296,7 +1296,7 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
1296
1296
} ;
1297
1297
1298
1298
let unparsed_crate_types = matches. opt_strs ( "crate-type" ) ;
1299
- let crate_types = parse_crate_types_from_list ( unparsed_crate_types)
1299
+ let ( crate_types, emit_metadata ) = parse_crate_types_from_list ( unparsed_crate_types)
1300
1300
. unwrap_or_else ( |e| early_error ( error_format, & e[ ..] ) ) ;
1301
1301
1302
1302
let mut lint_opts = vec ! [ ] ;
@@ -1343,7 +1343,9 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
1343
1343
}
1344
1344
}
1345
1345
} ;
1346
- if output_types. is_empty ( ) {
1346
+ if emit_metadata {
1347
+ output_types. insert ( OutputType :: Metadata , None ) ;
1348
+ } else if output_types. is_empty ( ) {
1347
1349
output_types. insert ( OutputType :: Exe , None ) ;
1348
1350
}
1349
1351
@@ -1545,8 +1547,10 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
1545
1547
cfg)
1546
1548
}
1547
1549
1548
- pub fn parse_crate_types_from_list ( list_list : Vec < String > ) -> Result < Vec < CrateType > , String > {
1550
+ pub fn parse_crate_types_from_list ( list_list : Vec < String > )
1551
+ -> Result < ( Vec < CrateType > , bool ) , String > {
1549
1552
let mut crate_types: Vec < CrateType > = Vec :: new ( ) ;
1553
+ let mut emit_metadata = false ;
1550
1554
for unparsed_crate_type in & list_list {
1551
1555
for part in unparsed_crate_type. split ( ',' ) {
1552
1556
let new_part = match part {
@@ -1557,6 +1561,13 @@ pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateTy
1557
1561
"cdylib" => CrateTypeCdylib ,
1558
1562
"bin" => CrateTypeExecutable ,
1559
1563
"proc-macro" => CrateTypeProcMacro ,
1564
+ // FIXME(#38640) remove this when Cargo is fixed.
1565
+ "metadata" => {
1566
+ early_warn ( ErrorOutputType :: default ( ) , "--crate-type=metadata is deprecated, \
1567
+ prefer --emit=metadata") ;
1568
+ emit_metadata = true ;
1569
+ CrateTypeRlib
1570
+ }
1560
1571
_ => {
1561
1572
return Err ( format ! ( "unknown crate type: `{}`" ,
1562
1573
part) ) ;
@@ -1568,7 +1579,7 @@ pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateTy
1568
1579
}
1569
1580
}
1570
1581
1571
- return Ok ( crate_types) ;
1582
+ return Ok ( ( crate_types, emit_metadata ) ) ;
1572
1583
}
1573
1584
1574
1585
pub mod nightly_options {
0 commit comments