Skip to content

Commit

Permalink
Auto merge of #63827 - andjo403:out-of-process-rustc-in-rustdoc, r=Ma…
Browse files Browse the repository at this point in the history
…rk-Simulacrum

Run doctests via out-of-process rustc

closes #63638
  • Loading branch information
bors committed Aug 30, 2019
2 parents 19a38de + b304cd0 commit 0f41401
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 151 deletions.
9 changes: 9 additions & 0 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,15 @@ fn make_input(free_matches: &[String]) -> Option<(Input, Option<PathBuf>, Option
} else {
None
};
if let Ok(path) = env::var("UNSTABLE_RUSTDOC_TEST_PATH") {
let line = env::var("UNSTABLE_RUSTDOC_TEST_LINE").
expect("when UNSTABLE_RUSTDOC_TEST_PATH is set \
UNSTABLE_RUSTDOC_TEST_LINE also needs to be set");
let line = isize::from_str_radix(&line, 10).
expect("UNSTABLE_RUSTDOC_TEST_LINE needs to be an number");
let file_name = FileName::doc_test_source_code(PathBuf::from(path), line);
return Some((Input::Str { name: file_name, input: src }, None, err));
}
Some((Input::Str { name: FileName::anon_source_code(&src), input: src },
None, err))
} else {
Expand Down
12 changes: 12 additions & 0 deletions src/librustdoc/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,18 @@ pub struct Options {
pub error_format: ErrorOutputType,
/// Library search paths to hand to the compiler.
pub libs: Vec<SearchPath>,
/// Library search paths strings to hand to the compiler.
pub lib_strs: Vec<String>,
/// The list of external crates to link against.
pub externs: Externs,
/// The list of external crates strings to link against.
pub extern_strs: Vec<String>,
/// List of `cfg` flags to hand to the compiler. Always includes `rustdoc`.
pub cfgs: Vec<String>,
/// Codegen options to hand to the compiler.
pub codegen_options: CodegenOptions,
/// Codegen options strings to hand to the compiler.
pub codegen_options_strs: Vec<String>,
/// Debugging (`-Z`) options to pass to the compiler.
pub debugging_options: DebuggingOptions,
/// The target used to compile the crate against.
Expand Down Expand Up @@ -461,6 +467,9 @@ impl Options {
let generate_search_filter = !matches.opt_present("disable-per-crate-search");
let persist_doctests = matches.opt_str("persist-doctests").map(PathBuf::from);
let generate_redirect_pages = matches.opt_present("generate-redirect-pages");
let codegen_options_strs = matches.opt_strs("C");
let lib_strs = matches.opt_strs("L");
let extern_strs = matches.opt_strs("extern");

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

Expand All @@ -470,9 +479,12 @@ impl Options {
proc_macro_crate,
error_format,
libs,
lib_strs,
externs,
extern_strs,
cfgs,
codegen_options,
codegen_options_strs,
debugging_options,
target,
edition,
Expand Down
7 changes: 2 additions & 5 deletions src/librustdoc/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,8 @@ pub fn test(mut options: Options, diag: &errors::Handler) -> i32 {
let mut opts = TestOptions::default();
opts.no_crate_inject = true;
opts.display_warnings = options.display_warnings;
let mut collector = Collector::new(options.input.display().to_string(), options.cfgs,
options.libs, options.codegen_options, options.externs,
true, opts, options.maybe_sysroot, None,
Some(options.input),
options.linker, options.edition, options.persist_doctests);
let mut collector = Collector::new(options.input.display().to_string(), options.clone(),
true, opts, None, Some(options.input));
collector.set_position(DUMMY_SP);
let codes = ErrorCodes::from(UnstableFeatures::from_environment().is_nightly_build());

Expand Down
Loading

0 comments on commit 0f41401

Please sign in to comment.