diff options
| author | mark <markm@cs.wisc.edu> | 2022-01-22 18:49:12 -0600 |
|---|---|---|
| committer | mark <markm@cs.wisc.edu> | 2022-03-16 10:35:24 -0500 |
| commit | bb8d4307eb723850e98bcb52d71d860a4aba220a (patch) | |
| tree | f3215627c474542776bdbcb03f634651a89b70f8 /src/librustdoc/lib.rs | |
| parent | 461e8078010433ff7de2db2aaae8a3cfb0847215 (diff) | |
| download | rust-bb8d4307eb723850e98bcb52d71d860a4aba220a.tar.gz rust-bb8d4307eb723850e98bcb52d71d860a4aba220a.zip | |
rustc_error: make ErrorReported impossible to construct
There are a few places were we have to construct it, though, and a few places that are more invasive to change. To do this, we create a constructor with a long obvious name.
Diffstat (limited to 'src/librustdoc/lib.rs')
| -rw-r--r-- | src/librustdoc/lib.rs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index f378915172a..f59222b780d 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -179,7 +179,7 @@ pub fn main() { let exit_code = rustc_driver::catch_with_exit_code(|| match get_args() { Some(args) => main_args(&args), - _ => Err(ErrorGuaranteed), + _ => Err(ErrorGuaranteed::unchecked_claim_error_was_emitted()), }); process::exit(exit_code); } @@ -692,7 +692,13 @@ fn main_args(at_args: &[String]) -> MainResult { // codes from `from_matches` here. let options = match config::Options::from_matches(&matches) { Ok(opts) => opts, - Err(code) => return if code == 0 { Ok(()) } else { Err(ErrorGuaranteed) }, + Err(code) => { + return if code == 0 { + Ok(()) + } else { + Err(ErrorGuaranteed::unchecked_claim_error_was_emitted()) + }; + } }; rustc_interface::util::run_in_thread_pool_with_globals( options.edition, @@ -705,8 +711,8 @@ fn wrap_return(diag: &rustc_errors::Handler, res: Result<(), String>) -> MainRes match res { Ok(()) => Ok(()), Err(err) => { - diag.struct_err(&err).emit(); - Err(ErrorGuaranteed) + let reported = diag.struct_err(&err).emit(); + Err(reported) } } } @@ -790,7 +796,7 @@ fn main_options(options: config::Options) -> MainResult { (resolver.clone(), resolver_caches) }; - if sess.diagnostic().has_errors_or_lint_errors() { + if sess.diagnostic().has_errors_or_lint_errors().is_some() { sess.fatal("Compilation failed, aborting rustdoc"); } |
