Skip to content

Commit 0f41401

Browse files
committed
Auto merge of #63827 - andjo403:out-of-process-rustc-in-rustdoc, r=Mark-Simulacrum
Run doctests via out-of-process rustc closes #63638
2 parents 19a38de + b304cd0 commit 0f41401

File tree

4 files changed

+91
-151
lines changed

4 files changed

+91
-151
lines changed

src/librustc_driver/lib.rs

+9
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,15 @@ fn make_input(free_matches: &[String]) -> Option<(Input, Option<PathBuf>, Option
439439
} else {
440440
None
441441
};
442+
if let Ok(path) = env::var("UNSTABLE_RUSTDOC_TEST_PATH") {
443+
let line = env::var("UNSTABLE_RUSTDOC_TEST_LINE").
444+
expect("when UNSTABLE_RUSTDOC_TEST_PATH is set \
445+
UNSTABLE_RUSTDOC_TEST_LINE also needs to be set");
446+
let line = isize::from_str_radix(&line, 10).
447+
expect("UNSTABLE_RUSTDOC_TEST_LINE needs to be an number");
448+
let file_name = FileName::doc_test_source_code(PathBuf::from(path), line);
449+
return Some((Input::Str { name: file_name, input: src }, None, err));
450+
}
442451
Some((Input::Str { name: FileName::anon_source_code(&src), input: src },
443452
None, err))
444453
} else {

src/librustdoc/config.rs

+12
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,18 @@ pub struct Options {
3939
pub error_format: ErrorOutputType,
4040
/// Library search paths to hand to the compiler.
4141
pub libs: Vec<SearchPath>,
42+
/// Library search paths strings to hand to the compiler.
43+
pub lib_strs: Vec<String>,
4244
/// The list of external crates to link against.
4345
pub externs: Externs,
46+
/// The list of external crates strings to link against.
47+
pub extern_strs: Vec<String>,
4448
/// List of `cfg` flags to hand to the compiler. Always includes `rustdoc`.
4549
pub cfgs: Vec<String>,
4650
/// Codegen options to hand to the compiler.
4751
pub codegen_options: CodegenOptions,
52+
/// Codegen options strings to hand to the compiler.
53+
pub codegen_options_strs: Vec<String>,
4854
/// Debugging (`-Z`) options to pass to the compiler.
4955
pub debugging_options: DebuggingOptions,
5056
/// The target used to compile the crate against.
@@ -461,6 +467,9 @@ impl Options {
461467
let generate_search_filter = !matches.opt_present("disable-per-crate-search");
462468
let persist_doctests = matches.opt_str("persist-doctests").map(PathBuf::from);
463469
let generate_redirect_pages = matches.opt_present("generate-redirect-pages");
470+
let codegen_options_strs = matches.opt_strs("C");
471+
let lib_strs = matches.opt_strs("L");
472+
let extern_strs = matches.opt_strs("extern");
464473

465474
let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format);
466475

@@ -470,9 +479,12 @@ impl Options {
470479
proc_macro_crate,
471480
error_format,
472481
libs,
482+
lib_strs,
473483
externs,
484+
extern_strs,
474485
cfgs,
475486
codegen_options,
487+
codegen_options_strs,
476488
debugging_options,
477489
target,
478490
edition,

src/librustdoc/markdown.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,8 @@ pub fn test(mut options: Options, diag: &errors::Handler) -> i32 {
142142
let mut opts = TestOptions::default();
143143
opts.no_crate_inject = true;
144144
opts.display_warnings = options.display_warnings;
145-
let mut collector = Collector::new(options.input.display().to_string(), options.cfgs,
146-
options.libs, options.codegen_options, options.externs,
147-
true, opts, options.maybe_sysroot, None,
148-
Some(options.input),
149-
options.linker, options.edition, options.persist_doctests);
145+
let mut collector = Collector::new(options.input.display().to_string(), options.clone(),
146+
true, opts, None, Some(options.input));
150147
collector.set_position(DUMMY_SP);
151148
let codes = ErrorCodes::from(UnstableFeatures::from_environment().is_nightly_build());
152149

0 commit comments

Comments
 (0)