Skip to content

Commit e61d3b8

Browse files
committed
fix Builder::doc_rust_lang_org_channel
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". Signed-off-by: onur-ozkan <[email protected]>
1 parent 16e8803 commit e61d3b8

File tree

2 files changed

+38
-14
lines changed

2 files changed

+38
-14
lines changed

src/bootstrap/src/core/builder.rs

+19-7
Original file line numberDiff line numberDiff line change
@@ -1038,14 +1038,26 @@ impl<'a> Builder<'a> {
10381038
}
10391039

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

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

src/bootstrap/src/core/config/config.rs

+19-7
Original file line numberDiff line numberDiff line change
@@ -2134,17 +2134,29 @@ impl Config {
21342134
args
21352135
}
21362136

2137+
/// Returns the content of the given file at a specific commit.
2138+
pub(crate) fn read_file_by_commit(&self, file: &Path, commit: &str) -> String {
2139+
assert!(
2140+
self.rust_info.is_managed_git_subrepository(),
2141+
"`Config::read_file_by_commit` is not supported in non-git sources."
2142+
);
2143+
2144+
let mut git = self.git();
2145+
git.arg("show").arg(format!("{commit}:{}", file.to_str().unwrap()));
2146+
output(&mut git)
2147+
}
2148+
21372149
/// Bootstrap embeds a version number into the name of shared libraries it uploads in CI.
21382150
/// Return the version it would have used for the given commit.
21392151
pub(crate) fn artifact_version_part(&self, commit: &str) -> String {
21402152
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())
2153+
let channel = self
2154+
.read_file_by_commit(&PathBuf::from("src/ci/channel"), commit)
2155+
.trim()
2156+
.to_owned();
2157+
let version =
2158+
self.read_file_by_commit(&PathBuf::from("src/version"), commit).trim().to_owned();
2159+
(channel, version)
21482160
} else {
21492161
let channel = fs::read_to_string(self.src.join("src/ci/channel"));
21502162
let version = fs::read_to_string(self.src.join("src/version"));

0 commit comments

Comments
 (0)