From 794434ec639277273d2154607bdcbe033691cc29 Mon Sep 17 00:00:00 2001
From: EtomicBomb <ethan@ethan.ws>
Date: Wed, 24 Jul 2024 21:52:32 +0000
Subject: [PATCH 1/6] initial implementation of rustdoc nested aux-build

---
 src/tools/compiletest/src/command-list.rs     |   2 +
 src/tools/compiletest/src/header.rs           |  13 +++
 src/tools/compiletest/src/runtest.rs          | 104 ++++++++++++------
 src/tools/compiletest/src/runtest/coverage.rs |   2 +-
 .../cargo-transitive-no-index/auxiliary/q.rs  |   4 +
 .../cargo-transitive-no-index/auxiliary/t.rs  |   6 +
 .../cargo-transitive-no-index/s.rs            |  17 +++
 .../cargo-transitive/auxiliary/q.rs           |   6 +
 .../cargo-transitive/auxiliary/t.rs           |   8 ++
 .../cross-crate-info/cargo-transitive/s.rs    |  24 ++++
 .../cargo-two-no-index/auxiliary/f.rs         |   4 +
 .../cross-crate-info/cargo-two-no-index/e.rs  |  15 +++
 .../cross-crate-info/cargo-two/auxiliary/f.rs |   6 +
 tests/rustdoc/cross-crate-info/cargo-two/e.rs |  21 ++++
 .../index-on-last/auxiliary/f.rs              |   4 +
 .../cross-crate-info/index-on-last/e.rs       |  21 ++++
 .../kitchen-sink/auxiliary/q.rs               |   6 +
 .../kitchen-sink/auxiliary/r.rs               |   8 ++
 .../kitchen-sink/auxiliary/s.rs               |   9 ++
 .../kitchen-sink/auxiliary/t.rs               |   8 ++
 .../cross-crate-info/kitchen-sink/i.rs        |  32 ++++++
 .../single-crate-baseline/q.rs                |  13 +++
 .../single-crate-no-index/q.rs                |   8 ++
 .../transitive/auxiliary/q.rs                 |   4 +
 .../transitive/auxiliary/t.rs                 |   6 +
 .../rustdoc/cross-crate-info/transitive/s.rs  |   9 ++
 .../cross-crate-info/two/auxiliary/f.rs       |   4 +
 tests/rustdoc/cross-crate-info/two/e.rs       |   9 ++
 .../working-dir-examples/q.rs                 |  10 ++
 .../write-docs-somewhere-else/auxiliary/f.rs  |   5 +
 .../write-docs-somewhere-else/e.rs            |  15 +++
 31 files changed, 369 insertions(+), 34 deletions(-)
 create mode 100644 tests/rustdoc/cross-crate-info/cargo-transitive-no-index/auxiliary/q.rs
 create mode 100644 tests/rustdoc/cross-crate-info/cargo-transitive-no-index/auxiliary/t.rs
 create mode 100644 tests/rustdoc/cross-crate-info/cargo-transitive-no-index/s.rs
 create mode 100644 tests/rustdoc/cross-crate-info/cargo-transitive/auxiliary/q.rs
 create mode 100644 tests/rustdoc/cross-crate-info/cargo-transitive/auxiliary/t.rs
 create mode 100644 tests/rustdoc/cross-crate-info/cargo-transitive/s.rs
 create mode 100644 tests/rustdoc/cross-crate-info/cargo-two-no-index/auxiliary/f.rs
 create mode 100644 tests/rustdoc/cross-crate-info/cargo-two-no-index/e.rs
 create mode 100644 tests/rustdoc/cross-crate-info/cargo-two/auxiliary/f.rs
 create mode 100644 tests/rustdoc/cross-crate-info/cargo-two/e.rs
 create mode 100644 tests/rustdoc/cross-crate-info/index-on-last/auxiliary/f.rs
 create mode 100644 tests/rustdoc/cross-crate-info/index-on-last/e.rs
 create mode 100644 tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/q.rs
 create mode 100644 tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/r.rs
 create mode 100644 tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/s.rs
 create mode 100644 tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/t.rs
 create mode 100644 tests/rustdoc/cross-crate-info/kitchen-sink/i.rs
 create mode 100644 tests/rustdoc/cross-crate-info/single-crate-baseline/q.rs
 create mode 100644 tests/rustdoc/cross-crate-info/single-crate-no-index/q.rs
 create mode 100644 tests/rustdoc/cross-crate-info/transitive/auxiliary/q.rs
 create mode 100644 tests/rustdoc/cross-crate-info/transitive/auxiliary/t.rs
 create mode 100644 tests/rustdoc/cross-crate-info/transitive/s.rs
 create mode 100644 tests/rustdoc/cross-crate-info/two/auxiliary/f.rs
 create mode 100644 tests/rustdoc/cross-crate-info/two/e.rs
 create mode 100644 tests/rustdoc/cross-crate-info/working-dir-examples/q.rs
 create mode 100644 tests/rustdoc/cross-crate-info/write-docs-somewhere-else/auxiliary/f.rs
 create mode 100644 tests/rustdoc/cross-crate-info/write-docs-somewhere-else/e.rs

diff --git a/src/tools/compiletest/src/command-list.rs b/src/tools/compiletest/src/command-list.rs
index c356f4266f016..305bf9c228c43 100644
--- a/src/tools/compiletest/src/command-list.rs
+++ b/src/tools/compiletest/src/command-list.rs
@@ -9,6 +9,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
     "aux-codegen-backend",
     "aux-crate",
     "build-aux-docs",
+    "unique-doc-out-dir",
     "build-fail",
     "build-pass",
     "check-fail",
@@ -18,6 +19,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
     "check-test-line-numbers-match",
     "compare-output-lines-by-subset",
     "compile-flags",
+    "doc-flags",
     "dont-check-compiler-stderr",
     "dont-check-compiler-stdout",
     "dont-check-failure-status",
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs
index 0208ed34ac182..3a08a8e38950c 100644
--- a/src/tools/compiletest/src/header.rs
+++ b/src/tools/compiletest/src/header.rs
@@ -95,6 +95,8 @@ pub struct TestProps {
     pub compile_flags: Vec<String>,
     // Extra flags to pass when the compiled code is run (such as --bench)
     pub run_flags: Vec<String>,
+    /// Extra flags to pass to rustdoc but not the compiler.
+    pub doc_flags: Vec<String>,
     // If present, the name of a file that this test should match when
     // pretty-printed
     pub pp_exact: Option<PathBuf>,
@@ -122,6 +124,9 @@ pub struct TestProps {
     pub unset_exec_env: Vec<String>,
     // Build documentation for all specified aux-builds as well
     pub build_aux_docs: bool,
+    /// Build the documentation for each crate in a unique output directory.
+    /// Uses <root output directory>/docs/<test name>/doc
+    pub unique_doc_out_dir: bool,
     // Flag to force a crate to be built with the host architecture
     pub force_host: bool,
     // Check stdout for error-pattern output as well as stderr
@@ -220,8 +225,10 @@ mod directives {
     pub const REGEX_ERROR_PATTERN: &'static str = "regex-error-pattern";
     pub const COMPILE_FLAGS: &'static str = "compile-flags";
     pub const RUN_FLAGS: &'static str = "run-flags";
+    pub const DOC_FLAGS: &'static str = "doc-flags";
     pub const SHOULD_ICE: &'static str = "should-ice";
     pub const BUILD_AUX_DOCS: &'static str = "build-aux-docs";
+    pub const UNIQUE_DOC_OUT_DIR: &'static str = "unique-doc-out-dir";
     pub const FORCE_HOST: &'static str = "force-host";
     pub const CHECK_STDOUT: &'static str = "check-stdout";
     pub const CHECK_RUN_RESULTS: &'static str = "check-run-results";
@@ -267,6 +274,7 @@ impl TestProps {
             regex_error_patterns: vec![],
             compile_flags: vec![],
             run_flags: vec![],
+            doc_flags: vec![],
             pp_exact: None,
             aux_builds: vec![],
             aux_bins: vec![],
@@ -281,6 +289,7 @@ impl TestProps {
             exec_env: vec![],
             unset_exec_env: vec![],
             build_aux_docs: false,
+            unique_doc_out_dir: false,
             force_host: false,
             check_stdout: false,
             check_run_results: false,
@@ -377,6 +386,8 @@ impl TestProps {
                         |r| r,
                     );
 
+                    config.push_name_value_directive(ln, DOC_FLAGS, &mut self.doc_flags, |r| r);
+
                     fn split_flags(flags: &str) -> Vec<String> {
                         // Individual flags can be single-quoted to preserve spaces; see
                         // <https://github.com/rust-lang/rust/pull/115948/commits/957c5db6>.
@@ -414,6 +425,8 @@ impl TestProps {
 
                     config.set_name_directive(ln, SHOULD_ICE, &mut self.should_ice);
                     config.set_name_directive(ln, BUILD_AUX_DOCS, &mut self.build_aux_docs);
+                    config.set_name_directive(ln, UNIQUE_DOC_OUT_DIR, &mut self.unique_doc_out_dir);
+
                     config.set_name_directive(ln, FORCE_HOST, &mut self.force_host);
                     config.set_name_directive(ln, CHECK_STDOUT, &mut self.check_stdout);
                     config.set_name_directive(ln, CHECK_RUN_RESULTS, &mut self.check_run_results);
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index f6e8fdd624434..2d298dfbc06f7 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -1,5 +1,17 @@
 // ignore-tidy-filelength
 
+use crate::compute_diff::{write_diff, write_filtered_diff};
+use crate::errors::{self, Error, ErrorKind};
+use crate::header::TestProps;
+use crate::json;
+use crate::read2::{read2_abbreviated, Truncated};
+use crate::util::{add_dylib_path, copy_dir_all, dylib_env_var, logv, static_regex, PathBufExt};
+use crate::ColorConfig;
+use colored::Colorize;
+use miropt_test_tools::{files_for_miropt_test, MiroptTest, MiroptTestFile};
+use regex::{Captures, Regex};
+use rustfix::{apply_suggestions, get_suggestions_from_json, Filter};
+use std::borrow::Cow;
 use std::collections::{HashMap, HashSet};
 use std::ffi::{OsStr, OsString};
 use std::fs::{self, create_dir_all, File, OpenOptions};
@@ -723,7 +735,7 @@ impl<'test> TestCx<'test> {
         self.maybe_add_external_args(&mut rustc, &self.config.target_rustcflags);
         rustc.args(&self.props.compile_flags);
 
-        self.compose_and_run_compiler(rustc, Some(src))
+        self.compose_and_run_compiler(rustc, Some(src), self.testpaths)
     }
 
     fn run_debuginfo_test(&self) {
@@ -1579,13 +1591,15 @@ impl<'test> TestCx<'test> {
             passes,
         );
 
-        self.compose_and_run_compiler(rustc, None)
+        self.compose_and_run_compiler(rustc, None, self.testpaths)
     }
 
-    fn document(&self, out_dir: &Path) -> ProcRes {
+    /// `root_out_dir` and `root_testpaths` refer to the parameters of the actual test being run.
+    /// Auxiliaries, no matter how deep, have the same root_out_dir and root_testpaths.
+    fn document(&self, root_out_dir: &Path, root_testpaths: &TestPaths) -> ProcRes {
         if self.props.build_aux_docs {
             for rel_ab in &self.props.aux_builds {
-                let aux_testpaths = self.compute_aux_test_paths(&self.testpaths, rel_ab);
+                let aux_testpaths = self.compute_aux_test_paths(root_testpaths, rel_ab);
                 let aux_props =
                     self.props.from_aux_file(&aux_testpaths.file, self.revision, self.config);
                 let aux_cx = TestCx {
@@ -1596,7 +1610,7 @@ impl<'test> TestCx<'test> {
                 };
                 // Create the directory for the stdout/stderr files.
                 create_dir_all(aux_cx.output_base_dir()).unwrap();
-                let auxres = aux_cx.document(out_dir);
+                let auxres = aux_cx.document(&root_out_dir, root_testpaths);
                 if !auxres.status.success() {
                     return auxres;
                 }
@@ -1606,21 +1620,47 @@ impl<'test> TestCx<'test> {
         let aux_dir = self.aux_output_dir_name();
 
         let rustdoc_path = self.config.rustdoc_path.as_ref().expect("--rustdoc-path not passed");
-        let mut rustdoc = Command::new(rustdoc_path);
 
+        // actual --out-dir given to the auxiliary or test, as opposed to the root out dir for the entire
+        // test
+        let out_dir: Cow<'_, Path> = if self.props.unique_doc_out_dir {
+            let file_name = self
+                .testpaths
+                .file
+                .file_name()
+                .expect("file name should not be empty")
+                .to_str()
+                .expect("file name utf8")
+                .trim_end_matches(".rs");
+            let out_dir = PathBuf::from_iter([
+                root_out_dir,
+                Path::new("docs"),
+                Path::new(file_name),
+                Path::new("doc"),
+            ]);
+            create_dir_all(&out_dir).unwrap();
+            Cow::Owned(out_dir)
+        } else {
+            Cow::Borrowed(root_out_dir)
+        };
+
+        let mut rustdoc = Command::new(rustdoc_path);
+        let current_dir = output_base_dir(self.config, root_testpaths, self.safe_revision());
+        rustdoc.current_dir(current_dir);
         rustdoc
             .arg("-L")
             .arg(self.config.run_lib_path.to_str().unwrap())
             .arg("-L")
             .arg(aux_dir)
             .arg("-o")
-            .arg(out_dir)
+            .arg(out_dir.as_ref())
             .arg("--deny")
             .arg("warnings")
             .arg(&self.testpaths.file)
             .arg("-A")
             .arg("internal_features")
-            .args(&self.props.compile_flags);
+            .args(&self.props.compile_flags)
+            .args(&self.props.doc_flags);
 
         if self.config.mode == RustdocJson {
             rustdoc.arg("--output-format").arg("json").arg("-Zunstable-options");
@@ -1630,7 +1670,7 @@ impl<'test> TestCx<'test> {
             rustdoc.arg(format!("-Clinker={}", linker));
         }
 
-        self.compose_and_run_compiler(rustdoc, None)
+        self.compose_and_run_compiler(rustdoc, None, root_testpaths)
     }
 
     fn exec_compiled_test(&self) -> ProcRes {
@@ -1828,9 +1868,16 @@ impl<'test> TestCx<'test> {
         }
     }
 
-    fn compose_and_run_compiler(&self, mut rustc: Command, input: Option<String>) -> ProcRes {
+    /// `root_testpaths` refers to the path of the original test.
+    /// the auxiliary and the test with an aux-build have the same `root_testpaths`.
+    fn compose_and_run_compiler(
+        &self,
+        mut rustc: Command,
+        input: Option<String>,
+        root_testpaths: &TestPaths,
+    ) -> ProcRes {
         let aux_dir = self.aux_output_dir();
-        self.build_all_auxiliary(&self.testpaths, &aux_dir, &mut rustc);
+        self.build_all_auxiliary(root_testpaths, &aux_dir, &mut rustc);
 
         rustc.envs(self.props.rustc_env.clone());
         self.props.unset_rustc_env.iter().fold(&mut rustc, Command::env_remove);
@@ -2545,7 +2592,7 @@ impl<'test> TestCx<'test> {
             Vec::new(),
         );
 
-        let proc_res = self.compose_and_run_compiler(rustc, None);
+        let proc_res = self.compose_and_run_compiler(rustc, None, self.testpaths);
         let output_path = self.get_filecheck_file("ll");
         (proc_res, output_path)
     }
@@ -2581,7 +2628,7 @@ impl<'test> TestCx<'test> {
             Vec::new(),
         );
 
-        let proc_res = self.compose_and_run_compiler(rustc, None);
+        let proc_res = self.compose_and_run_compiler(rustc, None, self.testpaths);
         let output_path = self.get_filecheck_file("s");
         (proc_res, output_path)
     }
@@ -2664,7 +2711,7 @@ impl<'test> TestCx<'test> {
         let out_dir = self.output_base_dir();
         remove_and_create_dir_all(&out_dir);
 
-        let proc_res = self.document(&out_dir);
+        let proc_res = self.document(&out_dir, &self.testpaths);
         if !proc_res.status.success() {
             self.fatal_proc_rec("rustdoc failed!", &proc_res);
         }
@@ -2723,7 +2770,7 @@ impl<'test> TestCx<'test> {
         let aux_dir = new_rustdoc.aux_output_dir();
         new_rustdoc.build_all_auxiliary(&new_rustdoc.testpaths, &aux_dir, &mut rustc);
 
-        let proc_res = new_rustdoc.document(&compare_dir);
+        let proc_res = new_rustdoc.document(&compare_dir, &new_rustdoc.testpaths);
         if !proc_res.status.success() {
             eprintln!("failed to run nightly rustdoc");
             return;
@@ -2846,7 +2893,7 @@ impl<'test> TestCx<'test> {
         let out_dir = self.output_base_dir();
         remove_and_create_dir_all(&out_dir);
 
-        let proc_res = self.document(&out_dir);
+        let proc_res = self.document(&out_dir, &self.testpaths);
         if !proc_res.status.success() {
             self.fatal_proc_rec("rustdoc failed!", &proc_res);
         }
@@ -2922,24 +2969,15 @@ impl<'test> TestCx<'test> {
     fn check_rustdoc_test_option(&self, res: ProcRes) {
         let mut other_files = Vec::new();
         let mut files: HashMap<String, Vec<usize>> = HashMap::new();
-        let cwd = env::current_dir().unwrap();
-        files.insert(
-            self.testpaths
-                .file
-                .strip_prefix(&cwd)
-                .unwrap_or(&self.testpaths.file)
-                .to_str()
-                .unwrap()
-                .replace('\\', "/"),
-            self.get_lines(&self.testpaths.file, Some(&mut other_files)),
-        );
+        let normalized = fs::canonicalize(&self.testpaths.file).expect("failed to canonicalize");
+        let normalized = normalized.to_str().unwrap().replace('\\', "/");
+        files.insert(normalized, self.get_lines(&self.testpaths.file, Some(&mut other_files)));
         for other_file in other_files {
             let mut path = self.testpaths.file.clone();
             path.set_file_name(&format!("{}.rs", other_file));
-            files.insert(
-                path.strip_prefix(&cwd).unwrap_or(&path).to_str().unwrap().replace('\\', "/"),
-                self.get_lines(&path, None),
-            );
+            let path = fs::canonicalize(path).expect("failed to canonicalize");
+            let normalized = path.to_str().unwrap().replace('\\', "/");
+            files.insert(normalized, self.get_lines(&path, None));
         }
 
         let mut tested = 0;
@@ -3778,7 +3816,7 @@ impl<'test> TestCx<'test> {
         if let Some(nodejs) = &self.config.nodejs {
             let out_dir = self.output_base_dir();
 
-            self.document(&out_dir);
+            self.document(&out_dir, &self.testpaths);
 
             let root = self.config.find_rust_src_root().unwrap();
             let file_stem =
@@ -4094,7 +4132,7 @@ impl<'test> TestCx<'test> {
                 rustc.arg(crate_name);
             }
 
-            let res = self.compose_and_run_compiler(rustc, None);
+            let res = self.compose_and_run_compiler(rustc, None, self.testpaths);
             if !res.status.success() {
                 self.fatal_proc_rec("failed to compile fixed code", &res);
             }
diff --git a/src/tools/compiletest/src/runtest/coverage.rs b/src/tools/compiletest/src/runtest/coverage.rs
index 6ee147da5a965..05191a159801c 100644
--- a/src/tools/compiletest/src/runtest/coverage.rs
+++ b/src/tools/compiletest/src/runtest/coverage.rs
@@ -191,7 +191,7 @@ impl<'test> TestCx<'test> {
 
         rustdoc_cmd.arg(&self.testpaths.file);
 
-        let proc_res = self.compose_and_run_compiler(rustdoc_cmd, None);
+        let proc_res = self.compose_and_run_compiler(rustdoc_cmd, None, self.testpaths);
         if !proc_res.status.success() {
             self.fatal_proc_rec("rustdoc --test failed!", &proc_res)
         }
diff --git a/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/auxiliary/q.rs b/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/auxiliary/q.rs
new file mode 100644
index 0000000000000..32ad96d3e8e36
--- /dev/null
+++ b/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/auxiliary/q.rs
@@ -0,0 +1,4 @@
+//@ build-aux-docs
+
+
+pub struct Quebec;
diff --git a/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/auxiliary/t.rs b/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/auxiliary/t.rs
new file mode 100644
index 0000000000000..e03c9a1c68c3b
--- /dev/null
+++ b/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/auxiliary/t.rs
@@ -0,0 +1,6 @@
+//@ aux-build:q.rs
+//@ build-aux-docs
+
+
+extern crate q;
+pub trait Tango {}
diff --git a/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/s.rs b/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/s.rs
new file mode 100644
index 0000000000000..af0d31c733ee1
--- /dev/null
+++ b/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/s.rs
@@ -0,0 +1,17 @@
+//@ aux-build:t.rs
+//@ build-aux-docs
+
+//@ has t/trait.Tango.html
+//@ hasraw search-index.js 'Quebec'
+//@ hasraw trait.impl/t/trait.Tango.js 'struct.Sierra.html'
+//@ hasraw s/struct.Sierra.html 'Tango'
+//@ hasraw search-index.js 'Sierra'
+//@ hasraw search-index.js 'Tango'
+//@ has q/struct.Quebec.html
+//@ has s/struct.Sierra.html
+
+// We document multiple crates into the same output directory, which merges the cross-crate information. Everything is available.
+
+extern crate t;
+pub struct Sierra;
+impl t::Tango for Sierra {}
diff --git a/tests/rustdoc/cross-crate-info/cargo-transitive/auxiliary/q.rs b/tests/rustdoc/cross-crate-info/cargo-transitive/auxiliary/q.rs
new file mode 100644
index 0000000000000..e32fdbaabfe21
--- /dev/null
+++ b/tests/rustdoc/cross-crate-info/cargo-transitive/auxiliary/q.rs
@@ -0,0 +1,6 @@
+//@ build-aux-docs
+//@ doc-flags:--enable-index-page
+//@ doc-flags:-Zunstable-options
+
+
+pub struct Quebec;
diff --git a/tests/rustdoc/cross-crate-info/cargo-transitive/auxiliary/t.rs b/tests/rustdoc/cross-crate-info/cargo-transitive/auxiliary/t.rs
new file mode 100644
index 0000000000000..0a49072b68a67
--- /dev/null
+++ b/tests/rustdoc/cross-crate-info/cargo-transitive/auxiliary/t.rs
@@ -0,0 +1,8 @@
+//@ aux-build:q.rs
+//@ build-aux-docs
+//@ doc-flags:--enable-index-page
+//@ doc-flags:-Zunstable-options
+
+
+extern crate q;
+pub trait Tango {}
diff --git a/tests/rustdoc/cross-crate-info/cargo-transitive/s.rs b/tests/rustdoc/cross-crate-info/cargo-transitive/s.rs
new file mode 100644
index 0000000000000..b050fbdf67d99
--- /dev/null
+++ b/tests/rustdoc/cross-crate-info/cargo-transitive/s.rs
@@ -0,0 +1,24 @@
+//@ aux-build:t.rs
+//@ build-aux-docs
+//@ doc-flags:--enable-index-page
+//@ doc-flags:-Zunstable-options
+
+//@ has t/trait.Tango.html
+//@ hasraw search-index.js 'Quebec'
+//@ has index.html '//ul[@class="all-items"]//a[@href="q/index.html"]' 'q'
+//@ hasraw s/struct.Sierra.html 'Tango'
+//@ hasraw trait.impl/t/trait.Tango.js 'struct.Sierra.html'
+//@ has index.html '//ul[@class="all-items"]//a[@href="t/index.html"]' 't'
+//@ has index.html '//h1' 'List of all crates'
+//@ has index.html '//ul[@class="all-items"]//a[@href="s/index.html"]' 's'
+//@ hasraw search-index.js 'Sierra'
+//@ hasraw search-index.js 'Tango'
+//@ has index.html
+//@ has q/struct.Quebec.html
+//@ has s/struct.Sierra.html
+
+// We document multiple crates into the same output directory, which merges the cross-crate information. Everything is available.
+
+extern crate t;
+pub struct Sierra;
+impl t::Tango for Sierra {}
diff --git a/tests/rustdoc/cross-crate-info/cargo-two-no-index/auxiliary/f.rs b/tests/rustdoc/cross-crate-info/cargo-two-no-index/auxiliary/f.rs
new file mode 100644
index 0000000000000..1bfc785535b53
--- /dev/null
+++ b/tests/rustdoc/cross-crate-info/cargo-two-no-index/auxiliary/f.rs
@@ -0,0 +1,4 @@
+//@ build-aux-docs
+
+
+pub trait Foxtrot {}
diff --git a/tests/rustdoc/cross-crate-info/cargo-two-no-index/e.rs b/tests/rustdoc/cross-crate-info/cargo-two-no-index/e.rs
new file mode 100644
index 0000000000000..d3e42989b7770
--- /dev/null
+++ b/tests/rustdoc/cross-crate-info/cargo-two-no-index/e.rs
@@ -0,0 +1,15 @@
+//@ aux-build:f.rs
+//@ build-aux-docs
+
+//@ hasraw search-index.js 'Echo'
+//@ hasraw search-index.js 'Foxtrot'
+//@ hasraw trait.impl/f/trait.Foxtrot.js 'enum.Echo.html'
+//@ has f/trait.Foxtrot.html
+//@ has e/enum.Echo.html
+//@ hasraw e/enum.Echo.html 'Foxtrot'
+
+// document two crates in the same way that cargo does. do not provide --enable-index-page
+
+extern crate f;
+pub enum Echo {}
+impl f::Foxtrot for Echo {}
diff --git a/tests/rustdoc/cross-crate-info/cargo-two/auxiliary/f.rs b/tests/rustdoc/cross-crate-info/cargo-two/auxiliary/f.rs
new file mode 100644
index 0000000000000..e84835b3e3102
--- /dev/null
+++ b/tests/rustdoc/cross-crate-info/cargo-two/auxiliary/f.rs
@@ -0,0 +1,6 @@
+//@ build-aux-docs
+//@ doc-flags:--enable-index-page
+//@ doc-flags:-Zunstable-options
+
+
+pub trait Foxtrot {}
diff --git a/tests/rustdoc/cross-crate-info/cargo-two/e.rs b/tests/rustdoc/cross-crate-info/cargo-two/e.rs
new file mode 100644
index 0000000000000..bb845877b52f0
--- /dev/null
+++ b/tests/rustdoc/cross-crate-info/cargo-two/e.rs
@@ -0,0 +1,21 @@
+//@ aux-build:f.rs
+//@ build-aux-docs
+//@ doc-flags:--enable-index-page
+//@ doc-flags:-Zunstable-options
+
+//@ hasraw search-index.js 'Echo'
+//@ hasraw search-index.js 'Foxtrot'
+//@ has index.html '//ul[@class="all-items"]//a[@href="e/index.html"]' 'e'
+//@ has index.html '//ul[@class="all-items"]//a[@href="f/index.html"]' 'f'
+//@ hasraw trait.impl/f/trait.Foxtrot.js 'enum.Echo.html'
+//@ has f/trait.Foxtrot.html
+//@ has index.html '//h1' 'List of all crates'
+//@ has e/enum.Echo.html
+//@ has index.html
+//@ hasraw e/enum.Echo.html 'Foxtrot'
+
+// document two crates in the same way that cargo does, writing them both into the same output directory
+
+extern crate f;
+pub enum Echo {}
+impl f::Foxtrot for Echo {}
diff --git a/tests/rustdoc/cross-crate-info/index-on-last/auxiliary/f.rs b/tests/rustdoc/cross-crate-info/index-on-last/auxiliary/f.rs
new file mode 100644
index 0000000000000..1bfc785535b53
--- /dev/null
+++ b/tests/rustdoc/cross-crate-info/index-on-last/auxiliary/f.rs
@@ -0,0 +1,4 @@
+//@ build-aux-docs
+
+
+pub trait Foxtrot {}
diff --git a/tests/rustdoc/cross-crate-info/index-on-last/e.rs b/tests/rustdoc/cross-crate-info/index-on-last/e.rs
new file mode 100644
index 0000000000000..876b94464c372
--- /dev/null
+++ b/tests/rustdoc/cross-crate-info/index-on-last/e.rs
@@ -0,0 +1,21 @@
+//@ aux-build:f.rs
+//@ build-aux-docs
+//@ doc-flags:--enable-index-page
+//@ doc-flags:-Zunstable-options
+
+//@ hasraw search-index.js 'Echo'
+//@ hasraw search-index.js 'Foxtrot'
+//@ has index.html '//ul[@class="all-items"]//a[@href="e/index.html"]' 'e'
+//@ has index.html '//ul[@class="all-items"]//a[@href="f/index.html"]' 'f'
+//@ hasraw trait.impl/f/trait.Foxtrot.js 'enum.Echo.html'
+//@ has f/trait.Foxtrot.html
+//@ has index.html '//h1' 'List of all crates'
+//@ has e/enum.Echo.html
+//@ has index.html
+//@ hasraw e/enum.Echo.html 'Foxtrot'
+
+// only declare --enable-index-page to the last rustdoc invocation
+
+extern crate f;
+pub enum Echo {}
+impl f::Foxtrot for Echo {}
diff --git a/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/q.rs b/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/q.rs
new file mode 100644
index 0000000000000..e32fdbaabfe21
--- /dev/null
+++ b/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/q.rs
@@ -0,0 +1,6 @@
+//@ build-aux-docs
+//@ doc-flags:--enable-index-page
+//@ doc-flags:-Zunstable-options
+
+
+pub struct Quebec;
diff --git a/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/r.rs b/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/r.rs
new file mode 100644
index 0000000000000..c0ada1aea1a85
--- /dev/null
+++ b/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/r.rs
@@ -0,0 +1,8 @@
+//@ aux-build:s.rs
+//@ build-aux-docs
+//@ doc-flags:--enable-index-page
+//@ doc-flags:-Zunstable-options
+
+
+extern crate s;
+pub type Romeo = s::Sierra;
diff --git a/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/s.rs b/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/s.rs
new file mode 100644
index 0000000000000..6b414a289f5a8
--- /dev/null
+++ b/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/s.rs
@@ -0,0 +1,9 @@
+//@ aux-build:t.rs
+//@ build-aux-docs
+//@ doc-flags:--enable-index-page
+//@ doc-flags:-Zunstable-options
+
+
+extern crate t;
+pub struct Sierra;
+impl t::Tango for Sierra {}
diff --git a/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/t.rs b/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/t.rs
new file mode 100644
index 0000000000000..0a49072b68a67
--- /dev/null
+++ b/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/t.rs
@@ -0,0 +1,8 @@
+//@ aux-build:q.rs
+//@ build-aux-docs
+//@ doc-flags:--enable-index-page
+//@ doc-flags:-Zunstable-options
+
+
+extern crate q;
+pub trait Tango {}
diff --git a/tests/rustdoc/cross-crate-info/kitchen-sink/i.rs b/tests/rustdoc/cross-crate-info/kitchen-sink/i.rs
new file mode 100644
index 0000000000000..9df0e9779ffa7
--- /dev/null
+++ b/tests/rustdoc/cross-crate-info/kitchen-sink/i.rs
@@ -0,0 +1,32 @@
+//@ aux-build:q.rs
+//@ aux-build:r.rs
+//@ aux-build:t.rs
+//@ aux-build:s.rs
+//@ build-aux-docs
+//@ doc-flags:--enable-index-page
+//@ doc-flags:-Zunstable-options
+
+//@ hasraw search-index.js 'Quebec'
+//@ hasraw search-index.js 'Sierra'
+//@ has index.html
+//@ has s/struct.Sierra.html
+//@ hasraw s/struct.Sierra.html 'Tango'
+//@ has index.html '//ul[@class="all-items"]//a[@href="i/index.html"]' 'i'
+//@ has q/struct.Quebec.html
+//@ has type.impl/s/struct.Sierra.js
+//@ hasraw type.impl/s/struct.Sierra.js 'Romeo'
+//@ hasraw type.impl/s/struct.Sierra.js 'Tango'
+//@ has index.html '//ul[@class="all-items"]//a[@href="q/index.html"]' 'q'
+//@ has index.html '//ul[@class="all-items"]//a[@href="t/index.html"]' 't'
+//@ has index.html '//ul[@class="all-items"]//a[@href="s/index.html"]' 's'
+//@ has r/type.Romeo.html
+//@ has t/trait.Tango.html
+//@ hasraw search-index.js 'Romeo'
+//@ hasraw trait.impl/t/trait.Tango.js 'struct.Sierra.html'
+//@ has index.html '//h1' 'List of all crates'
+//@ hasraw search-index.js 'Tango'
+//@ has index.html '//ul[@class="all-items"]//a[@href="r/index.html"]' 'r'
+
+// document everything in the default mode
+
+
diff --git a/tests/rustdoc/cross-crate-info/single-crate-baseline/q.rs b/tests/rustdoc/cross-crate-info/single-crate-baseline/q.rs
new file mode 100644
index 0000000000000..a9e03852f2297
--- /dev/null
+++ b/tests/rustdoc/cross-crate-info/single-crate-baseline/q.rs
@@ -0,0 +1,13 @@
+//@ build-aux-docs
+//@ doc-flags:--enable-index-page
+//@ doc-flags:-Zunstable-options
+
+//@ hasraw search-index.js 'Quebec'
+//@ has index.html '//ul[@class="all-items"]//a[@href="q/index.html"]' 'q'
+//@ has index.html '//h1' 'List of all crates'
+//@ has index.html
+//@ has q/struct.Quebec.html
+
+// there's nothing cross-crate going on here
+
+pub struct Quebec;
diff --git a/tests/rustdoc/cross-crate-info/single-crate-no-index/q.rs b/tests/rustdoc/cross-crate-info/single-crate-no-index/q.rs
new file mode 100644
index 0000000000000..38471e02a2820
--- /dev/null
+++ b/tests/rustdoc/cross-crate-info/single-crate-no-index/q.rs
@@ -0,0 +1,8 @@
+//@ build-aux-docs
+
+//@ hasraw search-index.js 'Quebec'
+//@ has q/struct.Quebec.html
+
+// there's nothing cross-crate going on here
+
+pub struct Quebec;
diff --git a/tests/rustdoc/cross-crate-info/transitive/auxiliary/q.rs b/tests/rustdoc/cross-crate-info/transitive/auxiliary/q.rs
new file mode 100644
index 0000000000000..32ad96d3e8e36
--- /dev/null
+++ b/tests/rustdoc/cross-crate-info/transitive/auxiliary/q.rs
@@ -0,0 +1,4 @@
+//@ build-aux-docs
+
+
+pub struct Quebec;
diff --git a/tests/rustdoc/cross-crate-info/transitive/auxiliary/t.rs b/tests/rustdoc/cross-crate-info/transitive/auxiliary/t.rs
new file mode 100644
index 0000000000000..e03c9a1c68c3b
--- /dev/null
+++ b/tests/rustdoc/cross-crate-info/transitive/auxiliary/t.rs
@@ -0,0 +1,6 @@
+//@ aux-build:q.rs
+//@ build-aux-docs
+
+
+extern crate q;
+pub trait Tango {}
diff --git a/tests/rustdoc/cross-crate-info/transitive/s.rs b/tests/rustdoc/cross-crate-info/transitive/s.rs
new file mode 100644
index 0000000000000..a758bd68be22f
--- /dev/null
+++ b/tests/rustdoc/cross-crate-info/transitive/s.rs
@@ -0,0 +1,9 @@
+//@ aux-build:t.rs
+//@ build-aux-docs
+
+
+// simple test to see if we support building transitive crates
+
+extern crate t;
+pub struct Sierra;
+impl t::Tango for Sierra {}
diff --git a/tests/rustdoc/cross-crate-info/two/auxiliary/f.rs b/tests/rustdoc/cross-crate-info/two/auxiliary/f.rs
new file mode 100644
index 0000000000000..1bfc785535b53
--- /dev/null
+++ b/tests/rustdoc/cross-crate-info/two/auxiliary/f.rs
@@ -0,0 +1,4 @@
+//@ build-aux-docs
+
+
+pub trait Foxtrot {}
diff --git a/tests/rustdoc/cross-crate-info/two/e.rs b/tests/rustdoc/cross-crate-info/two/e.rs
new file mode 100644
index 0000000000000..431e73c390d4a
--- /dev/null
+++ b/tests/rustdoc/cross-crate-info/two/e.rs
@@ -0,0 +1,9 @@
+//@ aux-build:f.rs
+//@ build-aux-docs
+
+
+// simple test to assert that we can do a two-level aux-build
+
+extern crate f;
+pub enum Echo {}
+impl f::Foxtrot for Echo {}
diff --git a/tests/rustdoc/cross-crate-info/working-dir-examples/q.rs b/tests/rustdoc/cross-crate-info/working-dir-examples/q.rs
new file mode 100644
index 0000000000000..89d1349e520fa
--- /dev/null
+++ b/tests/rustdoc/cross-crate-info/working-dir-examples/q.rs
@@ -0,0 +1,10 @@
+//@ build-aux-docs
+//@ doc-flags:--scrape-examples-output-path=examples
+//@ doc-flags:--scrape-examples-target-crate=q
+//@ doc-flags:-Zunstable-options
+
+//@ has examples
+
+// where will --scrape-examples-output-path resolve the path to be? should be the root output directory
+
+pub struct Quebec;
diff --git a/tests/rustdoc/cross-crate-info/write-docs-somewhere-else/auxiliary/f.rs b/tests/rustdoc/cross-crate-info/write-docs-somewhere-else/auxiliary/f.rs
new file mode 100644
index 0000000000000..52e02e8b89715
--- /dev/null
+++ b/tests/rustdoc/cross-crate-info/write-docs-somewhere-else/auxiliary/f.rs
@@ -0,0 +1,5 @@
+//@ build-aux-docs
+//@ unique-doc-out-dir
+
+
+pub trait Foxtrot {}
diff --git a/tests/rustdoc/cross-crate-info/write-docs-somewhere-else/e.rs b/tests/rustdoc/cross-crate-info/write-docs-somewhere-else/e.rs
new file mode 100644
index 0000000000000..0480a02bf22f7
--- /dev/null
+++ b/tests/rustdoc/cross-crate-info/write-docs-somewhere-else/e.rs
@@ -0,0 +1,15 @@
+//@ aux-build:f.rs
+//@ build-aux-docs
+
+//@ hasraw search-index.js 'Echo'
+//@ !hasraw search-index.js 'Foxtrot'
+//@ hasraw trait.impl/f/trait.Foxtrot.js 'enum.Echo.html'
+//@ !has f/trait.Foxtrot.html
+//@ has e/enum.Echo.html
+//@ hasraw e/enum.Echo.html 'Foxtrot'
+
+// test the fact that our test runner will document this crate somewhere else
+
+extern crate f;
+pub enum Echo {}
+impl f::Foxtrot for Echo {}

From d8211def61d2b436d2a8335d745105e2de3ac172 Mon Sep 17 00:00:00 2001
From: EtomicBomb <ethan@ethan.ws>
Date: Wed, 24 Jul 2024 22:16:01 +0000
Subject: [PATCH 2/6] ordering and wrapping cross-crate-info tests

---
 src/tools/compiletest/src/command-list.rs     |  2 +-
 .../cargo-transitive-no-index/s.rs            | 13 +++++-----
 .../cross-crate-info/cargo-transitive/s.rs    | 21 ++++++++-------
 .../cross-crate-info/cargo-two-no-index/e.rs  | 11 ++++----
 tests/rustdoc/cross-crate-info/cargo-two/e.rs | 17 ++++++------
 .../cross-crate-info/index-on-last/e.rs       | 14 +++++-----
 .../cross-crate-info/kitchen-sink/i.rs        | 26 +++++++++----------
 .../single-crate-baseline/q.rs                |  6 ++---
 .../single-crate-no-index/q.rs                |  2 +-
 .../working-dir-examples/q.rs                 |  3 ++-
 .../write-docs-somewhere-else/e.rs            | 11 ++++----
 11 files changed, 66 insertions(+), 60 deletions(-)

diff --git a/src/tools/compiletest/src/command-list.rs b/src/tools/compiletest/src/command-list.rs
index 305bf9c228c43..68443c300fc5c 100644
--- a/src/tools/compiletest/src/command-list.rs
+++ b/src/tools/compiletest/src/command-list.rs
@@ -9,7 +9,6 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
     "aux-codegen-backend",
     "aux-crate",
     "build-aux-docs",
-    "unique-doc-out-dir",
     "build-fail",
     "build-pass",
     "check-fail",
@@ -227,6 +226,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
     "should-ice",
     "stderr-per-bitwidth",
     "test-mir-pass",
+    "unique-doc-out-dir",
     "unset-exec-env",
     "unset-rustc-env",
     // Used by the tidy check `unknown_revision`.
diff --git a/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/s.rs b/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/s.rs
index af0d31c733ee1..639b772374fc8 100644
--- a/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/s.rs
+++ b/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/s.rs
@@ -1,16 +1,17 @@
 //@ aux-build:t.rs
 //@ build-aux-docs
 
+//@ has q/struct.Quebec.html
+//@ has s/struct.Sierra.html
 //@ has t/trait.Tango.html
-//@ hasraw search-index.js 'Quebec'
-//@ hasraw trait.impl/t/trait.Tango.js 'struct.Sierra.html'
 //@ hasraw s/struct.Sierra.html 'Tango'
-//@ hasraw search-index.js 'Sierra'
+//@ hasraw trait.impl/t/trait.Tango.js 'struct.Sierra.html'
 //@ hasraw search-index.js 'Tango'
-//@ has q/struct.Quebec.html
-//@ has s/struct.Sierra.html
+//@ hasraw search-index.js 'Sierra'
+//@ hasraw search-index.js 'Quebec'
 
-// We document multiple crates into the same output directory, which merges the cross-crate information. Everything is available.
+// We document multiple crates into the same output directory, which
+// merges the cross-crate information. Everything is available.
 
 extern crate t;
 pub struct Sierra;
diff --git a/tests/rustdoc/cross-crate-info/cargo-transitive/s.rs b/tests/rustdoc/cross-crate-info/cargo-transitive/s.rs
index b050fbdf67d99..4383d089c4c73 100644
--- a/tests/rustdoc/cross-crate-info/cargo-transitive/s.rs
+++ b/tests/rustdoc/cross-crate-info/cargo-transitive/s.rs
@@ -3,21 +3,22 @@
 //@ doc-flags:--enable-index-page
 //@ doc-flags:-Zunstable-options
 
-//@ has t/trait.Tango.html
-//@ hasraw search-index.js 'Quebec'
-//@ has index.html '//ul[@class="all-items"]//a[@href="q/index.html"]' 'q'
-//@ hasraw s/struct.Sierra.html 'Tango'
-//@ hasraw trait.impl/t/trait.Tango.js 'struct.Sierra.html'
-//@ has index.html '//ul[@class="all-items"]//a[@href="t/index.html"]' 't'
+//@ has index.html
 //@ has index.html '//h1' 'List of all crates'
+//@ has index.html '//ul[@class="all-items"]//a[@href="q/index.html"]' 'q'
 //@ has index.html '//ul[@class="all-items"]//a[@href="s/index.html"]' 's'
-//@ hasraw search-index.js 'Sierra'
-//@ hasraw search-index.js 'Tango'
-//@ has index.html
+//@ has index.html '//ul[@class="all-items"]//a[@href="t/index.html"]' 't'
 //@ has q/struct.Quebec.html
 //@ has s/struct.Sierra.html
+//@ has t/trait.Tango.html
+//@ hasraw s/struct.Sierra.html 'Tango'
+//@ hasraw trait.impl/t/trait.Tango.js 'struct.Sierra.html'
+//@ hasraw search-index.js 'Tango'
+//@ hasraw search-index.js 'Sierra'
+//@ hasraw search-index.js 'Quebec'
 
-// We document multiple crates into the same output directory, which merges the cross-crate information. Everything is available.
+// We document multiple crates into the same output directory, which
+// merges the cross-crate information. Everything is available.
 
 extern crate t;
 pub struct Sierra;
diff --git a/tests/rustdoc/cross-crate-info/cargo-two-no-index/e.rs b/tests/rustdoc/cross-crate-info/cargo-two-no-index/e.rs
index d3e42989b7770..7d64f9481fb80 100644
--- a/tests/rustdoc/cross-crate-info/cargo-two-no-index/e.rs
+++ b/tests/rustdoc/cross-crate-info/cargo-two-no-index/e.rs
@@ -1,14 +1,15 @@
 //@ aux-build:f.rs
 //@ build-aux-docs
 
-//@ hasraw search-index.js 'Echo'
-//@ hasraw search-index.js 'Foxtrot'
-//@ hasraw trait.impl/f/trait.Foxtrot.js 'enum.Echo.html'
-//@ has f/trait.Foxtrot.html
 //@ has e/enum.Echo.html
+//@ has f/trait.Foxtrot.html
 //@ hasraw e/enum.Echo.html 'Foxtrot'
+//@ hasraw trait.impl/f/trait.Foxtrot.js 'enum.Echo.html'
+//@ hasraw search-index.js 'Foxtrot'
+//@ hasraw search-index.js 'Echo'
 
-// document two crates in the same way that cargo does. do not provide --enable-index-page
+// document two crates in the same way that cargo does. do not provide
+// --enable-index-page
 
 extern crate f;
 pub enum Echo {}
diff --git a/tests/rustdoc/cross-crate-info/cargo-two/e.rs b/tests/rustdoc/cross-crate-info/cargo-two/e.rs
index bb845877b52f0..29e3571e6c209 100644
--- a/tests/rustdoc/cross-crate-info/cargo-two/e.rs
+++ b/tests/rustdoc/cross-crate-info/cargo-two/e.rs
@@ -3,18 +3,19 @@
 //@ doc-flags:--enable-index-page
 //@ doc-flags:-Zunstable-options
 
-//@ hasraw search-index.js 'Echo'
-//@ hasraw search-index.js 'Foxtrot'
-//@ has index.html '//ul[@class="all-items"]//a[@href="e/index.html"]' 'e'
-//@ has index.html '//ul[@class="all-items"]//a[@href="f/index.html"]' 'f'
-//@ hasraw trait.impl/f/trait.Foxtrot.js 'enum.Echo.html'
-//@ has f/trait.Foxtrot.html
+//@ has index.html
 //@ has index.html '//h1' 'List of all crates'
+//@ has index.html '//ul[@class="all-items"]//a[@href="f/index.html"]' 'f'
+//@ has index.html '//ul[@class="all-items"]//a[@href="e/index.html"]' 'e'
 //@ has e/enum.Echo.html
-//@ has index.html
+//@ has f/trait.Foxtrot.html
 //@ hasraw e/enum.Echo.html 'Foxtrot'
+//@ hasraw trait.impl/f/trait.Foxtrot.js 'enum.Echo.html'
+//@ hasraw search-index.js 'Foxtrot'
+//@ hasraw search-index.js 'Echo'
 
-// document two crates in the same way that cargo does, writing them both into the same output directory
+// document two crates in the same way that cargo does, writing them both
+// into the same output directory
 
 extern crate f;
 pub enum Echo {}
diff --git a/tests/rustdoc/cross-crate-info/index-on-last/e.rs b/tests/rustdoc/cross-crate-info/index-on-last/e.rs
index 876b94464c372..fee9f4bcddbe4 100644
--- a/tests/rustdoc/cross-crate-info/index-on-last/e.rs
+++ b/tests/rustdoc/cross-crate-info/index-on-last/e.rs
@@ -3,16 +3,16 @@
 //@ doc-flags:--enable-index-page
 //@ doc-flags:-Zunstable-options
 
-//@ hasraw search-index.js 'Echo'
-//@ hasraw search-index.js 'Foxtrot'
-//@ has index.html '//ul[@class="all-items"]//a[@href="e/index.html"]' 'e'
-//@ has index.html '//ul[@class="all-items"]//a[@href="f/index.html"]' 'f'
-//@ hasraw trait.impl/f/trait.Foxtrot.js 'enum.Echo.html'
-//@ has f/trait.Foxtrot.html
+//@ has index.html
 //@ has index.html '//h1' 'List of all crates'
+//@ has index.html '//ul[@class="all-items"]//a[@href="f/index.html"]' 'f'
+//@ has index.html '//ul[@class="all-items"]//a[@href="e/index.html"]' 'e'
 //@ has e/enum.Echo.html
-//@ has index.html
+//@ has f/trait.Foxtrot.html
 //@ hasraw e/enum.Echo.html 'Foxtrot'
+//@ hasraw trait.impl/f/trait.Foxtrot.js 'enum.Echo.html'
+//@ hasraw search-index.js 'Foxtrot'
+//@ hasraw search-index.js 'Echo'
 
 // only declare --enable-index-page to the last rustdoc invocation
 
diff --git a/tests/rustdoc/cross-crate-info/kitchen-sink/i.rs b/tests/rustdoc/cross-crate-info/kitchen-sink/i.rs
index 9df0e9779ffa7..558f47ab7c4c9 100644
--- a/tests/rustdoc/cross-crate-info/kitchen-sink/i.rs
+++ b/tests/rustdoc/cross-crate-info/kitchen-sink/i.rs
@@ -1,31 +1,31 @@
 //@ aux-build:q.rs
 //@ aux-build:r.rs
-//@ aux-build:t.rs
 //@ aux-build:s.rs
+//@ aux-build:t.rs
 //@ build-aux-docs
 //@ doc-flags:--enable-index-page
 //@ doc-flags:-Zunstable-options
 
-//@ hasraw search-index.js 'Quebec'
-//@ hasraw search-index.js 'Sierra'
+//@ has index.html '//h1' 'List of all crates'
 //@ has index.html
-//@ has s/struct.Sierra.html
-//@ hasraw s/struct.Sierra.html 'Tango'
 //@ has index.html '//ul[@class="all-items"]//a[@href="i/index.html"]' 'i'
-//@ has q/struct.Quebec.html
-//@ has type.impl/s/struct.Sierra.js
-//@ hasraw type.impl/s/struct.Sierra.js 'Romeo'
-//@ hasraw type.impl/s/struct.Sierra.js 'Tango'
 //@ has index.html '//ul[@class="all-items"]//a[@href="q/index.html"]' 'q'
-//@ has index.html '//ul[@class="all-items"]//a[@href="t/index.html"]' 't'
+//@ has index.html '//ul[@class="all-items"]//a[@href="r/index.html"]' 'r'
 //@ has index.html '//ul[@class="all-items"]//a[@href="s/index.html"]' 's'
+//@ has index.html '//ul[@class="all-items"]//a[@href="t/index.html"]' 't'
+//@ has q/struct.Quebec.html
 //@ has r/type.Romeo.html
+//@ has s/struct.Sierra.html
 //@ has t/trait.Tango.html
-//@ hasraw search-index.js 'Romeo'
+//@ hasraw s/struct.Sierra.html 'Tango'
 //@ hasraw trait.impl/t/trait.Tango.js 'struct.Sierra.html'
-//@ has index.html '//h1' 'List of all crates'
+//@ hasraw search-index.js 'Quebec'
+//@ hasraw search-index.js 'Romeo'
+//@ hasraw search-index.js 'Sierra'
 //@ hasraw search-index.js 'Tango'
-//@ has index.html '//ul[@class="all-items"]//a[@href="r/index.html"]' 'r'
+//@ has type.impl/s/struct.Sierra.js
+//@ hasraw type.impl/s/struct.Sierra.js 'Tango'
+//@ hasraw type.impl/s/struct.Sierra.js 'Romeo'
 
 // document everything in the default mode
 
diff --git a/tests/rustdoc/cross-crate-info/single-crate-baseline/q.rs b/tests/rustdoc/cross-crate-info/single-crate-baseline/q.rs
index a9e03852f2297..aa5cff73e7463 100644
--- a/tests/rustdoc/cross-crate-info/single-crate-baseline/q.rs
+++ b/tests/rustdoc/cross-crate-info/single-crate-baseline/q.rs
@@ -2,11 +2,11 @@
 //@ doc-flags:--enable-index-page
 //@ doc-flags:-Zunstable-options
 
-//@ hasraw search-index.js 'Quebec'
-//@ has index.html '//ul[@class="all-items"]//a[@href="q/index.html"]' 'q'
-//@ has index.html '//h1' 'List of all crates'
 //@ has index.html
+//@ has index.html '//h1' 'List of all crates'
+//@ has index.html '//ul[@class="all-items"]//a[@href="q/index.html"]' 'q'
 //@ has q/struct.Quebec.html
+//@ hasraw search-index.js 'Quebec'
 
 // there's nothing cross-crate going on here
 
diff --git a/tests/rustdoc/cross-crate-info/single-crate-no-index/q.rs b/tests/rustdoc/cross-crate-info/single-crate-no-index/q.rs
index 38471e02a2820..0cd126e8247d9 100644
--- a/tests/rustdoc/cross-crate-info/single-crate-no-index/q.rs
+++ b/tests/rustdoc/cross-crate-info/single-crate-no-index/q.rs
@@ -1,7 +1,7 @@
 //@ build-aux-docs
 
-//@ hasraw search-index.js 'Quebec'
 //@ has q/struct.Quebec.html
+//@ hasraw search-index.js 'Quebec'
 
 // there's nothing cross-crate going on here
 
diff --git a/tests/rustdoc/cross-crate-info/working-dir-examples/q.rs b/tests/rustdoc/cross-crate-info/working-dir-examples/q.rs
index 89d1349e520fa..ceced1fc46dcd 100644
--- a/tests/rustdoc/cross-crate-info/working-dir-examples/q.rs
+++ b/tests/rustdoc/cross-crate-info/working-dir-examples/q.rs
@@ -5,6 +5,7 @@
 
 //@ has examples
 
-// where will --scrape-examples-output-path resolve the path to be? should be the root output directory
+// where will --scrape-examples-output-path resolve the path to be?
+// should be the root output directory
 
 pub struct Quebec;
diff --git a/tests/rustdoc/cross-crate-info/write-docs-somewhere-else/e.rs b/tests/rustdoc/cross-crate-info/write-docs-somewhere-else/e.rs
index 0480a02bf22f7..6247ed5fd9660 100644
--- a/tests/rustdoc/cross-crate-info/write-docs-somewhere-else/e.rs
+++ b/tests/rustdoc/cross-crate-info/write-docs-somewhere-else/e.rs
@@ -1,14 +1,15 @@
 //@ aux-build:f.rs
 //@ build-aux-docs
 
-//@ hasraw search-index.js 'Echo'
-//@ !hasraw search-index.js 'Foxtrot'
-//@ hasraw trait.impl/f/trait.Foxtrot.js 'enum.Echo.html'
-//@ !has f/trait.Foxtrot.html
 //@ has e/enum.Echo.html
+//@ !has f/trait.Foxtrot.html
 //@ hasraw e/enum.Echo.html 'Foxtrot'
+//@ hasraw trait.impl/f/trait.Foxtrot.js 'enum.Echo.html'
+//@ !hasraw search-index.js 'Foxtrot'
+//@ hasraw search-index.js 'Echo'
 
-// test the fact that our test runner will document this crate somewhere else
+// test the fact that our test runner will document this crate somewhere
+// else
 
 extern crate f;
 pub enum Echo {}

From f6f0ef46f5a9f368183e8c59ee82d0319af7ec9c Mon Sep 17 00:00:00 2001
From: EtomicBomb <ethan@ethan.ws>
Date: Wed, 24 Jul 2024 22:35:14 +0000
Subject: [PATCH 3/6] reformatted rustdoc/cross-crate-info, fixing trailing
 newline issue

---
 .../cargo-transitive-no-index/auxiliary/q.rs                | 2 --
 .../cargo-transitive-no-index/auxiliary/t.rs                | 2 --
 .../rustdoc/cross-crate-info/cargo-transitive-no-index/s.rs | 2 --
 .../cross-crate-info/cargo-transitive/auxiliary/q.rs        | 1 -
 .../cross-crate-info/cargo-transitive/auxiliary/t.rs        | 1 -
 tests/rustdoc/cross-crate-info/cargo-transitive/s.rs        | 1 -
 .../cross-crate-info/cargo-two-no-index/auxiliary/f.rs      | 2 --
 tests/rustdoc/cross-crate-info/cargo-two-no-index/e.rs      | 2 --
 tests/rustdoc/cross-crate-info/cargo-two/auxiliary/f.rs     | 1 -
 tests/rustdoc/cross-crate-info/cargo-two/e.rs               | 1 -
 tests/rustdoc/cross-crate-info/index-on-last/auxiliary/f.rs | 2 --
 tests/rustdoc/cross-crate-info/index-on-last/e.rs           | 1 -
 tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/q.rs  | 1 -
 tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/r.rs  | 1 -
 tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/s.rs  | 1 -
 tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/t.rs  | 1 -
 tests/rustdoc/cross-crate-info/kitchen-sink/i.rs            | 6 ++----
 tests/rustdoc/cross-crate-info/single-crate-baseline/q.rs   | 1 -
 tests/rustdoc/cross-crate-info/single-crate-no-index/q.rs   | 2 --
 tests/rustdoc/cross-crate-info/transitive/auxiliary/q.rs    | 2 --
 tests/rustdoc/cross-crate-info/transitive/auxiliary/t.rs    | 2 --
 tests/rustdoc/cross-crate-info/transitive/s.rs              | 3 ---
 tests/rustdoc/cross-crate-info/two/auxiliary/f.rs           | 2 --
 tests/rustdoc/cross-crate-info/two/e.rs                     | 3 ---
 tests/rustdoc/cross-crate-info/working-dir-examples/q.rs    | 1 -
 .../write-docs-somewhere-else/auxiliary/f.rs                | 2 --
 .../rustdoc/cross-crate-info/write-docs-somewhere-else/e.rs | 2 --
 27 files changed, 2 insertions(+), 46 deletions(-)

diff --git a/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/auxiliary/q.rs b/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/auxiliary/q.rs
index 32ad96d3e8e36..5d0881029cb2f 100644
--- a/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/auxiliary/q.rs
+++ b/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/auxiliary/q.rs
@@ -1,4 +1,2 @@
 //@ build-aux-docs
-
-
 pub struct Quebec;
diff --git a/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/auxiliary/t.rs b/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/auxiliary/t.rs
index e03c9a1c68c3b..fab9ec4a92b96 100644
--- a/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/auxiliary/t.rs
+++ b/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/auxiliary/t.rs
@@ -1,6 +1,4 @@
 //@ aux-build:q.rs
 //@ build-aux-docs
-
-
 extern crate q;
 pub trait Tango {}
diff --git a/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/s.rs b/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/s.rs
index 639b772374fc8..85c460ace642f 100644
--- a/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/s.rs
+++ b/tests/rustdoc/cross-crate-info/cargo-transitive-no-index/s.rs
@@ -1,6 +1,5 @@
 //@ aux-build:t.rs
 //@ build-aux-docs
-
 //@ has q/struct.Quebec.html
 //@ has s/struct.Sierra.html
 //@ has t/trait.Tango.html
@@ -12,7 +11,6 @@
 
 // We document multiple crates into the same output directory, which
 // merges the cross-crate information. Everything is available.
-
 extern crate t;
 pub struct Sierra;
 impl t::Tango for Sierra {}
diff --git a/tests/rustdoc/cross-crate-info/cargo-transitive/auxiliary/q.rs b/tests/rustdoc/cross-crate-info/cargo-transitive/auxiliary/q.rs
index e32fdbaabfe21..932a0b17206d6 100644
--- a/tests/rustdoc/cross-crate-info/cargo-transitive/auxiliary/q.rs
+++ b/tests/rustdoc/cross-crate-info/cargo-transitive/auxiliary/q.rs
@@ -2,5 +2,4 @@
 //@ doc-flags:--enable-index-page
 //@ doc-flags:-Zunstable-options
 
-
 pub struct Quebec;
diff --git a/tests/rustdoc/cross-crate-info/cargo-transitive/auxiliary/t.rs b/tests/rustdoc/cross-crate-info/cargo-transitive/auxiliary/t.rs
index 0a49072b68a67..c21a59c65188f 100644
--- a/tests/rustdoc/cross-crate-info/cargo-transitive/auxiliary/t.rs
+++ b/tests/rustdoc/cross-crate-info/cargo-transitive/auxiliary/t.rs
@@ -3,6 +3,5 @@
 //@ doc-flags:--enable-index-page
 //@ doc-flags:-Zunstable-options
 
-
 extern crate q;
 pub trait Tango {}
diff --git a/tests/rustdoc/cross-crate-info/cargo-transitive/s.rs b/tests/rustdoc/cross-crate-info/cargo-transitive/s.rs
index 4383d089c4c73..68bfc34883bd8 100644
--- a/tests/rustdoc/cross-crate-info/cargo-transitive/s.rs
+++ b/tests/rustdoc/cross-crate-info/cargo-transitive/s.rs
@@ -19,7 +19,6 @@
 
 // We document multiple crates into the same output directory, which
 // merges the cross-crate information. Everything is available.
-
 extern crate t;
 pub struct Sierra;
 impl t::Tango for Sierra {}
diff --git a/tests/rustdoc/cross-crate-info/cargo-two-no-index/auxiliary/f.rs b/tests/rustdoc/cross-crate-info/cargo-two-no-index/auxiliary/f.rs
index 1bfc785535b53..abc580a388cd2 100644
--- a/tests/rustdoc/cross-crate-info/cargo-two-no-index/auxiliary/f.rs
+++ b/tests/rustdoc/cross-crate-info/cargo-two-no-index/auxiliary/f.rs
@@ -1,4 +1,2 @@
 //@ build-aux-docs
-
-
 pub trait Foxtrot {}
diff --git a/tests/rustdoc/cross-crate-info/cargo-two-no-index/e.rs b/tests/rustdoc/cross-crate-info/cargo-two-no-index/e.rs
index 7d64f9481fb80..c93298f969eab 100644
--- a/tests/rustdoc/cross-crate-info/cargo-two-no-index/e.rs
+++ b/tests/rustdoc/cross-crate-info/cargo-two-no-index/e.rs
@@ -1,6 +1,5 @@
 //@ aux-build:f.rs
 //@ build-aux-docs
-
 //@ has e/enum.Echo.html
 //@ has f/trait.Foxtrot.html
 //@ hasraw e/enum.Echo.html 'Foxtrot'
@@ -10,7 +9,6 @@
 
 // document two crates in the same way that cargo does. do not provide
 // --enable-index-page
-
 extern crate f;
 pub enum Echo {}
 impl f::Foxtrot for Echo {}
diff --git a/tests/rustdoc/cross-crate-info/cargo-two/auxiliary/f.rs b/tests/rustdoc/cross-crate-info/cargo-two/auxiliary/f.rs
index e84835b3e3102..a2a7033b13112 100644
--- a/tests/rustdoc/cross-crate-info/cargo-two/auxiliary/f.rs
+++ b/tests/rustdoc/cross-crate-info/cargo-two/auxiliary/f.rs
@@ -2,5 +2,4 @@
 //@ doc-flags:--enable-index-page
 //@ doc-flags:-Zunstable-options
 
-
 pub trait Foxtrot {}
diff --git a/tests/rustdoc/cross-crate-info/cargo-two/e.rs b/tests/rustdoc/cross-crate-info/cargo-two/e.rs
index 29e3571e6c209..00f86cbc34889 100644
--- a/tests/rustdoc/cross-crate-info/cargo-two/e.rs
+++ b/tests/rustdoc/cross-crate-info/cargo-two/e.rs
@@ -16,7 +16,6 @@
 
 // document two crates in the same way that cargo does, writing them both
 // into the same output directory
-
 extern crate f;
 pub enum Echo {}
 impl f::Foxtrot for Echo {}
diff --git a/tests/rustdoc/cross-crate-info/index-on-last/auxiliary/f.rs b/tests/rustdoc/cross-crate-info/index-on-last/auxiliary/f.rs
index 1bfc785535b53..abc580a388cd2 100644
--- a/tests/rustdoc/cross-crate-info/index-on-last/auxiliary/f.rs
+++ b/tests/rustdoc/cross-crate-info/index-on-last/auxiliary/f.rs
@@ -1,4 +1,2 @@
 //@ build-aux-docs
-
-
 pub trait Foxtrot {}
diff --git a/tests/rustdoc/cross-crate-info/index-on-last/e.rs b/tests/rustdoc/cross-crate-info/index-on-last/e.rs
index fee9f4bcddbe4..ffee898cd966d 100644
--- a/tests/rustdoc/cross-crate-info/index-on-last/e.rs
+++ b/tests/rustdoc/cross-crate-info/index-on-last/e.rs
@@ -15,7 +15,6 @@
 //@ hasraw search-index.js 'Echo'
 
 // only declare --enable-index-page to the last rustdoc invocation
-
 extern crate f;
 pub enum Echo {}
 impl f::Foxtrot for Echo {}
diff --git a/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/q.rs b/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/q.rs
index e32fdbaabfe21..932a0b17206d6 100644
--- a/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/q.rs
+++ b/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/q.rs
@@ -2,5 +2,4 @@
 //@ doc-flags:--enable-index-page
 //@ doc-flags:-Zunstable-options
 
-
 pub struct Quebec;
diff --git a/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/r.rs b/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/r.rs
index c0ada1aea1a85..2c0db2abc53d9 100644
--- a/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/r.rs
+++ b/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/r.rs
@@ -3,6 +3,5 @@
 //@ doc-flags:--enable-index-page
 //@ doc-flags:-Zunstable-options
 
-
 extern crate s;
 pub type Romeo = s::Sierra;
diff --git a/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/s.rs b/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/s.rs
index 6b414a289f5a8..355d3f1aaa883 100644
--- a/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/s.rs
+++ b/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/s.rs
@@ -3,7 +3,6 @@
 //@ doc-flags:--enable-index-page
 //@ doc-flags:-Zunstable-options
 
-
 extern crate t;
 pub struct Sierra;
 impl t::Tango for Sierra {}
diff --git a/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/t.rs b/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/t.rs
index 0a49072b68a67..c21a59c65188f 100644
--- a/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/t.rs
+++ b/tests/rustdoc/cross-crate-info/kitchen-sink/auxiliary/t.rs
@@ -3,6 +3,5 @@
 //@ doc-flags:--enable-index-page
 //@ doc-flags:-Zunstable-options
 
-
 extern crate q;
 pub trait Tango {}
diff --git a/tests/rustdoc/cross-crate-info/kitchen-sink/i.rs b/tests/rustdoc/cross-crate-info/kitchen-sink/i.rs
index 558f47ab7c4c9..bcb9464795af2 100644
--- a/tests/rustdoc/cross-crate-info/kitchen-sink/i.rs
+++ b/tests/rustdoc/cross-crate-info/kitchen-sink/i.rs
@@ -1,7 +1,7 @@
-//@ aux-build:q.rs
 //@ aux-build:r.rs
-//@ aux-build:s.rs
+//@ aux-build:q.rs
 //@ aux-build:t.rs
+//@ aux-build:s.rs
 //@ build-aux-docs
 //@ doc-flags:--enable-index-page
 //@ doc-flags:-Zunstable-options
@@ -28,5 +28,3 @@
 //@ hasraw type.impl/s/struct.Sierra.js 'Romeo'
 
 // document everything in the default mode
-
-
diff --git a/tests/rustdoc/cross-crate-info/single-crate-baseline/q.rs b/tests/rustdoc/cross-crate-info/single-crate-baseline/q.rs
index aa5cff73e7463..c5e3dc0a0f4e5 100644
--- a/tests/rustdoc/cross-crate-info/single-crate-baseline/q.rs
+++ b/tests/rustdoc/cross-crate-info/single-crate-baseline/q.rs
@@ -9,5 +9,4 @@
 //@ hasraw search-index.js 'Quebec'
 
 // there's nothing cross-crate going on here
-
 pub struct Quebec;
diff --git a/tests/rustdoc/cross-crate-info/single-crate-no-index/q.rs b/tests/rustdoc/cross-crate-info/single-crate-no-index/q.rs
index 0cd126e8247d9..d3e71fa0ce35f 100644
--- a/tests/rustdoc/cross-crate-info/single-crate-no-index/q.rs
+++ b/tests/rustdoc/cross-crate-info/single-crate-no-index/q.rs
@@ -1,8 +1,6 @@
 //@ build-aux-docs
-
 //@ has q/struct.Quebec.html
 //@ hasraw search-index.js 'Quebec'
 
 // there's nothing cross-crate going on here
-
 pub struct Quebec;
diff --git a/tests/rustdoc/cross-crate-info/transitive/auxiliary/q.rs b/tests/rustdoc/cross-crate-info/transitive/auxiliary/q.rs
index 32ad96d3e8e36..5d0881029cb2f 100644
--- a/tests/rustdoc/cross-crate-info/transitive/auxiliary/q.rs
+++ b/tests/rustdoc/cross-crate-info/transitive/auxiliary/q.rs
@@ -1,4 +1,2 @@
 //@ build-aux-docs
-
-
 pub struct Quebec;
diff --git a/tests/rustdoc/cross-crate-info/transitive/auxiliary/t.rs b/tests/rustdoc/cross-crate-info/transitive/auxiliary/t.rs
index e03c9a1c68c3b..fab9ec4a92b96 100644
--- a/tests/rustdoc/cross-crate-info/transitive/auxiliary/t.rs
+++ b/tests/rustdoc/cross-crate-info/transitive/auxiliary/t.rs
@@ -1,6 +1,4 @@
 //@ aux-build:q.rs
 //@ build-aux-docs
-
-
 extern crate q;
 pub trait Tango {}
diff --git a/tests/rustdoc/cross-crate-info/transitive/s.rs b/tests/rustdoc/cross-crate-info/transitive/s.rs
index a758bd68be22f..0a4e5f646ddaa 100644
--- a/tests/rustdoc/cross-crate-info/transitive/s.rs
+++ b/tests/rustdoc/cross-crate-info/transitive/s.rs
@@ -1,9 +1,6 @@
 //@ aux-build:t.rs
 //@ build-aux-docs
-
-
 // simple test to see if we support building transitive crates
-
 extern crate t;
 pub struct Sierra;
 impl t::Tango for Sierra {}
diff --git a/tests/rustdoc/cross-crate-info/two/auxiliary/f.rs b/tests/rustdoc/cross-crate-info/two/auxiliary/f.rs
index 1bfc785535b53..abc580a388cd2 100644
--- a/tests/rustdoc/cross-crate-info/two/auxiliary/f.rs
+++ b/tests/rustdoc/cross-crate-info/two/auxiliary/f.rs
@@ -1,4 +1,2 @@
 //@ build-aux-docs
-
-
 pub trait Foxtrot {}
diff --git a/tests/rustdoc/cross-crate-info/two/e.rs b/tests/rustdoc/cross-crate-info/two/e.rs
index 431e73c390d4a..9665af62706d1 100644
--- a/tests/rustdoc/cross-crate-info/two/e.rs
+++ b/tests/rustdoc/cross-crate-info/two/e.rs
@@ -1,9 +1,6 @@
 //@ aux-build:f.rs
 //@ build-aux-docs
-
-
 // simple test to assert that we can do a two-level aux-build
-
 extern crate f;
 pub enum Echo {}
 impl f::Foxtrot for Echo {}
diff --git a/tests/rustdoc/cross-crate-info/working-dir-examples/q.rs b/tests/rustdoc/cross-crate-info/working-dir-examples/q.rs
index ceced1fc46dcd..a7ab062fd9e28 100644
--- a/tests/rustdoc/cross-crate-info/working-dir-examples/q.rs
+++ b/tests/rustdoc/cross-crate-info/working-dir-examples/q.rs
@@ -7,5 +7,4 @@
 
 // where will --scrape-examples-output-path resolve the path to be?
 // should be the root output directory
-
 pub struct Quebec;
diff --git a/tests/rustdoc/cross-crate-info/write-docs-somewhere-else/auxiliary/f.rs b/tests/rustdoc/cross-crate-info/write-docs-somewhere-else/auxiliary/f.rs
index 52e02e8b89715..f8c9adcaf9cad 100644
--- a/tests/rustdoc/cross-crate-info/write-docs-somewhere-else/auxiliary/f.rs
+++ b/tests/rustdoc/cross-crate-info/write-docs-somewhere-else/auxiliary/f.rs
@@ -1,5 +1,3 @@
 //@ build-aux-docs
 //@ unique-doc-out-dir
-
-
 pub trait Foxtrot {}
diff --git a/tests/rustdoc/cross-crate-info/write-docs-somewhere-else/e.rs b/tests/rustdoc/cross-crate-info/write-docs-somewhere-else/e.rs
index 6247ed5fd9660..9dcec211e1787 100644
--- a/tests/rustdoc/cross-crate-info/write-docs-somewhere-else/e.rs
+++ b/tests/rustdoc/cross-crate-info/write-docs-somewhere-else/e.rs
@@ -1,6 +1,5 @@
 //@ aux-build:f.rs
 //@ build-aux-docs
-
 //@ has e/enum.Echo.html
 //@ !has f/trait.Foxtrot.html
 //@ hasraw e/enum.Echo.html 'Foxtrot'
@@ -10,7 +9,6 @@
 
 // test the fact that our test runner will document this crate somewhere
 // else
-
 extern crate f;
 pub enum Echo {}
 impl f::Foxtrot for Echo {}

From 12d87ee237a1f79c00ccd22424432f5ab869ed22 Mon Sep 17 00:00:00 2001
From: EtomicBomb <ethan@ethan.ws>
Date: Thu, 25 Jul 2024 17:59:32 +0000
Subject: [PATCH 4/6] file_stem and comment per notriddle

---
 src/tools/compiletest/src/runtest.rs | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index 2d298dfbc06f7..2beff593f08ad 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -1610,6 +1610,8 @@ impl<'test> TestCx<'test> {
                 };
                 // Create the directory for the stdout/stderr files.
                 create_dir_all(aux_cx.output_base_dir()).unwrap();
+                // use root_testpaths here, because aux-builds should have the
+                // same --out-dir and auxiliary directory.
                 let auxres = aux_cx.document(&root_out_dir, root_testpaths);
                 if !auxres.status.success() {
                     return auxres;
@@ -1624,14 +1626,7 @@ impl<'test> TestCx<'test> {
         // actual --out-dir given to the auxiliary or test, as opposed to the root out dir for the entire
         // test
         let out_dir: Cow<'_, Path> = if self.props.unique_doc_out_dir {
-            let file_name = self
-                .testpaths
-                .file
-                .file_name()
-                .expect("file name should not be empty")
-                .to_str()
-                .expect("file name utf8")
-                .trim_end_matches(".rs");
+            let file_name = self.testpaths.file.file_stem().expect("file name should not be empty");
             let out_dir = PathBuf::from_iter([
                 root_out_dir,
                 Path::new("docs"),

From f91da72cb75f03739985926c5e5561611f783b80 Mon Sep 17 00:00:00 2001
From: EtomicBomb <ethan@ethan.ws>
Date: Mon, 29 Jul 2024 14:41:09 +0000
Subject: [PATCH 5/6] merge conflicts; fix rebase duplicating imports

---
 src/tools/compiletest/src/runtest.rs | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index 2beff593f08ad..55f676e708670 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -1,16 +1,5 @@
 // ignore-tidy-filelength
 
-use crate::compute_diff::{write_diff, write_filtered_diff};
-use crate::errors::{self, Error, ErrorKind};
-use crate::header::TestProps;
-use crate::json;
-use crate::read2::{read2_abbreviated, Truncated};
-use crate::util::{add_dylib_path, copy_dir_all, dylib_env_var, logv, static_regex, PathBufExt};
-use crate::ColorConfig;
-use colored::Colorize;
-use miropt_test_tools::{files_for_miropt_test, MiroptTest, MiroptTestFile};
-use regex::{Captures, Regex};
-use rustfix::{apply_suggestions, get_suggestions_from_json, Filter};
 use std::borrow::Cow;
 use std::collections::{HashMap, HashSet};
 use std::ffi::{OsStr, OsString};

From bd23e0eb2694752f573eafd0d894a2b16d10fd7b Mon Sep 17 00:00:00 2001
From: EtomicBomb <ethan@ethan.ws>
Date: Wed, 31 Jul 2024 00:20:56 +0000
Subject: [PATCH 6/6] canonicalize path in another place to fix #128411

---
 src/tools/compiletest/src/runtest.rs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index 55f676e708670..2b7601a7c73b5 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -2968,7 +2968,9 @@ impl<'test> TestCx<'test> {
         for _ in res.stdout.split('\n').filter(|s| s.starts_with("test ")).inspect(|s| {
             if let Some((left, right)) = s.split_once(" - ") {
                 let path = left.rsplit("test ").next().unwrap();
-                if let Some(ref mut v) = files.get_mut(&path.replace('\\', "/")) {
+                let path = fs::canonicalize(&path).expect("failed to canonicalize");
+                let path = path.to_str().unwrap().replace('\\', "/");
+                if let Some(ref mut v) = files.get_mut(&path) {
                     tested += 1;
                     let mut iter = right.split("(line ");
                     iter.next();