Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report I/O errors from rmeta encoding with emit_fatal #119510

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions compiler/rustc_incremental/src/persist/file_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,12 @@ where
debug!("save: remove old file");
}
Err(err) if err.kind() == io::ErrorKind::NotFound => (),
Err(err) => {
sess.dcx().emit_err(errors::DeleteOld { name, path: path_buf, err });
return;
}
Err(err) => sess.dcx().emit_fatal(errors::DeleteOld { name, path: path_buf, err }),
}

let mut encoder = match FileEncoder::new(&path_buf) {
Ok(encoder) => encoder,
Err(err) => {
sess.dcx().emit_err(errors::CreateNew { name, path: path_buf, err });
return;
}
Err(err) => sess.dcx().emit_fatal(errors::CreateNew { name, path: path_buf, err }),
};

write_file_header(&mut encoder, sess);
Expand All @@ -80,9 +74,7 @@ where
);
debug!("save: data written to disk successfully");
}
Err((path, err)) => {
sess.dcx().emit_err(errors::WriteNew { name, path, err });
}
Err((path, err)) => sess.dcx().emit_fatal(errors::WriteNew { name, path, err }),
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_interface/src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ impl Compiler {
// the global context.
_timer = Some(self.sess.timer("free_global_ctxt"));
if let Err((path, error)) = queries.finish() {
self.sess.dcx().emit_err(errors::FailedWritingFile { path: &path, error });
self.sess.dcx().emit_fatal(errors::FailedWritingFile { path: &path, error });
}

ret
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_metadata/src/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2241,12 +2241,12 @@ pub fn encode_metadata(tcx: TyCtxt<'_>, path: &Path) {
// If we forget this, compilation can succeed with an incomplete rmeta file,
// causing an ICE when the rmeta file is read by another compilation.
if let Err((path, err)) = ecx.opaque.finish() {
tcx.dcx().emit_err(FailWriteFile { path: &path, err });
tcx.dcx().emit_fatal(FailWriteFile { path: &path, err });
}

let file = ecx.opaque.file();
if let Err(err) = encode_root_position(file, root.position.get()) {
tcx.dcx().emit_err(FailWriteFile { path: ecx.opaque.path(), err });
tcx.dcx().emit_fatal(FailWriteFile { path: ecx.opaque.path(), err });
}

// Record metadata size for self-profiling
Expand Down
Loading