Skip to content

Commit 059d6cf

Browse files
committed
Change some function names.
A couple of these are quite long, but they do a much better job of explaining what they do, which was non-obvious before.
1 parent 4ad5de2 commit 059d6cf

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

src/librustc_interface/interface.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,7 @@ pub struct Config {
159159
pub registry: Registry,
160160
}
161161

162-
pub fn run_compiler_in_existing_thread_pool<R>(
163-
config: Config,
164-
f: impl FnOnce(&Compiler) -> R,
165-
) -> R {
162+
pub fn create_compiler_and_run<R>(config: Config, f: impl FnOnce(&Compiler) -> R) -> R {
166163
let registry = &config.registry;
167164
let (sess, codegen_backend) = util::create_session(
168165
config.opts,
@@ -204,17 +201,20 @@ pub fn run_compiler_in_existing_thread_pool<R>(
204201
pub fn run_compiler<R: Send>(mut config: Config, f: impl FnOnce(&Compiler) -> R + Send) -> R {
205202
log::trace!("run_compiler");
206203
let stderr = config.stderr.take();
207-
util::spawn_thread_pool(
204+
util::setup_callbacks_and_run_in_thread_pool_with_globals(
208205
config.opts.edition,
209206
config.opts.debugging_opts.threads,
210207
&stderr,
211-
|| run_compiler_in_existing_thread_pool(config, f),
208+
|| create_compiler_and_run(config, f),
212209
)
213210
}
214211

215-
pub fn default_thread_pool<R: Send>(edition: edition::Edition, f: impl FnOnce() -> R + Send) -> R {
212+
pub fn setup_callbacks_and_run_in_default_thread_pool_with_globals<R: Send>(
213+
edition: edition::Edition,
214+
f: impl FnOnce() -> R + Send,
215+
) -> R {
216216
// the 1 here is duplicating code in config.opts.debugging_opts.threads
217217
// which also defaults to 1; it ultimately doesn't matter as the default
218218
// isn't threaded, and just ignores this parameter
219-
util::spawn_thread_pool(edition, 1, &None, f)
219+
util::setup_callbacks_and_run_in_thread_pool_with_globals(edition, 1, &None, f)
220220
}

src/librustc_interface/util.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ pub fn scoped_thread<F: FnOnce() -> R + Send, R: Send>(cfg: thread::Builder, f:
128128
}
129129

130130
#[cfg(not(parallel_compiler))]
131-
pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>(
131+
pub fn setup_callbacks_and_run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>(
132132
edition: Edition,
133133
_threads: usize,
134134
stderr: &Option<Arc<Mutex<Vec<u8>>>>,
@@ -157,7 +157,7 @@ pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>(
157157
}
158158

159159
#[cfg(parallel_compiler)]
160-
pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>(
160+
pub fn setup_callbacks_and_run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>(
161161
edition: Edition,
162162
threads: usize,
163163
stderr: &Option<Arc<Mutex<Vec<u8>>>>,

src/librustdoc/core.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
376376
registry: rustc_driver::diagnostics_registry(),
377377
};
378378

379-
interface::run_compiler_in_existing_thread_pool(config, |compiler| {
379+
interface::create_compiler_and_run(config, |compiler| {
380380
compiler.enter(|queries| {
381381
let sess = compiler.session();
382382

src/librustdoc/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,10 @@ fn main_args(args: &[String]) -> i32 {
437437
Ok(opts) => opts,
438438
Err(code) => return code,
439439
};
440-
rustc_interface::interface::default_thread_pool(options.edition, move || main_options(options))
440+
rustc_interface::interface::setup_callbacks_and_run_in_default_thread_pool_with_globals(
441+
options.edition,
442+
move || main_options(options),
443+
)
441444
}
442445

443446
fn wrap_return(diag: &rustc_errors::Handler, res: Result<(), String>) -> i32 {

0 commit comments

Comments
 (0)