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