doctest: Rename options to rustdoc_options

These are the rustdoc-wide options. It's easy to confuse them with
options for doctests in particular, so this change should help.
This commit is contained in:
Noah Lev 2021-12-03 19:54:38 -08:00
parent 5e33e6affd
commit 9afa190c44

View file

@ -29,7 +29,7 @@ use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Mutex};
use crate::clean::{types::AttributesExt, Attributes};
use crate::config::Options;
use crate::config::Options as RustdocOptions;
use crate::html::markdown::{self, ErrorCodes, Ignore, LangString};
use crate::lint::init_lints;
use crate::passes::span_of_attrs;
@ -43,7 +43,7 @@ crate struct GlobalTestOptions {
crate attrs: Vec<String>,
}
crate fn run(options: Options) -> Result<(), ErrorReported> {
crate fn run(options: RustdocOptions) -> Result<(), ErrorReported> {
let input = config::Input::File(options.input.clone());
let invalid_codeblock_attributes_name = crate::lint::INVALID_CODEBLOCK_ATTRIBUTES.name;
@ -293,7 +293,7 @@ fn run_test(
test: &str,
crate_name: &str,
line: usize,
options: Options,
rustdoc_options: RustdocOptions,
mut lang_string: LangString,
no_run: bool,
runtool: Option<String>,
@ -311,16 +311,16 @@ fn run_test(
let output_file = outdir.path().join("rust_out");
let rustc_binary = options
let rustc_binary = rustdoc_options
.test_builder
.as_deref()
.unwrap_or_else(|| rustc_interface::util::rustc_path().expect("found rustc"));
let mut compiler = Command::new(&rustc_binary);
compiler.arg("--crate-type").arg("bin");
for cfg in &options.cfgs {
for cfg in &rustdoc_options.cfgs {
compiler.arg("--cfg").arg(&cfg);
}
if let Some(sysroot) = options.maybe_sysroot {
if let Some(sysroot) = rustdoc_options.maybe_sysroot {
compiler.arg("--sysroot").arg(sysroot);
}
compiler.arg("--edition").arg(&edition.to_string());
@ -330,26 +330,26 @@ fn run_test(
if lang_string.test_harness {
compiler.arg("--test");
}
if options.json_unused_externs && !lang_string.compile_fail {
if rustdoc_options.json_unused_externs && !lang_string.compile_fail {
compiler.arg("--error-format=json");
compiler.arg("--json").arg("unused-externs");
compiler.arg("-Z").arg("unstable-options");
compiler.arg("-W").arg("unused_crate_dependencies");
}
for lib_str in &options.lib_strs {
for lib_str in &rustdoc_options.lib_strs {
compiler.arg("-L").arg(&lib_str);
}
for extern_str in &options.extern_strs {
for extern_str in &rustdoc_options.extern_strs {
compiler.arg("--extern").arg(&extern_str);
}
compiler.arg("-Ccodegen-units=1");
for codegen_options_str in &options.codegen_options_strs {
for codegen_options_str in &rustdoc_options.codegen_options_strs {
compiler.arg("-C").arg(&codegen_options_str);
}
for debugging_option_str in &options.debugging_opts_strs {
for debugging_option_str in &rustdoc_options.debugging_opts_strs {
compiler.arg("-Z").arg(&debugging_option_str);
}
if no_run && !lang_string.compile_fail && options.persist_doctests.is_none() {
if no_run && !lang_string.compile_fail && rustdoc_options.persist_doctests.is_none() {
compiler.arg("--emit=metadata");
}
compiler.arg("--target").arg(match target {
@ -358,7 +358,7 @@ fn run_test(
path.to_str().expect("target path must be valid unicode").to_string()
}
});
if let ErrorOutputType::HumanReadable(kind) = options.error_format {
if let ErrorOutputType::HumanReadable(kind) = rustdoc_options.error_format {
let (short, color_config) = kind.unzip();
if short {
@ -452,11 +452,11 @@ fn run_test(
} else {
cmd = Command::new(output_file);
}
if let Some(run_directory) = options.test_run_directory {
if let Some(run_directory) = rustdoc_options.test_run_directory {
cmd.current_dir(run_directory);
}
let result = if options.nocapture {
let result = if rustdoc_options.nocapture {
cmd.status().map(|status| process::Output {
status,
stdout: Vec::new(),
@ -802,7 +802,7 @@ crate struct Collector {
// the `names` vector of that test will be `["Title", "Subtitle"]`.
names: Vec<String>,
options: Options,
rustdoc_options: RustdocOptions,
use_headers: bool,
enable_per_target_ignores: bool,
crate_name: Symbol,
@ -818,7 +818,7 @@ crate struct Collector {
impl Collector {
crate fn new(
crate_name: Symbol,
options: Options,
rustdoc_options: RustdocOptions,
use_headers: bool,
opts: GlobalTestOptions,
source_map: Option<Lrc<SourceMap>>,
@ -828,7 +828,7 @@ impl Collector {
Collector {
tests: Vec::new(),
names: Vec::new(),
options,
rustdoc_options,
use_headers,
enable_per_target_ignores,
crate_name,
@ -882,14 +882,14 @@ impl Tester for Collector {
let name = self.generate_name(line, &filename);
let crate_name = self.crate_name.to_string();
let opts = self.opts.clone();
let edition = config.edition.unwrap_or(self.options.edition);
let options = self.options.clone();
let runtool = self.options.runtool.clone();
let runtool_args = self.options.runtool_args.clone();
let target = self.options.target.clone();
let edition = config.edition.unwrap_or(self.rustdoc_options.edition);
let rustdoc_options = self.rustdoc_options.clone();
let runtool = self.rustdoc_options.runtool.clone();
let runtool_args = self.rustdoc_options.runtool_args.clone();
let target = self.rustdoc_options.target.clone();
let target_str = target.to_string();
let unused_externs = self.unused_extern_reports.clone();
let no_run = config.no_run || options.no_run;
let no_run = config.no_run || rustdoc_options.no_run;
if !config.compile_fail {
self.compiling_test_count.fetch_add(1, Ordering::SeqCst);
}
@ -923,7 +923,7 @@ impl Tester for Collector {
self.visited_tests.entry((file.clone(), line)).and_modify(|v| *v += 1).or_insert(0)
},
);
let outdir = if let Some(mut path) = options.persist_doctests.clone() {
let outdir = if let Some(mut path) = rustdoc_options.persist_doctests.clone() {
path.push(&test_id);
std::fs::create_dir_all(&path)
@ -963,7 +963,7 @@ impl Tester for Collector {
&test,
&crate_name,
line,
options,
rustdoc_options,
config,
no_run,
runtool,