about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicholas Nethercote <nnethercote@mozilla.com>2020-07-07 14:13:03 +1000
committerNicholas Nethercote <nnethercote@mozilla.com>2020-07-10 11:50:21 +1000
commit0a7d2970e5947e7a2940a32e6975817a389b0708 (patch)
treeb8abcc1e2afa21ee4af39ee9739da11cc82da19a
parente59b08e62ea691916d2f063cac5aab4634128022 (diff)
downloadrust-0a7d2970e5947e7a2940a32e6975817a389b0708.tar.gz
rust-0a7d2970e5947e7a2940a32e6975817a389b0708.zip
Eliminate `rust_input`.
It has a single call site and having it as a separate (higher-order!)
function makes the code harder to read.
-rw-r--r--src/librustdoc/lib.rs54
1 files changed, 23 insertions, 31 deletions
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs
index 8e2dd77cc11..b02880ab4d3 100644
--- a/src/librustdoc/lib.rs
+++ b/src/librustdoc/lib.rs
@@ -471,7 +471,29 @@ fn main_options(options: config::Options) -> i32 {
     // but we can't crates the Handler ahead of time because it's not Send
     let diag_opts = (options.error_format, options.edition, options.debugging_options.clone());
     let show_coverage = options.show_coverage;
-    rust_input(options, move |out| {
+
+    // First, parse the crate and extract all relevant information.
+    info!("starting to run rustc");
+
+    // Interpret the input file as a rust source file, passing it through the
+    // compiler all the way through the analysis passes. The rustdoc output is
+    // then generated from the cleaned AST of the crate. This runs all the
+    // plug/cleaning passes.
+    let result = rustc_driver::catch_fatal_errors(move || {
+        let crate_name = options.crate_name.clone();
+        let crate_version = options.crate_version.clone();
+        let (mut krate, renderinfo, renderopts) = core::run_core(options);
+
+        info!("finished with rustc");
+
+        if let Some(name) = crate_name {
+            krate.name = name
+        }
+
+        krate.version = crate_version;
+
+        let out = Output { krate, renderinfo, renderopts };
+
         if show_coverage {
             // if we ran coverage, bail early, we don't need to also generate docs at this point
             // (also we didn't load in any of the useful passes)
@@ -491,36 +513,6 @@ fn main_options(options: config::Options) -> i32 {
                 rustc_driver::EXIT_FAILURE
             }
         }
-    })
-}
-
-/// Interprets the input file as a rust source file, passing it through the
-/// compiler all the way through the analysis passes. The rustdoc output is then
-/// generated from the cleaned AST of the crate.
-///
-/// This form of input will run all of the plug/cleaning passes
-fn rust_input<R, F>(options: config::Options, f: F) -> R
-where
-    R: 'static + Send,
-    F: 'static + Send + FnOnce(Output) -> R,
-{
-    // First, parse the crate and extract all relevant information.
-    info!("starting to run rustc");
-
-    let result = rustc_driver::catch_fatal_errors(move || {
-        let crate_name = options.crate_name.clone();
-        let crate_version = options.crate_version.clone();
-        let (mut krate, renderinfo, renderopts) = core::run_core(options);
-
-        info!("finished with rustc");
-
-        if let Some(name) = crate_name {
-            krate.name = name
-        }
-
-        krate.version = crate_version;
-
-        f(Output { krate, renderinfo, renderopts })
     });
 
     match result {