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 | |
| 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')
| -rw-r--r-- | src/librustdoc/clean/types.rs | 4 | ||||
| -rw-r--r-- | src/librustdoc/core.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/doctest.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/lib.rs | 16 | ||||
| -rw-r--r-- | src/librustdoc/passes/bare_urls.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/passes/check_code_block_syntax.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/passes/check_doc_test_visibility.rs | 8 |
7 files changed, 24 insertions, 12 deletions
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index c0e7cd0b1f5..42b7eec5d3a 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -834,7 +834,9 @@ impl AttributesExt for [ast::Attribute] { { match Cfg::parse(cfg_mi) { Ok(new_cfg) => cfg &= new_cfg, - Err(e) => sess.span_err(e.span, e.msg), + Err(e) => { + sess.span_err(e.span, e.msg); + } } } } diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 2b82575f710..bd64e2b03ce 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -452,7 +452,7 @@ crate fn run_global_ctxt( } } - if tcx.sess.diagnostic().has_errors_or_lint_errors() { + if tcx.sess.diagnostic().has_errors_or_lint_errors().is_some() { rustc_errors::FatalError.raise(); } diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 728b7720f73..8db5f8b0cff 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -149,7 +149,7 @@ crate fn run(options: RustdocOptions) -> Result<(), ErrorGuaranteed> { collector }); - if compiler.session().diagnostic().has_errors_or_lint_errors() { + if compiler.session().diagnostic().has_errors_or_lint_errors().is_some() { FatalError.raise(); } 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"); } diff --git a/src/librustdoc/passes/bare_urls.rs b/src/librustdoc/passes/bare_urls.rs index 71fa71750f4..81f371840ae 100644 --- a/src/librustdoc/passes/bare_urls.rs +++ b/src/librustdoc/passes/bare_urls.rs @@ -80,7 +80,7 @@ impl<'a, 'tcx> DocVisitor for BareUrlsLinter<'a, 'tcx> { format!("<{}>", url), Applicability::MachineApplicable, ) - .emit() + .emit(); }); }; diff --git a/src/librustdoc/passes/check_code_block_syntax.rs b/src/librustdoc/passes/check_code_block_syntax.rs index c4aa31ad912..8d9b3377a69 100644 --- a/src/librustdoc/passes/check_code_block_syntax.rs +++ b/src/librustdoc/passes/check_code_block_syntax.rs @@ -91,7 +91,7 @@ impl<'a, 'tcx> SyntaxChecker<'a, 'tcx> { // lambda that will use the lint to start a new diagnostic and add // a suggestion to it when needed. - let diag_builder = |lint: LintDiagnosticBuilder<'_>| { + let diag_builder = |lint: LintDiagnosticBuilder<'_, ()>| { let explanation = if is_ignore { "`ignore` code blocks require valid Rust code for syntax highlighting; \ mark blocks that do not contain Rust code as text" diff --git a/src/librustdoc/passes/check_doc_test_visibility.rs b/src/librustdoc/passes/check_doc_test_visibility.rs index f1bb766f467..2b17e3457d2 100644 --- a/src/librustdoc/passes/check_doc_test_visibility.rs +++ b/src/librustdoc/passes/check_doc_test_visibility.rs @@ -125,7 +125,9 @@ crate fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item) { crate::lint::MISSING_DOC_CODE_EXAMPLES, hir_id, sp, - |lint| lint.build("missing code example in this documentation").emit(), + |lint| { + lint.build("missing code example in this documentation").emit(); + }, ); } } else if tests.found_tests > 0 @@ -135,7 +137,9 @@ crate fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item) { crate::lint::PRIVATE_DOC_TESTS, hir_id, item.attr_span(cx.tcx), - |lint| lint.build("documentation test in private item").emit(), + |lint| { + lint.build("documentation test in private item").emit(); + }, ); } } |
