diff options
| author | EtomicBomb <ethan@ethan.ws> | 2024-08-26 21:40:52 -0700 |
|---|---|---|
| committer | ethan <ethan@localhost.localdomain> | 2024-09-07 18:57:48 -0400 |
| commit | 3782251c2c6e6e7fedb806a97664ee38ced1677b (patch) | |
| tree | f3058660ca68b53512278af54fdce0528751b5a6 /src/librustdoc/doctest | |
| parent | ec867f03bcd6c39156ef13eb5f85bf4fb924ca29 (diff) | |
| download | rust-3782251c2c6e6e7fedb806a97664ee38ced1677b.tar.gz rust-3782251c2c6e6e7fedb806a97664ee38ced1677b.zip | |
librustdoc::config: removed Input from Options
The `librustdoc::config::Options` struct no longer includes `rustc_session::config::Input`. This is so that Input can be optional. In rfc#3662, the crate input is not required if `--merge=finalize`. Replacing Input with Option<Input> was decided against. In most places that Input is needed, it should be statically known to not be optional (means fewer unwraps). We just want to have an Input-free Options in librustdoc::main_args, where we can run the write shared procedure.
Diffstat (limited to 'src/librustdoc/doctest')
| -rw-r--r-- | src/librustdoc/doctest/markdown.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/librustdoc/doctest/markdown.rs b/src/librustdoc/doctest/markdown.rs index 9a237f8684d..4f83bd5e882 100644 --- a/src/librustdoc/doctest/markdown.rs +++ b/src/librustdoc/doctest/markdown.rs @@ -3,6 +3,7 @@ use std::fs::read_to_string; use std::sync::{Arc, Mutex}; +use rustc_session::config::Input; use rustc_span::FileName; use tempfile::tempdir; @@ -69,9 +70,8 @@ impl DocTestVisitor for MdCollector { } /// Runs any tests/code examples in the markdown file `options.input`. -pub(crate) fn test(options: Options) -> Result<(), String> { - use rustc_session::config::Input; - let input_str = match &options.input { +pub(crate) fn test(input: &Input, options: Options) -> Result<(), String> { + let input_str = match input { Input::File(path) => { read_to_string(path).map_err(|err| format!("{}: {err}", path.display()))? } @@ -79,7 +79,7 @@ pub(crate) fn test(options: Options) -> Result<(), String> { }; // Obviously not a real crate name, but close enough for purposes of doctests. - let crate_name = options.input.filestem().to_string(); + let crate_name = input.filestem().to_string(); let temp_dir = tempdir().map_err(|error| format!("failed to create temporary directory: {error:?}"))?; let args_file = temp_dir.path().join("rustdoc-cfgs"); @@ -96,8 +96,7 @@ pub(crate) fn test(options: Options) -> Result<(), String> { let mut md_collector = MdCollector { tests: vec![], cur_path: vec![], - filename: options - .input + filename: input .opt_path() .map(ToOwned::to_owned) .map(FileName::from) |
