Skip to content

Commit ebf8966

Browse files
committed
Use has_errors_or_lint_errors in rustdoc instead of abort_if_errors()
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.
1 parent c008bb0 commit ebf8966

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/librustdoc/core.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -486,11 +486,13 @@ crate fn run_global_ctxt(
486486
};
487487
if run {
488488
debug!("running pass {}", p.pass.name);
489-
krate = ctxt.tcx.sess.time(p.pass.name, || (p.pass.run)(krate, &mut ctxt));
489+
krate = tcx.sess.time(p.pass.name, || (p.pass.run)(krate, &mut ctxt));
490490
}
491491
}
492492

493-
ctxt.sess().abort_if_errors();
493+
if tcx.sess.diagnostic().has_errors_or_lint_errors() {
494+
rustc_errors::FatalError.raise();
495+
}
494496

495497
let render_options = ctxt.render_options;
496498
let mut cache = ctxt.cache;

src/librustdoc/doctest.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_ast as ast;
22
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
33
use rustc_data_structures::sync::Lrc;
4-
use rustc_errors::{ColorConfig, ErrorReported};
4+
use rustc_errors::{ColorConfig, ErrorReported, FatalError};
55
use rustc_hir as hir;
66
use rustc_hir::def_id::LOCAL_CRATE;
77
use rustc_hir::intravisit;
@@ -149,7 +149,9 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
149149

150150
collector
151151
});
152-
compiler.session().abort_if_errors();
152+
if compiler.session().diagnostic().has_errors_or_lint_errors() {
153+
FatalError.raise();
154+
}
153155

154156
let unused_extern_reports = collector.unused_extern_reports.clone();
155157
let compiling_test_count = collector.compiling_test_count.load(Ordering::SeqCst);

src/librustdoc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ fn main_options(options: config::Options) -> MainResult {
775775
// current architecture.
776776
let resolver = core::create_resolver(queries, sess);
777777

778-
if sess.has_errors() {
778+
if sess.diagnostic().has_errors_or_lint_errors() {
779779
sess.fatal("Compilation failed, aborting rustdoc");
780780
}
781781

0 commit comments

Comments
 (0)