Skip to content

Commit cbf9d57

Browse files
authored
Rollup merge of #126572 - onur-ozkan:channel-problem, r=clubby789
override user defined channel when using precompiled rustc We need to override `rust.channel` if it's manually specified when using the CI rustc. This is because if the compiler uses a different channel than the one specified in config.toml, tests may fail due to using a different channel than the one used by the compiler during tests. For more context, see #122709 (comment).
2 parents 035285b + 5ae2446 commit cbf9d57

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

src/bootstrap/src/core/builder.rs

+6-17
Original file line numberDiff line numberDiff line change
@@ -1031,23 +1031,12 @@ impl<'a> Builder<'a> {
10311031
}
10321032

10331033
pub fn doc_rust_lang_org_channel(&self) -> String {
1034-
// When using precompiled compiler from CI, we need to use CI rustc's channel and
1035-
// ignore `rust.channel` from the configuration. Otherwise most of the rustdoc tests
1036-
// will fail due to incompatible `DOC_RUST_LANG_ORG_CHANNEL`.
1037-
let channel = if let Some(commit) = self.config.download_rustc_commit() {
1038-
self.config
1039-
.read_file_by_commit(&PathBuf::from("src/ci/channel"), commit)
1040-
.trim()
1041-
.to_owned()
1042-
} else {
1043-
match &*self.config.channel {
1044-
"stable" => &self.version,
1045-
"beta" => "beta",
1046-
"nightly" | "dev" => "nightly",
1047-
// custom build of rustdoc maybe? link to the latest stable docs just in case
1048-
_ => "stable",
1049-
}
1050-
.to_owned()
1034+
let channel = match &*self.config.channel {
1035+
"stable" => &self.version,
1036+
"beta" => "beta",
1037+
"nightly" | "dev" => "nightly",
1038+
// custom build of rustdoc maybe? link to the latest stable docs just in case
1039+
_ => "stable",
10511040
};
10521041

10531042
format!("https://doc.rust-lang.org/{channel}")

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

+17-1
Original file line numberDiff line numberDiff line change
@@ -1718,7 +1718,23 @@ impl Config {
17181718
config.omit_git_hash = omit_git_hash.unwrap_or(default);
17191719
config.rust_info = GitInfo::new(config.omit_git_hash, &config.src);
17201720

1721-
if config.rust_info.is_from_tarball() && !is_user_configured_rust_channel {
1721+
// We need to override `rust.channel` if it's manually specified when using the CI rustc.
1722+
// This is because if the compiler uses a different channel than the one specified in config.toml,
1723+
// tests may fail due to using a different channel than the one used by the compiler during tests.
1724+
if let Some(commit) = &config.download_rustc_commit {
1725+
if is_user_configured_rust_channel {
1726+
println!(
1727+
"WARNING: `rust.download-rustc` is enabled. The `rust.channel` option will be overridden by the CI rustc's channel."
1728+
);
1729+
1730+
let channel = config
1731+
.read_file_by_commit(&PathBuf::from("src/ci/channel"), commit)
1732+
.trim()
1733+
.to_owned();
1734+
1735+
config.channel = channel;
1736+
}
1737+
} else if config.rust_info.is_from_tarball() && !is_user_configured_rust_channel {
17221738
ci_channel.clone_into(&mut config.channel);
17231739
}
17241740

0 commit comments

Comments
 (0)