Skip to content

Commit 7231591

Browse files
committed
Reduce duplication in impl Step for doc::Rustc
This should have no user-visible change.
1 parent 43c16ac commit 7231591

File tree

1 file changed

+13
-24
lines changed

1 file changed

+13
-24
lines changed

src/bootstrap/doc.rs

+13-24
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
//! Everything here is basically just a shim around calling either `rustbook` or
88
//! `rustdoc`.
99
10-
use std::collections::HashSet;
1110
use std::fs;
1211
use std::io;
1312
use std::path::{Path, PathBuf};
@@ -604,32 +603,22 @@ impl Step for Rustc {
604603
cargo.rustdocflag("--extern-html-root-url");
605604
cargo.rustdocflag("ena=https://docs.rs/ena/latest/");
606605

607-
let mut compiler_crates = HashSet::new();
608-
609-
if paths.is_empty() {
610-
// Find dependencies for top level crates.
611-
for root_crate in &["rustc_driver", "rustc_codegen_llvm", "rustc_codegen_ssa"] {
612-
compiler_crates.extend(
613-
builder
614-
.in_tree_crates(root_crate, Some(target))
615-
.into_iter()
616-
.map(|krate| krate.name),
617-
);
618-
}
606+
let root_crates = if paths.is_empty() {
607+
vec![
608+
INTERNER.intern_str("rustc_driver"),
609+
INTERNER.intern_str("rustc_codegen_llvm"),
610+
INTERNER.intern_str("rustc_codegen_ssa"),
611+
]
619612
} else {
620-
for root_crate_path in paths {
621-
let root_crate = builder.crate_paths[root_crate_path];
622-
compiler_crates.extend(
623-
builder
624-
.in_tree_crates(&root_crate, Some(target))
625-
.into_iter()
626-
.map(|krate| krate.name),
627-
);
628-
}
629-
}
613+
paths.into_iter().map(|p| builder.crate_paths[p]).collect()
614+
};
615+
// Find dependencies for top level crates.
616+
let compiler_crates = root_crates.iter().flat_map(|krate| {
617+
builder.in_tree_crates(krate, Some(target)).into_iter().map(|krate| krate.name)
618+
});
630619

631620
let mut to_open = None;
632-
for krate in &compiler_crates {
621+
for krate in compiler_crates {
633622
// Create all crate output directories first to make sure rustdoc uses
634623
// relative links.
635624
// FIXME: Cargo should probably do this itself.

0 commit comments

Comments
 (0)