Skip to content

Commit 7ea286e

Browse files
render the rust version into std/compiler/test docs
1 parent fcee950 commit 7ea286e

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/bootstrap/bin/rustdoc.rs

+8
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ fn main() {
4848
cmd.arg("-Z").arg("force-unstable-if-unmarked");
4949
}
5050

51+
// Bootstrap's Cargo-command builder sets this variable to the current Rust version; let's pick
52+
// it up so we can make rustdoc print this into the docs
53+
if let Some(version) = env::var_os("RUSTDOC_CRATE_VERSION") {
54+
// This "unstable-options" can be removed when `--crate-version` is stabilized
55+
cmd.arg("-Z").arg("unstable-options")
56+
.arg("--crate-version").arg(version);
57+
}
58+
5159
std::process::exit(match cmd.status() {
5260
Ok(s) => s.code().unwrap_or(1),
5361
Err(e) => panic!("\n\nfailed to run {:?}: {}\n\n", cmd, e),

src/bootstrap/builder.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,8 @@ impl<'a> Builder<'a> {
418418
.env("RUSTC_SYSROOT", self.sysroot(compiler))
419419
.env("RUSTC_LIBDIR", self.sysroot_libdir(compiler, self.build.build))
420420
.env("CFG_RELEASE_CHANNEL", &self.build.config.channel)
421-
.env("RUSTDOC_REAL", self.rustdoc(host));
421+
.env("RUSTDOC_REAL", self.rustdoc(host))
422+
.env("RUSTDOC_CRATE_VERSION", self.build.rust_version());
422423
cmd
423424
}
424425

@@ -574,6 +575,9 @@ impl<'a> Builder<'a> {
574575
cargo.env("RUSTC_SAVE_ANALYSIS", "api".to_string());
575576
}
576577

578+
// For `cargo doc` invocations, make rustdoc print the Rust version into the docs
579+
cargo.env("RUSTDOC_CRATE_VERSION", self.build.rust_version());
580+
577581
// Environment variables *required* throughout the build
578582
//
579583
// FIXME: should update code to not require this env var

0 commit comments

Comments
 (0)