Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f827364

Browse files
committedSep 10, 2024
Auto merge of #129337 - EtomicBomb:rfc, r=notriddle
rustdoc rfc#3662 changes under unstable flags * All new functionality is under unstable options * Adds `--merge=shared|none|finalize` flags * Adds `--parts-out-dir=<crate specific directory>` for `--merge=none` to write cross-crate info file for a single crate * Adds `--include-parts-dir=<previously specified directory>` for `--merge=finalize` to write cross-crate info files * `tests/rustdoc/` tests for the new flags
2 parents 26b2b8d + 548b6e1 commit f827364

File tree

51 files changed

+953
-169
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+953
-169
lines changed
 

‎src/librustdoc/doctest.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use rustc_errors::{ColorConfig, DiagCtxtHandle, ErrorGuaranteed, FatalError};
1919
use rustc_hir::def_id::LOCAL_CRATE;
2020
use rustc_hir::CRATE_HIR_ID;
2121
use rustc_interface::interface;
22-
use rustc_session::config::{self, CrateType, ErrorOutputType};
22+
use rustc_session::config::{self, CrateType, ErrorOutputType, Input};
2323
use rustc_session::lint;
2424
use rustc_span::edition::Edition;
2525
use rustc_span::symbol::sym;
@@ -88,7 +88,11 @@ fn get_doctest_dir() -> io::Result<TempDir> {
8888
TempFileBuilder::new().prefix("rustdoctest").tempdir()
8989
}
9090

91-
pub(crate) fn run(dcx: DiagCtxtHandle<'_>, options: RustdocOptions) -> Result<(), ErrorGuaranteed> {
91+
pub(crate) fn run(
92+
dcx: DiagCtxtHandle<'_>,
93+
input: Input,
94+
options: RustdocOptions,
95+
) -> Result<(), ErrorGuaranteed> {
9296
let invalid_codeblock_attributes_name = crate::lint::INVALID_CODEBLOCK_ATTRIBUTES.name;
9397

9498
// See core::create_config for what's going on here.
@@ -135,7 +139,7 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, options: RustdocOptions) -> Result<()
135139
opts: sessopts,
136140
crate_cfg: cfgs,
137141
crate_check_cfg: options.check_cfgs.clone(),
138-
input: options.input.clone(),
142+
input: input.clone(),
139143
output_file: None,
140144
output_dir: None,
141145
file_loader: None,

‎src/librustdoc/doctest/markdown.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use std::fs::read_to_string;
44
use std::sync::{Arc, Mutex};
55

6+
use rustc_session::config::Input;
67
use rustc_span::FileName;
78
use tempfile::tempdir;
89

@@ -69,17 +70,16 @@ impl DocTestVisitor for MdCollector {
6970
}
7071

7172
/// Runs any tests/code examples in the markdown file `options.input`.
72-
pub(crate) fn test(options: Options) -> Result<(), String> {
73-
use rustc_session::config::Input;
74-
let input_str = match &options.input {
73+
pub(crate) fn test(input: &Input, options: Options) -> Result<(), String> {
74+
let input_str = match input {
7575
Input::File(path) => {
7676
read_to_string(path).map_err(|err| format!("{}: {err}", path.display()))?
7777
}
7878
Input::Str { name: _, input } => input.clone(),
7979
};
8080

8181
// Obviously not a real crate name, but close enough for purposes of doctests.
82-
let crate_name = options.input.filestem().to_string();
82+
let crate_name = input.filestem().to_string();
8383
let temp_dir =
8484
tempdir().map_err(|error| format!("failed to create temporary directory: {error:?}"))?;
8585
let args_file = temp_dir.path().join("rustdoc-cfgs");
@@ -96,8 +96,7 @@ pub(crate) fn test(options: Options) -> Result<(), String> {
9696
let mut md_collector = MdCollector {
9797
tests: vec![],
9898
cur_path: vec![],
99-
filename: options
100-
.input
99+
filename: input
101100
.opt_path()
102101
.map(ToOwned::to_owned)
103102
.map(FileName::from)
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.