@@ -1375,6 +1375,25 @@ impl Config {
13751375 let mut omit_git_hash = None;
13761376
13771377 if let Some(rust) = toml.rust {
1378+ set(&mut config.channel, rust.channel);
1379+
1380+ config.download_rustc_commit = config.download_ci_rustc_commit(rust.download_rustc);
1381+ // This list is incomplete, please help by expanding it!
1382+ if config.download_rustc_commit.is_some() {
1383+ // We need the channel used by the downloaded compiler to match the one we set for rustdoc;
1384+ // otherwise rustdoc-ui tests break.
1385+ let ci_channel = t!(fs::read_to_string(config.src.join("src/ci/channel")));
1386+ let ci_channel = ci_channel.trim_end();
1387+ if config.channel != ci_channel
1388+ && !(config.channel == "dev" && ci_channel == "nightly")
1389+ {
1390+ panic!(
1391+ "setting rust.channel={} is incompatible with download-rustc",
1392+ config.channel
1393+ );
1394+ }
1395+ }
1396+
13781397 debug = rust.debug;
13791398 debug_assertions = rust.debug_assertions;
13801399 debug_assertions_std = rust.debug_assertions_std;
@@ -1386,6 +1405,7 @@ impl Config {
13861405 debuginfo_level_std = rust.debuginfo_level_std;
13871406 debuginfo_level_tools = rust.debuginfo_level_tools;
13881407 debuginfo_level_tests = rust.debuginfo_level_tests;
1408+
13891409 config.rust_split_debuginfo = rust
13901410 .split_debuginfo
13911411 .as_deref()
@@ -1401,7 +1421,6 @@ impl Config {
14011421 set(&mut config.jemalloc, rust.jemalloc);
14021422 set(&mut config.test_compare_mode, rust.test_compare_mode);
14031423 set(&mut config.backtrace, rust.backtrace);
1404- set(&mut config.channel, rust.channel);
14051424 config.description = rust.description;
14061425 set(&mut config.rust_dist_src, rust.dist_src);
14071426 set(&mut config.verbose_tests, rust.verbose_tests);
@@ -1442,8 +1461,6 @@ impl Config {
14421461 config.rust_codegen_units_std = rust.codegen_units_std.map(threads_from_config);
14431462 config.rust_profile_use = flags.rust_profile_use.or(rust.profile_use);
14441463 config.rust_profile_generate = flags.rust_profile_generate.or(rust.profile_generate);
1445- config.download_rustc_commit = config.download_ci_rustc_commit(rust.download_rustc);
1446-
14471464 config.rust_lto = rust
14481465 .lto
14491466 .as_deref()
@@ -1555,6 +1572,11 @@ impl Config {
15551572 let mut target = Target::from_triple(&triple);
15561573
15571574 if let Some(ref s) = cfg.llvm_config {
1575+ if config.download_rustc_commit.is_some() && triple == &*config.build.triple {
1576+ panic!(
1577+ "setting llvm_config for the host is incompatible with download-rustc"
1578+ );
1579+ }
15581580 target.llvm_config = Some(config.src.join(s));
15591581 }
15601582 target.llvm_has_rust_patches = cfg.llvm_has_rust_patches;
@@ -1825,6 +1847,12 @@ impl Config {
18251847 self.out.join(&*self.build.triple).join("ci-llvm")
18261848 }
18271849
1850+ /// Directory where the extracted `rustc-dev` component is stored.
1851+ pub(crate) fn ci_rustc_dir(&self) -> PathBuf {
1852+ assert!(self.download_rustc());
1853+ self.out.join(self.build.triple).join("ci-rustc")
1854+ }
1855+
18281856 /// Determine whether llvm should be linked dynamically.
18291857 ///
18301858 /// If `false`, llvm should be linked statically.
@@ -1860,11 +1888,11 @@ impl Config {
18601888 self.download_rustc_commit().is_some()
18611889 }
18621890
1863- pub(crate) fn download_rustc_commit(&self) -> Option<&'static str> {
1891+ pub(crate) fn download_rustc_commit(&self) -> Option<&str> {
18641892 static DOWNLOAD_RUSTC: OnceCell<Option<String>> = OnceCell::new();
18651893 if self.dry_run() && DOWNLOAD_RUSTC.get().is_none() {
18661894 // avoid trying to actually download the commit
1867- return None ;
1895+ return self.download_rustc_commit.as_deref() ;
18681896 }
18691897
18701898 DOWNLOAD_RUSTC
0 commit comments