create an empty file even in case of MetadataKind::None
This commit is contained in:
parent
7eb64b4901
commit
03de5c4a14
@ -68,13 +68,24 @@ pub fn encode_and_write_metadata(
|
||||
.unwrap_or_else(|err| tcx.sess.fatal(&format!("couldn't create a temp dir: {}", err)));
|
||||
let metadata_tmpdir = MaybeTempDir::new(metadata_tmpdir, tcx.sess.opts.cg.save_temps);
|
||||
let metadata_filename = metadata_tmpdir.as_ref().join(METADATA_FILENAME);
|
||||
let need_metadata_file = tcx.sess.opts.output_types.contains_key(&OutputType::Metadata);
|
||||
let metadata = match metadata_kind {
|
||||
MetadataKind::None => {
|
||||
if tcx.sess.opts.json_artifact_notifications {
|
||||
tcx.sess
|
||||
.parse_sess
|
||||
.span_diagnostic
|
||||
.emit_artifact_notification(&out_filename, "metadata");
|
||||
if need_metadata_file {
|
||||
// Though creating the empty file here seems to be meaningless, cargo expects it.
|
||||
if let Err(e) = std::fs::File::create(&out_filename) {
|
||||
tcx.sess.fatal(&format!(
|
||||
"failed to create the file {}: {}",
|
||||
out_filename.display(),
|
||||
e
|
||||
));
|
||||
}
|
||||
if tcx.sess.opts.json_artifact_notifications {
|
||||
tcx.sess
|
||||
.parse_sess
|
||||
.span_diagnostic
|
||||
.emit_artifact_notification(&out_filename, "metadata");
|
||||
}
|
||||
}
|
||||
EncodedMetadata::empty()
|
||||
}
|
||||
@ -83,7 +94,6 @@ pub fn encode_and_write_metadata(
|
||||
|
||||
let _prof_timer = tcx.sess.prof.generic_activity("write_crate_metadata");
|
||||
|
||||
let need_metadata_file = tcx.sess.opts.output_types.contains_key(&OutputType::Metadata);
|
||||
let (metadata_filename, metadata_tmpdir) = if need_metadata_file {
|
||||
if let Err(e) = non_durable_rename(&metadata_filename, &out_filename) {
|
||||
tcx.sess.fatal(&format!("failed to write {}: {}", out_filename.display(), e));
|
||||
|
Loading…
x
Reference in New Issue
Block a user