Inline and remove create_compiler_and_run.

It has a single call site.
This commit is contained in:
Nicholas Nethercote 2022-10-07 16:17:57 +11:00
parent dcc194e4bf
commit b6ae1453cb

View File

@ -275,7 +275,14 @@ pub struct Config {
pub registry: Registry,
}
fn create_compiler_and_run<R>(config: Config, f: impl FnOnce(&Compiler) -> R) -> R {
// JUSTIFICATION: before session exists, only config
#[allow(rustc::bad_opt_access)]
pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Send) -> R {
trace!("run_compiler");
util::run_in_thread_pool_with_globals(
config.opts.edition,
config.opts.unstable_opts.threads,
|| {
crate::callbacks::setup_callbacks();
let registry = &config.registry;
@ -325,16 +332,7 @@ fn create_compiler_and_run<R>(config: Config, f: impl FnOnce(&Compiler) -> R) ->
prof.generic_activity("drop_compiler").run(move || drop(compiler));
r
})
}
// JUSTIFICATION: before session exists, only config
#[allow(rustc::bad_opt_access)]
pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Send) -> R {
trace!("run_compiler");
util::run_in_thread_pool_with_globals(
config.opts.edition,
config.opts.unstable_opts.threads,
|| create_compiler_and_run(config, f),
},
)
}