Replace unnecessary abort_if_errors
.
Replace `abort_if_errors` calls that are certain to abort -- because we emit an error immediately beforehand -- with `FatalErro.raise()`.
This commit is contained in:
parent
44006444c8
commit
4da67fff61
@ -3,7 +3,7 @@ use rustc_ast::CRATE_NODE_ID;
|
|||||||
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
|
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
|
||||||
use rustc_data_structures::memmap::Mmap;
|
use rustc_data_structures::memmap::Mmap;
|
||||||
use rustc_data_structures::temp_dir::MaybeTempDir;
|
use rustc_data_structures::temp_dir::MaybeTempDir;
|
||||||
use rustc_errors::{DiagCtxt, ErrorGuaranteed};
|
use rustc_errors::{DiagCtxt, ErrorGuaranteed, FatalError};
|
||||||
use rustc_fs_util::{fix_windows_verbatim_for_gcc, try_canonicalize};
|
use rustc_fs_util::{fix_windows_verbatim_for_gcc, try_canonicalize};
|
||||||
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
|
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
|
||||||
use rustc_metadata::find_native_static_library;
|
use rustc_metadata::find_native_static_library;
|
||||||
@ -722,10 +722,7 @@ fn link_dwarf_object<'a>(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}) {
|
}) {
|
||||||
Ok(()) => {}
|
Ok(()) => {}
|
||||||
Err(e) => {
|
Err(e) => sess.dcx().emit_fatal(errors::ThorinErrorWrapper(e)),
|
||||||
sess.dcx().emit_err(errors::ThorinErrorWrapper(e));
|
|
||||||
sess.dcx().abort_if_errors();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1001,7 +998,7 @@ fn link_natively<'a>(
|
|||||||
sess.dcx().emit_note(errors::CheckInstalledVisualStudio);
|
sess.dcx().emit_note(errors::CheckInstalledVisualStudio);
|
||||||
sess.dcx().emit_note(errors::InsufficientVSCodeProduct);
|
sess.dcx().emit_note(errors::InsufficientVSCodeProduct);
|
||||||
}
|
}
|
||||||
sess.dcx().abort_if_errors();
|
FatalError.raise();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,10 +449,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
|||||||
let Some(llfn) = cx.declare_c_main(llfty) else {
|
let Some(llfn) = cx.declare_c_main(llfty) else {
|
||||||
// FIXME: We should be smart and show a better diagnostic here.
|
// FIXME: We should be smart and show a better diagnostic here.
|
||||||
let span = cx.tcx().def_span(rust_main_def_id);
|
let span = cx.tcx().def_span(rust_main_def_id);
|
||||||
let dcx = cx.tcx().dcx();
|
cx.tcx().dcx().emit_fatal(errors::MultipleMainFunctions { span });
|
||||||
dcx.emit_err(errors::MultipleMainFunctions { span });
|
|
||||||
dcx.abort_if_errors();
|
|
||||||
bug!();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// `main` should respect same config for frame pointer elimination as rest of code
|
// `main` should respect same config for frame pointer elimination as rest of code
|
||||||
|
@ -876,6 +876,10 @@ impl DiagCtxt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This excludes delayed bugs and stashed errors. Used for early aborts
|
||||||
|
/// after errors occurred -- e.g. because continuing in the face of errors is
|
||||||
|
/// likely to lead to bad results, such as spurious/uninteresting
|
||||||
|
/// additional errors -- when returning an error `Result` is difficult.
|
||||||
pub fn abort_if_errors(&self) {
|
pub fn abort_if_errors(&self) {
|
||||||
if self.has_errors().is_some() {
|
if self.has_errors().is_some() {
|
||||||
FatalError.raise();
|
FatalError.raise();
|
||||||
|
@ -936,9 +936,7 @@ pub fn start_codegen<'tcx>(
|
|||||||
|
|
||||||
if tcx.sess.opts.output_types.contains_key(&OutputType::Mir) {
|
if tcx.sess.opts.output_types.contains_key(&OutputType::Mir) {
|
||||||
if let Err(error) = rustc_mir_transform::dump_mir::emit_mir(tcx) {
|
if let Err(error) = rustc_mir_transform::dump_mir::emit_mir(tcx) {
|
||||||
let dcx = tcx.dcx();
|
tcx.dcx().emit_fatal(errors::CantEmitMIR { error });
|
||||||
dcx.emit_err(errors::CantEmitMIR { error });
|
|
||||||
dcx.abort_if_errors();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ use crate::errors::{
|
|||||||
};
|
};
|
||||||
use crate::Session;
|
use crate::Session;
|
||||||
use rustc_ast::{self as ast, attr};
|
use rustc_ast::{self as ast, attr};
|
||||||
|
use rustc_errors::FatalError;
|
||||||
use rustc_span::symbol::sym;
|
use rustc_span::symbol::sym;
|
||||||
use rustc_span::{Span, Symbol};
|
use rustc_span::{Span, Symbol};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
@ -115,7 +116,7 @@ pub fn validate_crate_name(sess: &Session, s: Symbol, sp: Option<Span>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err_count > 0 {
|
if err_count > 0 {
|
||||||
sess.dcx().abort_if_errors();
|
FatalError.raise();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ use crate::traits::{
|
|||||||
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
|
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
codes::*, pluralize, struct_span_code_err, Applicability, DiagnosticBuilder, ErrorGuaranteed,
|
codes::*, pluralize, struct_span_code_err, Applicability, DiagnosticBuilder, ErrorGuaranteed,
|
||||||
MultiSpan, StashKey, StringPart,
|
FatalError, MultiSpan, StashKey, StringPart,
|
||||||
};
|
};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::{DefKind, Namespace, Res};
|
use rustc_hir::def::{DefKind, Namespace, Res};
|
||||||
@ -193,14 +193,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||||||
let mut err = self.build_overflow_error(predicate, span, suggest_increasing_limit);
|
let mut err = self.build_overflow_error(predicate, span, suggest_increasing_limit);
|
||||||
mutate(&mut err);
|
mutate(&mut err);
|
||||||
err.emit();
|
err.emit();
|
||||||
|
FatalError.raise();
|
||||||
self.dcx().abort_if_errors();
|
|
||||||
// FIXME: this should be something like `build_overflow_error_fatal`, which returns
|
|
||||||
// `DiagnosticBuilder<', !>`. Then we don't even need anything after that `emit()`.
|
|
||||||
unreachable!(
|
|
||||||
"did not expect compilation to continue after `abort_if_errors`, \
|
|
||||||
since an error was definitely emitted!"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_overflow_error<T>(
|
fn build_overflow_error<T>(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user