Skip to content

Commit a7b9a1c

Browse files
committed
get nightly version from env var to pin exact version
1 parent 64ad701 commit a7b9a1c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

contrib/tools/config-docs-generator/src/extract_docs.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,18 @@ fn generate_rustdoc_json(package: &str) -> Result<serde_json::Value> {
156156

157157
// WARNING: This tool relies on nightly rustdoc JSON output (-Z unstable-options --output-format json)
158158
// The JSON format is subject to change with new Rust nightly versions and could break this tool.
159-
// Use cargo rustdoc with nightly to generate JSON for the main package
159+
// Determine the toolchain to use for rustdoc. Allow callers to override the
160+
// default "+nightly" prefix via the `RUST_NIGHTLY_VERSION` environment variable
161+
// so CI can pin a specific nightly (e.g. "+nightly-2025-06-17").
162+
let toolchain_arg =
163+
std::env::var("RUST_NIGHTLY_VERSION").unwrap_or_else(|_| "nightly".to_string());
164+
165+
let toolchain_arg = format!("+{}", toolchain_arg);
166+
167+
// Use cargo rustdoc with the selected toolchain to generate JSON for the main package
160168
let output = StdCommand::new("cargo")
161169
.args([
162-
"+nightly",
170+
toolchain_arg.as_str(),
163171
"rustdoc",
164172
"--lib",
165173
"-p",
@@ -189,7 +197,7 @@ fn generate_rustdoc_json(package: &str) -> Result<serde_json::Value> {
189197
);
190198
let output = StdCommand::new("cargo")
191199
.args([
192-
"+nightly",
200+
toolchain_arg.as_str(),
193201
"rustdoc",
194202
"--lib",
195203
"-p",

0 commit comments

Comments
 (0)