Skip to content

Commit 9afa190

Browse files
committed
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.
1 parent 5e33e6a commit 9afa190

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

Diff for: src/librustdoc/doctest.rs

+26-26
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use std::sync::atomic::{AtomicUsize, Ordering};
2929
use std::sync::{Arc, Mutex};
3030

3131
use crate::clean::{types::AttributesExt, Attributes};
32-
use crate::config::Options;
32+
use crate::config::Options as RustdocOptions;
3333
use crate::html::markdown::{self, ErrorCodes, Ignore, LangString};
3434
use crate::lint::init_lints;
3535
use crate::passes::span_of_attrs;
@@ -43,7 +43,7 @@ crate struct GlobalTestOptions {
4343
crate attrs: Vec<String>,
4444
}
4545

46-
crate fn run(options: Options) -> Result<(), ErrorReported> {
46+
crate fn run(options: RustdocOptions) -> Result<(), ErrorReported> {
4747
let input = config::Input::File(options.input.clone());
4848

4949
let invalid_codeblock_attributes_name = crate::lint::INVALID_CODEBLOCK_ATTRIBUTES.name;
@@ -293,7 +293,7 @@ fn run_test(
293293
test: &str,
294294
crate_name: &str,
295295
line: usize,
296-
options: Options,
296+
rustdoc_options: RustdocOptions,
297297
mut lang_string: LangString,
298298
no_run: bool,
299299
runtool: Option<String>,
@@ -311,16 +311,16 @@ fn run_test(
311311

312312
let output_file = outdir.path().join("rust_out");
313313

314-
let rustc_binary = options
314+
let rustc_binary = rustdoc_options
315315
.test_builder
316316
.as_deref()
317317
.unwrap_or_else(|| rustc_interface::util::rustc_path().expect("found rustc"));
318318
let mut compiler = Command::new(&rustc_binary);
319319
compiler.arg("--crate-type").arg("bin");
320-
for cfg in &options.cfgs {
320+
for cfg in &rustdoc_options.cfgs {
321321
compiler.arg("--cfg").arg(&cfg);
322322
}
323-
if let Some(sysroot) = options.maybe_sysroot {
323+
if let Some(sysroot) = rustdoc_options.maybe_sysroot {
324324
compiler.arg("--sysroot").arg(sysroot);
325325
}
326326
compiler.arg("--edition").arg(&edition.to_string());
@@ -330,26 +330,26 @@ fn run_test(
330330
if lang_string.test_harness {
331331
compiler.arg("--test");
332332
}
333-
if options.json_unused_externs && !lang_string.compile_fail {
333+
if rustdoc_options.json_unused_externs && !lang_string.compile_fail {
334334
compiler.arg("--error-format=json");
335335
compiler.arg("--json").arg("unused-externs");
336336
compiler.arg("-Z").arg("unstable-options");
337337
compiler.arg("-W").arg("unused_crate_dependencies");
338338
}
339-
for lib_str in &options.lib_strs {
339+
for lib_str in &rustdoc_options.lib_strs {
340340
compiler.arg("-L").arg(&lib_str);
341341
}
342-
for extern_str in &options.extern_strs {
342+
for extern_str in &rustdoc_options.extern_strs {
343343
compiler.arg("--extern").arg(&extern_str);
344344
}
345345
compiler.arg("-Ccodegen-units=1");
346-
for codegen_options_str in &options.codegen_options_strs {
346+
for codegen_options_str in &rustdoc_options.codegen_options_strs {
347347
compiler.arg("-C").arg(&codegen_options_str);
348348
}
349-
for debugging_option_str in &options.debugging_opts_strs {
349+
for debugging_option_str in &rustdoc_options.debugging_opts_strs {
350350
compiler.arg("-Z").arg(&debugging_option_str);
351351
}
352-
if no_run && !lang_string.compile_fail && options.persist_doctests.is_none() {
352+
if no_run && !lang_string.compile_fail && rustdoc_options.persist_doctests.is_none() {
353353
compiler.arg("--emit=metadata");
354354
}
355355
compiler.arg("--target").arg(match target {
@@ -358,7 +358,7 @@ fn run_test(
358358
path.to_str().expect("target path must be valid unicode").to_string()
359359
}
360360
});
361-
if let ErrorOutputType::HumanReadable(kind) = options.error_format {
361+
if let ErrorOutputType::HumanReadable(kind) = rustdoc_options.error_format {
362362
let (short, color_config) = kind.unzip();
363363

364364
if short {
@@ -452,11 +452,11 @@ fn run_test(
452452
} else {
453453
cmd = Command::new(output_file);
454454
}
455-
if let Some(run_directory) = options.test_run_directory {
455+
if let Some(run_directory) = rustdoc_options.test_run_directory {
456456
cmd.current_dir(run_directory);
457457
}
458458

459-
let result = if options.nocapture {
459+
let result = if rustdoc_options.nocapture {
460460
cmd.status().map(|status| process::Output {
461461
status,
462462
stdout: Vec::new(),
@@ -802,7 +802,7 @@ crate struct Collector {
802802
// the `names` vector of that test will be `["Title", "Subtitle"]`.
803803
names: Vec<String>,
804804

805-
options: Options,
805+
rustdoc_options: RustdocOptions,
806806
use_headers: bool,
807807
enable_per_target_ignores: bool,
808808
crate_name: Symbol,
@@ -818,7 +818,7 @@ crate struct Collector {
818818
impl Collector {
819819
crate fn new(
820820
crate_name: Symbol,
821-
options: Options,
821+
rustdoc_options: RustdocOptions,
822822
use_headers: bool,
823823
opts: GlobalTestOptions,
824824
source_map: Option<Lrc<SourceMap>>,
@@ -828,7 +828,7 @@ impl Collector {
828828
Collector {
829829
tests: Vec::new(),
830830
names: Vec::new(),
831-
options,
831+
rustdoc_options,
832832
use_headers,
833833
enable_per_target_ignores,
834834
crate_name,
@@ -882,14 +882,14 @@ impl Tester for Collector {
882882
let name = self.generate_name(line, &filename);
883883
let crate_name = self.crate_name.to_string();
884884
let opts = self.opts.clone();
885-
let edition = config.edition.unwrap_or(self.options.edition);
886-
let options = self.options.clone();
887-
let runtool = self.options.runtool.clone();
888-
let runtool_args = self.options.runtool_args.clone();
889-
let target = self.options.target.clone();
885+
let edition = config.edition.unwrap_or(self.rustdoc_options.edition);
886+
let rustdoc_options = self.rustdoc_options.clone();
887+
let runtool = self.rustdoc_options.runtool.clone();
888+
let runtool_args = self.rustdoc_options.runtool_args.clone();
889+
let target = self.rustdoc_options.target.clone();
890890
let target_str = target.to_string();
891891
let unused_externs = self.unused_extern_reports.clone();
892-
let no_run = config.no_run || options.no_run;
892+
let no_run = config.no_run || rustdoc_options.no_run;
893893
if !config.compile_fail {
894894
self.compiling_test_count.fetch_add(1, Ordering::SeqCst);
895895
}
@@ -923,7 +923,7 @@ impl Tester for Collector {
923923
self.visited_tests.entry((file.clone(), line)).and_modify(|v| *v += 1).or_insert(0)
924924
},
925925
);
926-
let outdir = if let Some(mut path) = options.persist_doctests.clone() {
926+
let outdir = if let Some(mut path) = rustdoc_options.persist_doctests.clone() {
927927
path.push(&test_id);
928928

929929
std::fs::create_dir_all(&path)
@@ -963,7 +963,7 @@ impl Tester for Collector {
963963
&test,
964964
&crate_name,
965965
line,
966-
options,
966+
rustdoc_options,
967967
config,
968968
no_run,
969969
runtool,

0 commit comments

Comments
 (0)