Skip to content

Commit 187fe5b

Browse files
authored
Rollup merge of rust-lang#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 rust-lang#122709 (comment).
2 parents 5ec5dda + 5ae2446 commit 187fe5b

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
@@ -1036,23 +1036,12 @@ impl<'a> Builder<'a> {
10361036
}
10371037

10381038
pub fn doc_rust_lang_org_channel(&self) -> String {
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()
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",
10561045
};
10571046

10581047
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)