Inline and remove abort_on_err
.
It's clumsy and doesn't improve readability.
This commit is contained in:
parent
4da67fff61
commit
f16c226af3
@ -144,16 +144,6 @@ pub(super) fn install() {}
|
||||
pub const DEFAULT_BUG_REPORT_URL: &str = "https://github.com/rust-lang/rust/issues/new\
|
||||
?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md";
|
||||
|
||||
pub fn abort_on_err<T>(result: Result<T, ErrorGuaranteed>, sess: &Session) -> T {
|
||||
match result {
|
||||
Err(..) => {
|
||||
sess.dcx().abort_if_errors();
|
||||
panic!("error reported but abort_if_errors didn't abort???");
|
||||
}
|
||||
Ok(x) => x,
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Callbacks {
|
||||
/// Called before creating the compiler instance
|
||||
fn config(&mut self, _config: &mut interface::Config) {}
|
||||
@ -665,10 +655,11 @@ fn process_rlink(sess: &Session, compiler: &interface::Compiler) {
|
||||
};
|
||||
}
|
||||
};
|
||||
let result = compiler.codegen_backend.link(sess, codegen_results, &outputs);
|
||||
abort_on_err(result, sess);
|
||||
if compiler.codegen_backend.link(sess, codegen_results, &outputs).is_err() {
|
||||
FatalError.raise();
|
||||
}
|
||||
} else {
|
||||
dcx.emit_fatal(RlinkNotAFile {})
|
||||
dcx.emit_fatal(RlinkNotAFile {});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
use rustc_ast as ast;
|
||||
use rustc_ast_pretty::pprust as pprust_ast;
|
||||
use rustc_errors::FatalError;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir_pretty as pprust_hir;
|
||||
use rustc_middle::bug;
|
||||
@ -18,7 +19,6 @@
|
||||
|
||||
pub use self::PpMode::*;
|
||||
pub use self::PpSourceMode::*;
|
||||
use crate::abort_on_err;
|
||||
|
||||
struct AstNoAnn;
|
||||
|
||||
@ -243,7 +243,9 @@ fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
|
||||
pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
|
||||
if ppm.needs_analysis() {
|
||||
abort_on_err(ex.tcx().analysis(()), sess);
|
||||
if ex.tcx().analysis(()).is_err() {
|
||||
FatalError.raise();
|
||||
}
|
||||
}
|
||||
|
||||
let (src, src_name) = get_source(sess);
|
||||
@ -334,7 +336,9 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
|
||||
ThirTree => {
|
||||
let tcx = ex.tcx();
|
||||
let mut out = String::new();
|
||||
abort_on_err(rustc_hir_analysis::check_crate(tcx), tcx.sess);
|
||||
if rustc_hir_analysis::check_crate(tcx).is_err() {
|
||||
FatalError.raise();
|
||||
}
|
||||
debug!("pretty printing THIR tree");
|
||||
for did in tcx.hir().body_owners() {
|
||||
let _ = writeln!(out, "{:?}:\n{}\n", did, tcx.thir_tree(did));
|
||||
@ -344,7 +348,9 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
|
||||
ThirFlat => {
|
||||
let tcx = ex.tcx();
|
||||
let mut out = String::new();
|
||||
abort_on_err(rustc_hir_analysis::check_crate(tcx), tcx.sess);
|
||||
if rustc_hir_analysis::check_crate(tcx).is_err() {
|
||||
FatalError.raise();
|
||||
}
|
||||
debug!("pretty printing THIR flat");
|
||||
for did in tcx.hir().body_owners() {
|
||||
let _ = writeln!(out, "{:?}:\n{}\n", did, tcx.thir_flat(did));
|
||||
|
@ -78,8 +78,7 @@
|
||||
use std::process;
|
||||
use std::sync::{atomic::AtomicBool, Arc};
|
||||
|
||||
use rustc_driver::abort_on_err;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_errors::{ErrorGuaranteed, FatalError};
|
||||
use rustc_interface::interface;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::config::{make_crate_type_option, ErrorOutputType, RustcOptGroup};
|
||||
@ -779,7 +778,7 @@ fn main_args(
|
||||
}
|
||||
|
||||
compiler.enter(|queries| {
|
||||
let mut gcx = abort_on_err(queries.global_ctxt(), sess);
|
||||
let Ok(mut gcx) = queries.global_ctxt() else { FatalError.raise() };
|
||||
if sess.dcx().has_errors().is_some() {
|
||||
sess.dcx().fatal("Compilation failed, aborting rustdoc");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user