mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Inline and remove Session::compile_status
.
Because it's now simple enough that it doesn't provide much benefit.
This commit is contained in:
parent
72b172bdf6
commit
c2512a130f
@ -487,7 +487,9 @@ fn collate_raw_dylibs<'a, 'b>(
|
||||
}
|
||||
}
|
||||
}
|
||||
sess.compile_status()?;
|
||||
if let Some(guar) = sess.dcx().has_errors() {
|
||||
return Err(guar);
|
||||
}
|
||||
Ok(dylib_table
|
||||
.into_iter()
|
||||
.map(|(name, imports)| {
|
||||
|
@ -357,18 +357,25 @@ fn run_compiler(
|
||||
let sess = &compiler.sess;
|
||||
let codegen_backend = &*compiler.codegen_backend;
|
||||
|
||||
// This is used for early exits unrelated to errors. E.g. when just
|
||||
// printing some information without compiling, or exiting immediately
|
||||
// after parsing, etc.
|
||||
let early_exit = || {
|
||||
if let Some(guar) = sess.dcx().has_errors() { Err(guar) } else { Ok(()) }
|
||||
};
|
||||
|
||||
// This implements `-Whelp`. It should be handled very early, like
|
||||
// `--help`/`-Zhelp`/`-Chelp`. This is the earliest it can run, because
|
||||
// it must happen after lints are registered, during session creation.
|
||||
if sess.opts.describe_lints {
|
||||
describe_lints(sess);
|
||||
return sess.compile_status();
|
||||
return early_exit();
|
||||
}
|
||||
|
||||
let early_dcx = EarlyDiagCtxt::new(sess.opts.error_format);
|
||||
|
||||
if print_crate_info(&early_dcx, codegen_backend, sess, has_input) == Compilation::Stop {
|
||||
return sess.compile_status();
|
||||
return early_exit();
|
||||
}
|
||||
|
||||
if !has_input {
|
||||
@ -377,16 +384,16 @@ fn run_compiler(
|
||||
|
||||
if !sess.opts.unstable_opts.ls.is_empty() {
|
||||
list_metadata(&early_dcx, sess, &*codegen_backend.metadata_loader());
|
||||
return sess.compile_status();
|
||||
return early_exit();
|
||||
}
|
||||
|
||||
if sess.opts.unstable_opts.link_only {
|
||||
process_rlink(sess, compiler);
|
||||
return sess.compile_status();
|
||||
return early_exit();
|
||||
}
|
||||
|
||||
let linker = compiler.enter(|queries| {
|
||||
let early_exit = || sess.compile_status().map(|_| None);
|
||||
let early_exit = || early_exit().map(|_| None);
|
||||
queries.parse()?;
|
||||
|
||||
if let Some(ppm) = &sess.opts.pretty {
|
||||
|
@ -261,7 +261,9 @@ impl Linker {
|
||||
let (codegen_results, work_products) =
|
||||
codegen_backend.join_codegen(self.ongoing_codegen, sess, &self.output_filenames);
|
||||
|
||||
sess.compile_status()?;
|
||||
if let Some(guar) = sess.dcx().has_errors() {
|
||||
return Err(guar);
|
||||
}
|
||||
|
||||
sess.time("serialize_work_products", || {
|
||||
rustc_incremental::save_work_product_index(sess, &self.dep_graph, work_products)
|
||||
|
@ -317,14 +317,6 @@ impl Session {
|
||||
err
|
||||
}
|
||||
|
||||
pub fn compile_status(&self) -> Result<(), ErrorGuaranteed> {
|
||||
if let Some(reported) = self.dcx().has_errors() {
|
||||
Err(reported)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Record the fact that we called `trimmed_def_paths`, and do some
|
||||
/// checking about whether its cost was justified.
|
||||
pub fn record_trimmed_def_paths(&self) {
|
||||
|
@ -68,7 +68,7 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
|
||||
queries: &'tcx rustc_interface::Queries<'tcx>,
|
||||
) -> Compilation {
|
||||
queries.global_ctxt().unwrap().enter(|tcx| {
|
||||
if tcx.sess.compile_status().is_err() {
|
||||
if tcx.sess.dcx().has_errors().is_some() {
|
||||
tcx.dcx().fatal("miri cannot be run on programs that fail compilation");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user