mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Create separate match arms for FileNames and CrateNames
This introduces a bit of code duplication, but we don't have the build_output_filenames in the CrateName arm and this seems a little cleaner overall.
This commit is contained in:
parent
26fd6b15b0
commit
11ae0afc93
@ -771,24 +771,28 @@ fn print_crate_info(
|
|||||||
}
|
}
|
||||||
println_info!("{}", serde_json::to_string_pretty(&targets).unwrap());
|
println_info!("{}", serde_json::to_string_pretty(&targets).unwrap());
|
||||||
}
|
}
|
||||||
FileNames | CrateName => {
|
FileNames => {
|
||||||
let Some(attrs) = attrs.as_ref() else {
|
let Some(attrs) = attrs.as_ref() else {
|
||||||
// no crate attributes, print out an error and exit
|
// no crate attributes, print out an error and exit
|
||||||
return Compilation::Continue;
|
return Compilation::Continue;
|
||||||
};
|
};
|
||||||
let t_outputs = rustc_interface::util::build_output_filenames(attrs, sess);
|
let t_outputs = rustc_interface::util::build_output_filenames(attrs, sess);
|
||||||
let id = rustc_session::output::find_crate_name(sess, attrs);
|
let id = rustc_session::output::find_crate_name(sess, attrs);
|
||||||
if req.kind == CrateName {
|
let crate_types = collect_crate_types(sess, attrs);
|
||||||
println_info!("{id}");
|
for &style in &crate_types {
|
||||||
} else {
|
let fname =
|
||||||
let crate_types = collect_crate_types(sess, attrs);
|
rustc_session::output::filename_for_input(sess, style, id, &t_outputs);
|
||||||
for &style in &crate_types {
|
println_info!("{}", fname.as_path().file_name().unwrap().to_string_lossy());
|
||||||
let fname =
|
|
||||||
rustc_session::output::filename_for_input(sess, style, id, &t_outputs);
|
|
||||||
println_info!("{}", fname.as_path().file_name().unwrap().to_string_lossy());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CrateName => {
|
||||||
|
let Some(attrs) = attrs.as_ref() else {
|
||||||
|
// no crate attributes, print out an error and exit
|
||||||
|
return Compilation::Continue;
|
||||||
|
};
|
||||||
|
let id = rustc_session::output::find_crate_name(sess, attrs);
|
||||||
|
println_info!("{id}");
|
||||||
|
}
|
||||||
Cfg => {
|
Cfg => {
|
||||||
let mut cfgs = sess
|
let mut cfgs = sess
|
||||||
.parse_sess
|
.parse_sess
|
||||||
|
Loading…
Reference in New Issue
Block a user