about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicholas Nethercote <nnethercote@mozilla.com>2020-07-07 13:41:08 +1000
committerNicholas Nethercote <nnethercote@mozilla.com>2020-07-10 16:07:20 +1000
commitbf7078615b868f7359bff58933fd5236fabe7280 (patch)
tree728c7ab4d4e1ca9ec5562cf29ea332d4205cf327
parent4ad5de22d182578e846a6ccc69940e76a820381c (diff)
downloadrust-bf7078615b868f7359bff58933fd5236fabe7280.tar.gz
rust-bf7078615b868f7359bff58933fd5236fabe7280.zip
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.
-rw-r--r--src/librustc_interface/interface.rs16
-rw-r--r--src/librustc_interface/util.rs6
-rw-r--r--src/librustdoc/core.rs2
-rw-r--r--src/librustdoc/lib.rs5
4 files changed, 16 insertions, 13 deletions
diff --git a/src/librustc_interface/interface.rs b/src/librustc_interface/interface.rs
index f89be02099e..e50622a0053 100644
--- a/src/librustc_interface/interface.rs
+++ b/src/librustc_interface/interface.rs
@@ -159,10 +159,7 @@ pub struct Config {
     pub registry: Registry,
 }
 
-pub fn run_compiler_in_existing_thread_pool<R>(
-    config: Config,
-    f: impl FnOnce(&Compiler) -> R,
-) -> R {
+pub fn create_compiler_and_run<R>(config: Config, f: impl FnOnce(&Compiler) -> R) -> R {
     let registry = &config.registry;
     let (sess, codegen_backend) = util::create_session(
         config.opts,
@@ -204,17 +201,20 @@ pub fn run_compiler_in_existing_thread_pool<R>(
 pub fn run_compiler<R: Send>(mut config: Config, f: impl FnOnce(&Compiler) -> R + Send) -> R {
     log::trace!("run_compiler");
     let stderr = config.stderr.take();
-    util::spawn_thread_pool(
+    util::setup_callbacks_and_run_in_thread_pool_with_globals(
         config.opts.edition,
         config.opts.debugging_opts.threads,
         &stderr,
-        || run_compiler_in_existing_thread_pool(config, f),
+        || create_compiler_and_run(config, f),
     )
 }
 
-pub fn default_thread_pool<R: Send>(edition: edition::Edition, f: impl FnOnce() -> R + Send) -> R {
+pub fn setup_callbacks_and_run_in_default_thread_pool_with_globals<R: Send>(
+    edition: edition::Edition,
+    f: impl FnOnce() -> R + Send,
+) -> R {
     // the 1 here is duplicating code in config.opts.debugging_opts.threads
     // which also defaults to 1; it ultimately doesn't matter as the default
     // isn't threaded, and just ignores this parameter
-    util::spawn_thread_pool(edition, 1, &None, f)
+    util::setup_callbacks_and_run_in_thread_pool_with_globals(edition, 1, &None, f)
 }
diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs
index dc82219b332..fb5f3581b6d 100644
--- a/src/librustc_interface/util.rs
+++ b/src/librustc_interface/util.rs
@@ -128,7 +128,7 @@ pub fn scoped_thread<F: FnOnce() -> R + Send, R: Send>(cfg: thread::Builder, f:
 }
 
 #[cfg(not(parallel_compiler))]
-pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>(
+pub fn setup_callbacks_and_run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>(
     edition: Edition,
     _threads: usize,
     stderr: &Option<Arc<Mutex<Vec<u8>>>>,
@@ -157,7 +157,7 @@ pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>(
 }
 
 #[cfg(parallel_compiler)]
-pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>(
+pub fn setup_callbacks_and_run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>(
     edition: Edition,
     threads: usize,
     stderr: &Option<Arc<Mutex<Vec<u8>>>>,
@@ -186,7 +186,7 @@ pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>(
                 // span_session_globals are captured and set on the new
                 // threads. ty::tls::with_thread_locals sets up thread local
                 // callbacks from librustc_ast.
-                let main_handler = move |thread: ThreadBuilder| {
+                let main_handler = move |thread: rayon::ThreadBuilder| {
                     rustc_ast::SESSION_GLOBALS.set(ast_session_globals, || {
                         rustc_span::SESSION_GLOBALS.set(span_session_globals, || {
                             ty::tls::GCX_PTR.set(&Lock::new(0), || {
diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs
index db98ec5d0a7..80cc5182bef 100644
--- a/src/librustdoc/core.rs
+++ b/src/librustdoc/core.rs
@@ -376,7 +376,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
         registry: rustc_driver::diagnostics_registry(),
     };
 
-    interface::run_compiler_in_existing_thread_pool(config, |compiler| {
+    interface::create_compiler_and_run(config, |compiler| {
         compiler.enter(|queries| {
             let sess = compiler.session();
 
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs
index b02880ab4d3..57151e2b200 100644
--- a/src/librustdoc/lib.rs
+++ b/src/librustdoc/lib.rs
@@ -437,7 +437,10 @@ fn main_args(args: &[String]) -> i32 {
         Ok(opts) => opts,
         Err(code) => return code,
     };
-    rustc_interface::interface::default_thread_pool(options.edition, move || main_options(options))
+    rustc_interface::interface::setup_callbacks_and_run_in_default_thread_pool_with_globals(
+        options.edition,
+        move || main_options(options),
+    )
 }
 
 fn wrap_return(diag: &rustc_errors::Handler, res: Result<(), String>) -> i32 {