Skip to content

Commit 8bf985b

Browse files
committed
Replace bare tuple with a StepToRun struct
1 parent e8ea0cd commit 8bf985b

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/bootstrap/src/core/builder/cli_paths.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use std::fmt::{self, Debug};
66
use std::path::PathBuf;
77

8-
use crate::core::builder::{Builder, Kind, ShouldRun, StepDescription};
8+
use crate::core::builder::{Builder, Kind, PathSet, ShouldRun, StepDescription};
99

1010
pub(crate) const PATH_REMAP: &[(&str, &[&str])] = &[
1111
// bootstrap.toml uses `rust-analyzer-proc-macro-srv`, but the
@@ -95,6 +95,12 @@ struct StepExtra<'a> {
9595
should_run: ShouldRun<'a>,
9696
}
9797

98+
struct StepToRun<'a> {
99+
sort_index: usize,
100+
desc: &'a StepDescription,
101+
pathsets: Vec<PathSet>,
102+
}
103+
98104
pub(crate) fn match_paths_to_steps_and_run(
99105
builder: &Builder<'_>,
100106
step_descs: &[StepDescription],
@@ -185,9 +191,8 @@ pub(crate) fn match_paths_to_steps_and_run(
185191
let mut path_lookup: Vec<(CLIStepPath, bool)> =
186192
paths.clone().into_iter().map(|p| (p, false)).collect();
187193

188-
// List of `(usize, &StepDescription, Vec<PathSet>)` where `usize` is the closest index of a path
189-
// compared to the given CLI paths. So we can respect to the CLI order by using this value to sort
190-
// the steps.
194+
// Before actually running (non-suite) steps, collect them into a list of structs
195+
// so that we can then sort the list to preserve CLI order as much as possible.
191196
let mut steps_to_run = vec![];
192197

193198
for StepExtra { desc, should_run } in &steps {
@@ -209,14 +214,14 @@ pub(crate) fn match_paths_to_steps_and_run(
209214
}
210215
}
211216

212-
steps_to_run.push((closest_index, desc, pathsets));
217+
steps_to_run.push(StepToRun { sort_index: closest_index, desc, pathsets });
213218
}
214219

215220
// Sort the steps before running them to respect the CLI order.
216-
steps_to_run.sort_by_key(|(index, _, _)| *index);
221+
steps_to_run.sort_by_key(|step| step.sort_index);
217222

218223
// Handle all PathSets.
219-
for (_index, desc, pathsets) in steps_to_run {
224+
for StepToRun { sort_index: _, desc, pathsets } in steps_to_run {
220225
if !pathsets.is_empty() {
221226
desc.maybe_run(builder, pathsets);
222227
}

0 commit comments

Comments
 (0)