Skip to content

Commit 0ac58f7

Browse files
committed
Split apart create_config and run_core
1 parent caeb333 commit 0ac58f7

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

src/librustdoc/core.rs

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,9 @@ where
273273
(lint_opts, lint_caps)
274274
}
275275

276-
crate fn run_core(
277-
options: RustdocOptions,
278-
) -> (clean::Crate, RenderInfo, RenderOptions, Lrc<Session>) {
279-
// Parse, resolve, and typecheck the given crate.
280-
281-
let RustdocOptions {
276+
/// Parse, resolve, and typecheck the given crate.
277+
fn create_config(
278+
RustdocOptions {
282279
input,
283280
crate_name,
284281
proc_macro_crate,
@@ -294,21 +291,10 @@ crate fn run_core(
294291
lint_opts,
295292
describe_lints,
296293
lint_cap,
297-
default_passes,
298-
manual_passes,
299294
display_warnings,
300-
render_options,
301-
output_format,
302295
..
303-
} = options;
304-
305-
let extern_names: Vec<String> = externs
306-
.iter()
307-
.filter(|(_, entry)| entry.add_prelude)
308-
.map(|(name, _)| name)
309-
.cloned()
310-
.collect();
311-
296+
}: RustdocOptions,
297+
) -> rustc_interface::Config {
312298
// Add the doc cfg into the doc build.
313299
cfgs.push("doc".to_string());
314300

@@ -374,7 +360,7 @@ crate fn run_core(
374360
..Options::default()
375361
};
376362

377-
let config = interface::Config {
363+
interface::Config {
378364
opts: sessopts,
379365
crate_cfg: interface::parse_cfgspecs(cfgs),
380366
input,
@@ -417,7 +403,25 @@ crate fn run_core(
417403
}),
418404
make_codegen_backend: None,
419405
registry: rustc_driver::diagnostics_registry(),
420-
};
406+
}
407+
}
408+
409+
crate fn run_core(
410+
options: RustdocOptions,
411+
) -> (clean::Crate, RenderInfo, RenderOptions, Lrc<Session>) {
412+
let extern_names: Vec<String> = options
413+
.externs
414+
.iter()
415+
.filter(|(_, entry)| entry.add_prelude)
416+
.map(|(name, _)| name)
417+
.cloned()
418+
.collect();
419+
let default_passes = options.default_passes;
420+
let output_format = options.output_format;
421+
// TODO: fix this clone (especially render_options)
422+
let manual_passes = options.manual_passes.clone();
423+
let render_options = options.render_options.clone();
424+
let config = create_config(options);
421425

422426
interface::create_compiler_and_run(config, |compiler| {
423427
compiler.enter(|queries| {

0 commit comments

Comments
 (0)