about summary refs log tree commit diff
diff options
context:
space:
mode:
authorjyn <github@jyn.dev>2023-05-25 13:37:24 -0500
committerjyn <github@jyn.dev>2023-05-29 13:26:44 -0500
commit20372f1817e9498f00100c149b4f47fc8ba00329 (patch)
treee477c8bb11c2b919c45d1879375d79620f1b5fce
parent564e3adfdfdd761a8fa94e5e33abd04ae5f14675 (diff)
downloadrust-20372f1817e9498f00100c149b4f47fc8ba00329.tar.gz
rust-20372f1817e9498f00100c149b4f47fc8ba00329.zip
Add a `make_run_crates` function and use it Rustc and Std
This fixes the panic from the previous commit.
-rw-r--r--src/bootstrap/check.rs8
-rw-r--r--src/bootstrap/compile.rs19
2 files changed, 17 insertions, 10 deletions
diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs
index a4fcaa5e196..09835516f7b 100644
--- a/src/bootstrap/check.rs
+++ b/src/bootstrap/check.rs
@@ -2,7 +2,9 @@
 
 use crate::builder::{crate_description, Builder, Kind, RunConfig, ShouldRun, Step};
 use crate::cache::Interned;
-use crate::compile::{add_to_sysroot, run_cargo, rustc_cargo, rustc_cargo_env, std_cargo};
+use crate::compile::{
+    add_to_sysroot, make_run_crates, run_cargo, rustc_cargo, rustc_cargo_env, std_cargo,
+};
 use crate::config::TargetSelection;
 use crate::tool::{prepare_tool_cargo, SourceType};
 use crate::INTERNER;
@@ -88,7 +90,7 @@ impl Step for Std {
     }
 
     fn make_run(run: RunConfig<'_>) {
-        let crates = run.cargo_crates_in_set();
+        let crates = make_run_crates(&run, "library");
         run.builder.ensure(Std { target: run.target, crates });
     }
 
@@ -218,7 +220,7 @@ impl Step for Rustc {
     }
 
     fn make_run(run: RunConfig<'_>) {
-        let crates = run.cargo_crates_in_set();
+        let crates = make_run_crates(&run, "compiler");
         run.builder.ensure(Rustc { target: run.target, crates });
     }
 
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
index 33addb90da3..7b9c4c0f3b3 100644
--- a/src/bootstrap/compile.rs
+++ b/src/bootstrap/compile.rs
@@ -48,6 +48,17 @@ impl Std {
     }
 }
 
+/// Given an `alias` selected by the `Step` and the paths passed on the command line,
+/// return a list of the crates that should be built.
+///
+/// Normally, people will pass *just* `library` if they pass it.
+/// But it's possible (although strange) to pass something like `library std core`.
+/// Build all crates anyway, as if they hadn't passed the other args.
+pub(crate) fn make_run_crates(run: &RunConfig<'_>, alias: &str) -> Interned<Vec<String>> {
+    let has_alias = run.paths.iter().any(|set| set.assert_single_path().path.ends_with(alias));
+    if has_alias { Default::default() } else { run.cargo_crates_in_set() }
+}
+
 impl Step for Std {
     type Output = ();
     const DEFAULT: bool = true;
@@ -62,16 +73,10 @@ impl Step for Std {
     }
 
     fn make_run(run: RunConfig<'_>) {
-        // Normally, people will pass *just* library if they pass it.
-        // But it's possible (although strange) to pass something like `library std core`.
-        // Build all crates anyway, as if they hadn't passed the other args.
-        let has_library =
-            run.paths.iter().any(|set| set.assert_single_path().path.ends_with("library"));
-        let crates = if has_library { Default::default() } else { run.cargo_crates_in_set() };
         run.builder.ensure(Std {
             compiler: run.builder.compiler(run.builder.top_stage, run.build_triple()),
             target: run.target,
-            crates,
+            crates: make_run_crates(&run, "library"),
         });
     }