Merge `Queries::{ongoing_codegen,linker}`.

There is no real need for them to be separate.
This commit is contained in:
Nicholas Nethercote 2023-11-20 15:09:05 +11:00
parent 3a4798c92d
commit 971010ea5a
3 changed files with 15 additions and 21 deletions

View File

@ -453,7 +453,7 @@ fn run_compiler(
return early_exit();
}
let ongoing_codegen = queries.ongoing_codegen()?;
let linker = queries.codegen_and_build_linker()?;
// This must run after monomorphization so that all generic types
// have been instantiated.
@ -467,7 +467,6 @@ fn run_compiler(
sess.code_stats.print_vtable_sizes(crate_name);
}
let linker = queries.linker(ongoing_codegen)?;
Ok(Some(linker))
})?;

View File

@ -180,22 +180,6 @@ impl<'tcx> Queries<'tcx> {
})
}
pub fn ongoing_codegen(&'tcx self) -> Result<Box<dyn Any>> {
self.global_ctxt()?.enter(|tcx| {
// Don't do code generation if there were any errors
self.compiler.sess.compile_status()?;
// If we have any delayed bugs, for example because we created TyKind::Error earlier,
// it's likely that codegen will only cause more ICEs, obscuring the original problem
self.compiler.sess.diagnostic().flush_delayed();
// Hook for UI tests.
Self::check_for_rustc_errors_attr(tcx);
Ok(passes::start_codegen(&*self.compiler.codegen_backend, tcx))
})
}
/// Check for the `#[rustc_error]` annotation, which forces an error in codegen. This is used
/// to write UI tests that actually test that compilation succeeds without reporting
/// an error.
@ -230,8 +214,20 @@ impl<'tcx> Queries<'tcx> {
}
}
pub fn linker(&'tcx self, ongoing_codegen: Box<dyn Any>) -> Result<Linker> {
pub fn codegen_and_build_linker(&'tcx self) -> Result<Linker> {
self.global_ctxt()?.enter(|tcx| {
// Don't do code generation if there were any errors
self.compiler.sess.compile_status()?;
// If we have any delayed bugs, for example because we created TyKind::Error earlier,
// it's likely that codegen will only cause more ICEs, obscuring the original problem
self.compiler.sess.diagnostic().flush_delayed();
// Hook for UI tests.
Self::check_for_rustc_errors_attr(tcx);
let ongoing_codegen = passes::start_codegen(&*self.compiler.codegen_backend, tcx);
Ok(Linker {
dep_graph: tcx.dep_graph.clone(),
output_filenames: tcx.output_filenames(()).clone(),

View File

@ -69,8 +69,7 @@ fn compile(code: String, output: PathBuf, sysroot: PathBuf) {
interface::run_compiler(config, |compiler| {
let linker = compiler.enter(|queries| {
queries.global_ctxt()?.enter(|tcx| tcx.analysis(()))?;
let ongoing_codegen = queries.ongoing_codegen()?;
queries.linker(ongoing_codegen)
queries.codegen_and_build_linker()
});
linker.unwrap().link(&compiler.sess, &*compiler.codegen_backend).unwrap();
});