Skip to content

Commit 20372f1

Browse files
committed
Add a make_run_crates function and use it Rustc and Std
This fixes the panic from the previous commit.
1 parent 564e3ad commit 20372f1

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

src/bootstrap/check.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
33
use crate::builder::{crate_description, Builder, Kind, RunConfig, ShouldRun, Step};
44
use crate::cache::Interned;
5-
use crate::compile::{add_to_sysroot, run_cargo, rustc_cargo, rustc_cargo_env, std_cargo};
5+
use crate::compile::{
6+
add_to_sysroot, make_run_crates, run_cargo, rustc_cargo, rustc_cargo_env, std_cargo,
7+
};
68
use crate::config::TargetSelection;
79
use crate::tool::{prepare_tool_cargo, SourceType};
810
use crate::INTERNER;
@@ -88,7 +90,7 @@ impl Step for Std {
8890
}
8991

9092
fn make_run(run: RunConfig<'_>) {
91-
let crates = run.cargo_crates_in_set();
93+
let crates = make_run_crates(&run, "library");
9294
run.builder.ensure(Std { target: run.target, crates });
9395
}
9496

@@ -218,7 +220,7 @@ impl Step for Rustc {
218220
}
219221

220222
fn make_run(run: RunConfig<'_>) {
221-
let crates = run.cargo_crates_in_set();
223+
let crates = make_run_crates(&run, "compiler");
222224
run.builder.ensure(Rustc { target: run.target, crates });
223225
}
224226

src/bootstrap/compile.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ impl Std {
4848
}
4949
}
5050

51+
/// Given an `alias` selected by the `Step` and the paths passed on the command line,
52+
/// return a list of the crates that should be built.
53+
///
54+
/// Normally, people will pass *just* `library` if they pass it.
55+
/// But it's possible (although strange) to pass something like `library std core`.
56+
/// Build all crates anyway, as if they hadn't passed the other args.
57+
pub(crate) fn make_run_crates(run: &RunConfig<'_>, alias: &str) -> Interned<Vec<String>> {
58+
let has_alias = run.paths.iter().any(|set| set.assert_single_path().path.ends_with(alias));
59+
if has_alias { Default::default() } else { run.cargo_crates_in_set() }
60+
}
61+
5162
impl Step for Std {
5263
type Output = ();
5364
const DEFAULT: bool = true;
@@ -62,16 +73,10 @@ impl Step for Std {
6273
}
6374

6475
fn make_run(run: RunConfig<'_>) {
65-
// Normally, people will pass *just* library if they pass it.
66-
// But it's possible (although strange) to pass something like `library std core`.
67-
// Build all crates anyway, as if they hadn't passed the other args.
68-
let has_library =
69-
run.paths.iter().any(|set| set.assert_single_path().path.ends_with("library"));
70-
let crates = if has_library { Default::default() } else { run.cargo_crates_in_set() };
7176
run.builder.ensure(Std {
7277
compiler: run.builder.compiler(run.builder.top_stage, run.build_triple()),
7378
target: run.target,
74-
crates,
79+
crates: make_run_crates(&run, "library"),
7580
});
7681
}
7782

0 commit comments

Comments
 (0)