1
Fork 0

Auto merge of #95502 - jyn514:doc-rustc, r=Mark-Simulacrum

Fix `x doc compiler/rustc`

This also has a few cleanups to `doc.rs`. The last two commits I don't care about, but the first commit I'd like to keep - it will be very useful for https://github.com/rust-lang/rust/issues/44293.

Fixes https://github.com/rust-lang/rust/issues/95447.
This commit is contained in:
bors 2022-04-10 06:28:40 +00:00
commit 341883d051
4 changed files with 30 additions and 68 deletions

View file

@ -7,7 +7,6 @@
//! Everything here is basically just a shim around calling either `rustbook` or //! Everything here is basically just a shim around calling either `rustbook` or
//! `rustdoc`. //! `rustdoc`.
use std::collections::HashSet;
use std::fs; use std::fs;
use std::io; use std::io;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
@ -554,13 +553,9 @@ impl Step for Rustc {
let paths = builder let paths = builder
.paths .paths
.iter() .iter()
.map(components_simplified) .filter(|path| {
.filter_map(|path| { let components = components_simplified(path);
if path.get(0) == Some(&"compiler") { components.len() >= 2 && components[0] == "compiler"
path.get(1).map(|p| p.to_owned())
} else {
None
}
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
@ -608,38 +603,22 @@ impl Step for Rustc {
cargo.rustdocflag("--extern-html-root-url"); cargo.rustdocflag("--extern-html-root-url");
cargo.rustdocflag("ena=https://docs.rs/ena/latest/"); cargo.rustdocflag("ena=https://docs.rs/ena/latest/");
let mut compiler_crates = HashSet::new(); let root_crates = if paths.is_empty() {
vec![
if paths.is_empty() { INTERNER.intern_str("rustc_driver"),
// Find dependencies for top level crates. INTERNER.intern_str("rustc_codegen_llvm"),
for root_crate in &["rustc_driver", "rustc_codegen_llvm", "rustc_codegen_ssa"] { INTERNER.intern_str("rustc_codegen_ssa"),
compiler_crates.extend( ]
builder
.in_tree_crates(root_crate, Some(target))
.into_iter()
.map(|krate| krate.name),
);
}
} else { } else {
for root_crate in paths { paths.into_iter().map(|p| builder.crate_paths[p]).collect()
if !builder.src.join("compiler").join(&root_crate).exists() { };
builder.info(&format!( // Find dependencies for top level crates.
"\tskipping - compiler/{} (unknown compiler crate)", let compiler_crates = root_crates.iter().flat_map(|krate| {
root_crate builder.in_tree_crates(krate, Some(target)).into_iter().map(|krate| krate.name)
)); });
} else {
compiler_crates.extend(
builder
.in_tree_crates(root_crate, Some(target))
.into_iter()
.map(|krate| krate.name),
);
}
}
}
let mut to_open = None; let mut to_open = None;
for krate in &compiler_crates { for krate in compiler_crates {
// Create all crate output directories first to make sure rustdoc uses // Create all crate output directories first to make sure rustdoc uses
// relative links. // relative links.
// FIXME: Cargo should probably do this itself. // FIXME: Cargo should probably do this itself.

View file

@ -302,7 +302,9 @@ pub struct Build {
ar: HashMap<TargetSelection, PathBuf>, ar: HashMap<TargetSelection, PathBuf>,
ranlib: HashMap<TargetSelection, PathBuf>, ranlib: HashMap<TargetSelection, PathBuf>,
// Miscellaneous // Miscellaneous
// allow bidirectional lookups: both name -> path and path -> name
crates: HashMap<Interned<String>, Crate>, crates: HashMap<Interned<String>, Crate>,
crate_paths: HashMap<PathBuf, Interned<String>>,
is_sudo: bool, is_sudo: bool,
ci_env: CiEnv, ci_env: CiEnv,
delayed_failures: RefCell<Vec<String>>, delayed_failures: RefCell<Vec<String>>,
@ -492,6 +494,7 @@ impl Build {
ar: HashMap::new(), ar: HashMap::new(),
ranlib: HashMap::new(), ranlib: HashMap::new(),
crates: HashMap::new(), crates: HashMap::new(),
crate_paths: HashMap::new(),
is_sudo, is_sudo,
ci_env: CiEnv::current(), ci_env: CiEnv::current(),
delayed_failures: RefCell::new(Vec::new()), delayed_failures: RefCell::new(Vec::new()),

View file

@ -49,7 +49,11 @@ pub fn build(build: &mut Build) {
.filter(|dep| dep.source.is_none()) .filter(|dep| dep.source.is_none())
.map(|dep| INTERNER.intern_string(dep.name)) .map(|dep| INTERNER.intern_string(dep.name))
.collect(); .collect();
build.crates.insert(name, Crate { name, deps, path }); let krate = Crate { name, deps, path };
let relative_path = krate.local_path(build);
build.crates.insert(name, krate);
let existing_path = build.crate_paths.insert(relative_path, name);
assert!(existing_path.is_none(), "multiple crates with the same path");
} }
} }
} }

View file

@ -21,7 +21,6 @@ use crate::native;
use crate::tool::{self, SourceType, Tool}; use crate::tool::{self, SourceType, Tool};
use crate::toolstate::ToolState; use crate::toolstate::ToolState;
use crate::util::{self, add_link_lib_path, dylib_path, dylib_path_var, output, t}; use crate::util::{self, add_link_lib_path, dylib_path, dylib_path_var, output, t};
use crate::Crate as CargoCrate;
use crate::{envify, CLang, DocTests, GitRepo, Mode}; use crate::{envify, CLang, DocTests, GitRepo, Mode};
const ADB_TEST_DIR: &str = "/data/tmp/work"; const ADB_TEST_DIR: &str = "/data/tmp/work";
@ -1901,19 +1900,10 @@ impl Step for CrateLibrustc {
fn make_run(run: RunConfig<'_>) { fn make_run(run: RunConfig<'_>) {
let builder = run.builder; let builder = run.builder;
let compiler = builder.compiler(builder.top_stage, run.build_triple()); let compiler = builder.compiler(builder.top_stage, run.build_triple());
let krate = builder.crate_paths[&run.path];
let test_kind = builder.kind.into();
for krate in builder.in_tree_crates("rustc-main", Some(run.target)) { builder.ensure(CrateLibrustc { compiler, target: run.target, test_kind, krate });
if krate.path.ends_with(&run.path) {
let test_kind = builder.kind.into();
builder.ensure(CrateLibrustc {
compiler,
target: run.target,
test_kind,
krate: krate.name,
});
}
}
} }
fn run(self, builder: &Builder<'_>) { fn run(self, builder: &Builder<'_>) {
@ -1947,24 +1937,10 @@ impl Step for Crate {
fn make_run(run: RunConfig<'_>) { fn make_run(run: RunConfig<'_>) {
let builder = run.builder; let builder = run.builder;
let compiler = builder.compiler(builder.top_stage, run.build_triple()); let compiler = builder.compiler(builder.top_stage, run.build_triple());
let test_kind = builder.kind.into();
let krate = builder.crate_paths[&run.path];
let make = |mode: Mode, krate: &CargoCrate| { builder.ensure(Crate { compiler, target: run.target, mode: Mode::Std, test_kind, krate });
let test_kind = builder.kind.into();
builder.ensure(Crate {
compiler,
target: run.target,
mode,
test_kind,
krate: krate.name,
});
};
for krate in builder.in_tree_crates("test", Some(run.target)) {
if krate.path.ends_with(&run.path) {
make(Mode::Std, krate);
}
}
} }
/// Runs all unit tests plus documentation tests for a given crate defined /// Runs all unit tests plus documentation tests for a given crate defined