Skip to content

Commit d2fb97f

Browse files
committed
Auto merge of rust-lang#126153 - onur-ozkan:fix-rustdoc-issue-with-ci-rustc, r=Mark-Simulacrum
resolve rustdoc incompatibility with `rust.download-rustc=true` + `rust.channel= beta/stable` Previously, we were unable to use `rust.download-rustc` with the beta or stable channel settings through `rust.channel` due to breaking rustdoc UI tests. This was because when using a precompiled nightly compiler from CI, we must use the channel of precompiled compiler and ignore `rust.channel` from the configuration. This change addresses that issue in `Builder::doc_rust_lang_org_channel` and allows rustdoc UI tests to work with the precompiled compiler even if the channel specified in config.toml is "beta" or "stable". Blocker for rust-lang#122709
2 parents 6d94a87 + 99c5476 commit d2fb97f

File tree

2 files changed

+40
-27
lines changed

2 files changed

+40
-27
lines changed

Diff for: src/bootstrap/src/core/builder.rs

+19-7
Original file line numberDiff line numberDiff line change
@@ -1036,14 +1036,26 @@ impl<'a> Builder<'a> {
10361036
}
10371037

10381038
pub fn doc_rust_lang_org_channel(&self) -> String {
1039-
let channel = match &*self.config.channel {
1040-
"stable" => &self.version,
1041-
"beta" => "beta",
1042-
"nightly" | "dev" => "nightly",
1043-
// custom build of rustdoc maybe? link to the latest stable docs just in case
1044-
_ => "stable",
1039+
// When using precompiled compiler from CI, we need to use CI rustc's channel and
1040+
// ignore `rust.channel` from the configuration. Otherwise most of the rustdoc tests
1041+
// will fail due to incompatible `DOC_RUST_LANG_ORG_CHANNEL`.
1042+
let channel = if let Some(commit) = self.config.download_rustc_commit() {
1043+
self.config
1044+
.read_file_by_commit(&PathBuf::from("src/ci/channel"), commit)
1045+
.trim()
1046+
.to_owned()
1047+
} else {
1048+
match &*self.config.channel {
1049+
"stable" => &self.version,
1050+
"beta" => "beta",
1051+
"nightly" | "dev" => "nightly",
1052+
// custom build of rustdoc maybe? link to the latest stable docs just in case
1053+
_ => "stable",
1054+
}
1055+
.to_owned()
10451056
};
1046-
"https://doc.rust-lang.org/".to_owned() + channel
1057+
1058+
format!("https://doc.rust-lang.org/{channel}")
10471059
}
10481060

10491061
fn run_step_descriptions(&self, v: &[StepDescription], paths: &[PathBuf]) {

Diff for: src/bootstrap/src/core/config/config.rs

+21-20
Original file line numberDiff line numberDiff line change
@@ -1608,19 +1608,8 @@ impl Config {
16081608
set(&mut config.channel, channel);
16091609

16101610
config.download_rustc_commit = config.download_ci_rustc_commit(download_rustc);
1611-
// This list is incomplete, please help by expanding it!
1612-
if config.download_rustc_commit.is_some() {
1613-
// We need the channel used by the downloaded compiler to match the one we set for rustdoc;
1614-
// otherwise rustdoc-ui tests break.
1615-
if config.channel != ci_channel
1616-
&& !(config.channel == "dev" && ci_channel == "nightly")
1617-
{
1618-
panic!(
1619-
"setting rust.channel={} is incompatible with download-rustc",
1620-
config.channel
1621-
);
1622-
}
1623-
}
1611+
1612+
// FIXME: handle download-rustc incompatible options.
16241613

16251614
debug = debug_toml;
16261615
debug_assertions = debug_assertions_toml;
@@ -2134,17 +2123,29 @@ impl Config {
21342123
args
21352124
}
21362125

2126+
/// Returns the content of the given file at a specific commit.
2127+
pub(crate) fn read_file_by_commit(&self, file: &Path, commit: &str) -> String {
2128+
assert!(
2129+
self.rust_info.is_managed_git_subrepository(),
2130+
"`Config::read_file_by_commit` is not supported in non-git sources."
2131+
);
2132+
2133+
let mut git = self.git();
2134+
git.arg("show").arg(format!("{commit}:{}", file.to_str().unwrap()));
2135+
output(&mut git)
2136+
}
2137+
21372138
/// Bootstrap embeds a version number into the name of shared libraries it uploads in CI.
21382139
/// Return the version it would have used for the given commit.
21392140
pub(crate) fn artifact_version_part(&self, commit: &str) -> String {
21402141
let (channel, version) = if self.rust_info.is_managed_git_subrepository() {
2141-
let mut channel = self.git();
2142-
channel.arg("show").arg(format!("{commit}:src/ci/channel"));
2143-
let channel = output(&mut channel);
2144-
let mut version = self.git();
2145-
version.arg("show").arg(format!("{commit}:src/version"));
2146-
let version = output(&mut version);
2147-
(channel.trim().to_owned(), version.trim().to_owned())
2142+
let channel = self
2143+
.read_file_by_commit(&PathBuf::from("src/ci/channel"), commit)
2144+
.trim()
2145+
.to_owned();
2146+
let version =
2147+
self.read_file_by_commit(&PathBuf::from("src/version"), commit).trim().to_owned();
2148+
(channel, version)
21482149
} else {
21492150
let channel = fs::read_to_string(self.src.join("src/ci/channel"));
21502151
let version = fs::read_to_string(self.src.join("src/version"));

0 commit comments

Comments
 (0)