Skip to content

Commit 20f063a

Browse files
authored
Rollup merge of rust-lang#58848 - GuillaumeGomez:fix-cache-issues, r=Mark-Simulacrum,ollie27
Prevent cache issues on version updates Fixes rust-lang#58827. cc @rust-lang/infra
2 parents 83d91d3 + 5652dd6 commit 20f063a

File tree

3 files changed

+31
-16
lines changed

3 files changed

+31
-16
lines changed

src/bootstrap/bin/rustdoc.rs

+11
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,17 @@ fn main() {
6969
.arg("unstable-options");
7070
}
7171
cmd.arg("--generate-redirect-pages");
72+
has_unstable = true;
73+
}
74+
75+
// Needed to be able to run all rustdoc tests.
76+
if let Some(ref x) = env::var_os("RUSTDOC_RESOURCE_SUFFIX") {
77+
// This "unstable-options" can be removed when `--resource-suffix` is stabilized
78+
if !has_unstable {
79+
cmd.arg("-Z")
80+
.arg("unstable-options");
81+
}
82+
cmd.arg("--resource-suffix").arg(x);
7283
}
7384

7485
if verbose > 1 {

src/bootstrap/doc.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -343,12 +343,9 @@ fn invoke_rustdoc(
343343
.arg("--html-before-content").arg(&version_info)
344344
.arg("--html-in-header").arg(&header)
345345
.arg("--markdown-no-toc")
346-
.arg("--markdown-playground-url")
347-
.arg("https://play.rust-lang.org/")
348-
.arg("-o").arg(&out)
349-
.arg(&path)
350-
.arg("--markdown-css")
351-
.arg("../rust.css");
346+
.arg("--markdown-playground-url").arg("https://play.rust-lang.org/")
347+
.arg("-o").arg(&out).arg(&path)
348+
.arg("--markdown-css").arg("../rust.css");
352349

353350
builder.run(&mut cmd);
354351
}
@@ -431,8 +428,7 @@ impl Step for Standalone {
431428
.arg("--html-in-header").arg(&favicon)
432429
.arg("--markdown-no-toc")
433430
.arg("--index-page").arg(&builder.src.join("src/doc/index.md"))
434-
.arg("--markdown-playground-url")
435-
.arg("https://play.rust-lang.org/")
431+
.arg("--markdown-playground-url").arg("https://play.rust-lang.org/")
436432
.arg("-o").arg(&out)
437433
.arg(&path);
438434

@@ -523,6 +519,7 @@ impl Step for Std {
523519
.arg("--markdown-css").arg("rust.css")
524520
.arg("--markdown-no-toc")
525521
.arg("--generate-redirect-pages")
522+
.arg("--resource-suffix").arg(crate::channel::CFG_RELEASE_NUM)
526523
.arg("--index-page").arg(&builder.src.join("src/doc/index.md"));
527524

528525
builder.run(&mut cargo);
@@ -589,6 +586,7 @@ impl Step for Test {
589586

590587
cargo.arg("--no-deps")
591588
.arg("-p").arg("test")
589+
.env("RUSTDOC_RESOURCE_SUFFIX", crate::channel::CFG_RELEASE_NUM)
592590
.env("RUSTDOC_GENERATE_REDIRECT_PAGES", "1");
593591

594592
builder.run(&mut cargo);
@@ -660,6 +658,7 @@ impl Step for WhitelistedRustc {
660658
// for which docs must be built.
661659
for krate in &["proc_macro"] {
662660
cargo.arg("-p").arg(krate)
661+
.env("RUSTDOC_RESOURCE_SUFFIX", crate::channel::CFG_RELEASE_NUM)
663662
.env("RUSTDOC_GENERATE_REDIRECT_PAGES", "1");
664663
}
665664

@@ -890,6 +889,7 @@ impl Step for ErrorIndex {
890889
);
891890
index.arg("html");
892891
index.arg(out.join("error-index.html"));
892+
index.arg(crate::channel::CFG_RELEASE_NUM);
893893

894894
// FIXME: shouldn't have to pass this env var
895895
index.env("CFG_BUILD", &builder.config.build)

src/tools/error_index_generator/main.rs

+12-8
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ enum OutputFormat {
2727
}
2828

2929
impl OutputFormat {
30-
fn from(format: &str) -> OutputFormat {
30+
fn from(format: &str, resource_suffix: &str) -> OutputFormat {
3131
match &*format.to_lowercase() {
32-
"html" => OutputFormat::HTML(HTMLFormatter(RefCell::new(IdMap::new()))),
32+
"html" => OutputFormat::HTML(HTMLFormatter(RefCell::new(IdMap::new()),
33+
resource_suffix.to_owned())),
3334
"markdown" => OutputFormat::Markdown(MarkdownFormatter),
3435
s => OutputFormat::Unknown(s.to_owned()),
3536
}
@@ -44,7 +45,7 @@ trait Formatter {
4445
fn footer(&self, output: &mut dyn Write) -> Result<(), Box<dyn Error>>;
4546
}
4647

47-
struct HTMLFormatter(RefCell<IdMap>);
48+
struct HTMLFormatter(RefCell<IdMap>, String);
4849
struct MarkdownFormatter;
4950

5051
impl Formatter for HTMLFormatter {
@@ -55,7 +56,7 @@ impl Formatter for HTMLFormatter {
5556
<title>Rust Compiler Error Index</title>
5657
<meta charset="utf-8">
5758
<!-- Include rust.css after light.css so its rules take priority. -->
58-
<link rel="stylesheet" type="text/css" href="light.css"/>
59+
<link rel="stylesheet" type="text/css" href="light{suffix}.css"/>
5960
<link rel="stylesheet" type="text/css" href="rust.css"/>
6061
<style>
6162
.error-undescribed {{
@@ -64,7 +65,7 @@ impl Formatter for HTMLFormatter {
6465
</style>
6566
</head>
6667
<body>
67-
"##)?;
68+
"##, suffix=self.1)?;
6869
Ok(())
6970
}
7071

@@ -242,9 +243,12 @@ fn main_with_result(format: OutputFormat, dst: &Path) -> Result<(), Box<dyn Erro
242243

243244
fn parse_args() -> (OutputFormat, PathBuf) {
244245
let mut args = env::args().skip(1);
245-
let format = args.next().map(|a| OutputFormat::from(&a))
246-
.unwrap_or(OutputFormat::from("html"));
247-
let dst = args.next().map(PathBuf::from).unwrap_or_else(|| {
246+
let format = args.next();
247+
let dst = args.next();
248+
let resource_suffix = args.next().unwrap_or_else(String::new);
249+
let format = format.map(|a| OutputFormat::from(&a, &resource_suffix))
250+
.unwrap_or(OutputFormat::from("html", &resource_suffix));
251+
let dst = dst.map(PathBuf::from).unwrap_or_else(|| {
248252
match format {
249253
OutputFormat::HTML(..) => PathBuf::from("doc/error-index.html"),
250254
OutputFormat::Markdown(..) => PathBuf::from("doc/error-index.md"),

0 commit comments

Comments
 (0)