Skip to content

Commit 9c89166

Browse files
committed
Restore --crate-type=metadata as an alias for --crate-type=rlib,--emit=metadata + a warning
1 parent 71f161c commit 9c89166

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/librustc/session/config.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,7 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
12961296
};
12971297

12981298
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)
13001300
.unwrap_or_else(|e| early_error(error_format, &e[..]));
13011301

13021302
let mut lint_opts = vec![];
@@ -1343,7 +1343,9 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
13431343
}
13441344
}
13451345
};
1346-
if output_types.is_empty() {
1346+
if emit_metadata {
1347+
output_types.insert(OutputType::Metadata, None);
1348+
} else if output_types.is_empty() {
13471349
output_types.insert(OutputType::Exe, None);
13481350
}
13491351

@@ -1545,8 +1547,10 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
15451547
cfg)
15461548
}
15471549

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> {
15491552
let mut crate_types: Vec<CrateType> = Vec::new();
1553+
let mut emit_metadata = false;
15501554
for unparsed_crate_type in &list_list {
15511555
for part in unparsed_crate_type.split(',') {
15521556
let new_part = match part {
@@ -1557,6 +1561,13 @@ pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateTy
15571561
"cdylib" => CrateTypeCdylib,
15581562
"bin" => CrateTypeExecutable,
15591563
"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+
}
15601571
_ => {
15611572
return Err(format!("unknown crate type: `{}`",
15621573
part));
@@ -1568,7 +1579,7 @@ pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateTy
15681579
}
15691580
}
15701581

1571-
return Ok(crate_types);
1582+
return Ok((crate_types, emit_metadata));
15721583
}
15731584

15741585
pub mod nightly_options {

0 commit comments

Comments
 (0)