Don't silently ignore errors that happen during rendering

This commit is contained in:
Guillaume Gomez 2022-12-07 16:08:13 +01:00
parent e72ea1dc37
commit 06693790ce

View File

@ -674,7 +674,7 @@ fn usage(argv0: &str) {
fn wrap_return(diag: &rustc_errors::Handler, res: Result<(), String>) -> MainResult {
match res {
Ok(()) => Ok(()),
Ok(()) => diag.has_errors().map_or(Ok(()), Err),
Err(err) => {
let reported = diag.struct_err(&err).emit();
Err(reported)
@ -689,7 +689,7 @@ fn run_renderer<'tcx, T: formats::FormatRenderer<'tcx>>(
tcx: TyCtxt<'tcx>,
) -> MainResult {
match formats::run_format::<T>(krate, renderopts, cache, tcx) {
Ok(_) => Ok(()),
Ok(_) => tcx.sess.has_errors().map_or(Ok(()), Err),
Err(e) => {
let mut msg =
tcx.sess.struct_err(&format!("couldn't generate documentation: {}", e.error));