Skip to content

Commit 0a7d297

Browse files
committed
Eliminate rust_input.
It has a single call site and having it as a separate (higher-order!) function makes the code harder to read.
1 parent e59b08e commit 0a7d297

File tree

1 file changed

+23
-31
lines changed

1 file changed

+23
-31
lines changed

src/librustdoc/lib.rs

+23-31
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,29 @@ fn main_options(options: config::Options) -> i32 {
471471
// but we can't crates the Handler ahead of time because it's not Send
472472
let diag_opts = (options.error_format, options.edition, options.debugging_options.clone());
473473
let show_coverage = options.show_coverage;
474-
rust_input(options, move |out| {
474+
475+
// First, parse the crate and extract all relevant information.
476+
info!("starting to run rustc");
477+
478+
// Interpret the input file as a rust source file, passing it through the
479+
// compiler all the way through the analysis passes. The rustdoc output is
480+
// then generated from the cleaned AST of the crate. This runs all the
481+
// plug/cleaning passes.
482+
let result = rustc_driver::catch_fatal_errors(move || {
483+
let crate_name = options.crate_name.clone();
484+
let crate_version = options.crate_version.clone();
485+
let (mut krate, renderinfo, renderopts) = core::run_core(options);
486+
487+
info!("finished with rustc");
488+
489+
if let Some(name) = crate_name {
490+
krate.name = name
491+
}
492+
493+
krate.version = crate_version;
494+
495+
let out = Output { krate, renderinfo, renderopts };
496+
475497
if show_coverage {
476498
// if we ran coverage, bail early, we don't need to also generate docs at this point
477499
// (also we didn't load in any of the useful passes)
@@ -491,36 +513,6 @@ fn main_options(options: config::Options) -> i32 {
491513
rustc_driver::EXIT_FAILURE
492514
}
493515
}
494-
})
495-
}
496-
497-
/// Interprets the input file as a rust source file, passing it through the
498-
/// compiler all the way through the analysis passes. The rustdoc output is then
499-
/// generated from the cleaned AST of the crate.
500-
///
501-
/// This form of input will run all of the plug/cleaning passes
502-
fn rust_input<R, F>(options: config::Options, f: F) -> R
503-
where
504-
R: 'static + Send,
505-
F: 'static + Send + FnOnce(Output) -> R,
506-
{
507-
// First, parse the crate and extract all relevant information.
508-
info!("starting to run rustc");
509-
510-
let result = rustc_driver::catch_fatal_errors(move || {
511-
let crate_name = options.crate_name.clone();
512-
let crate_version = options.crate_version.clone();
513-
let (mut krate, renderinfo, renderopts) = core::run_core(options);
514-
515-
info!("finished with rustc");
516-
517-
if let Some(name) = crate_name {
518-
krate.name = name
519-
}
520-
521-
krate.version = crate_version;
522-
523-
f(Output { krate, renderinfo, renderopts })
524516
});
525517

526518
match result {

0 commit comments

Comments
 (0)