Skip to content

Commit

Permalink
Use has_errors_or_lint_errors in rustdoc instead of `abort_if_error…
Browse files Browse the repository at this point in the history
…s()`

Rustdoc is special as usual and doesn't go through RunCompiler, so it
needs its own explicit checks. The rest of the tools go through
RunCompiler, so they should be fine.
  • Loading branch information
jyn514 committed Nov 8, 2021
1 parent c008bb0 commit ebf8966
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/librustdoc/core.rs
Expand Up @@ -486,11 +486,13 @@ crate fn run_global_ctxt(
};
if run {
debug!("running pass {}", p.pass.name);
krate = ctxt.tcx.sess.time(p.pass.name, || (p.pass.run)(krate, &mut ctxt));
krate = tcx.sess.time(p.pass.name, || (p.pass.run)(krate, &mut ctxt));
}
}

ctxt.sess().abort_if_errors();
if tcx.sess.diagnostic().has_errors_or_lint_errors() {
rustc_errors::FatalError.raise();
}

let render_options = ctxt.render_options;
let mut cache = ctxt.cache;
Expand Down
6 changes: 4 additions & 2 deletions src/librustdoc/doctest.rs
@@ -1,7 +1,7 @@
use rustc_ast as ast;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::sync::Lrc;
use rustc_errors::{ColorConfig, ErrorReported};
use rustc_errors::{ColorConfig, ErrorReported, FatalError};
use rustc_hir as hir;
use rustc_hir::def_id::LOCAL_CRATE;
use rustc_hir::intravisit;
Expand Down Expand Up @@ -149,7 +149,9 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {

collector
});
compiler.session().abort_if_errors();
if compiler.session().diagnostic().has_errors_or_lint_errors() {
FatalError.raise();
}

let unused_extern_reports = collector.unused_extern_reports.clone();
let compiling_test_count = collector.compiling_test_count.load(Ordering::SeqCst);
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/lib.rs
Expand Up @@ -775,7 +775,7 @@ fn main_options(options: config::Options) -> MainResult {
// current architecture.
let resolver = core::create_resolver(queries, sess);

if sess.has_errors() {
if sess.diagnostic().has_errors_or_lint_errors() {
sess.fatal("Compilation failed, aborting rustdoc");
}

Expand Down

0 comments on commit ebf8966

Please sign in to comment.