Skip to content

Commit ac49cda

Browse files
committed
rename PathSet -> StepSelectors
1 parent 3dc03a2 commit ac49cda

5 files changed

Lines changed: 41 additions & 40 deletions

File tree

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use crate::utils::helpers::{
4141
linker_args, linker_flags, t, target_supports_cranelift_backend, up_to_date,
4242
};
4343
use crate::utils::render_tests::{add_flags_and_try_run_tests, try_run_tests};
44-
use crate::{CLang, CodegenBackendKind, DocTests, GitRepo, Mode, PathSet, envify};
44+
use crate::{CLang, CodegenBackendKind, DocTests, GitRepo, Mode, StepSelectors, envify};
4545

4646
mod compiletest;
4747

@@ -1697,15 +1697,15 @@ impl Step for Coverage {
16971697
// determine which modes to run in.
16981698
for path in &run.paths {
16991699
match path {
1700-
PathSet::Set(_) => {
1700+
StepSelectors::Set(_) => {
17011701
for &mode in Self::ALL_MODES {
17021702
if path.assert_single_path().path == Path::new(mode.as_str()) {
17031703
modes.push(mode);
17041704
break;
17051705
}
17061706
}
17071707
}
1708-
PathSet::TestSuite(_) => {
1708+
StepSelectors::TestSuite(_) => {
17091709
modes.extend_from_slice(Self::ALL_MODES);
17101710
break;
17111711
}

src/bootstrap/src/core/builder/mod.rs

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ pub struct Builder<'a> {
7171
/// executed to be logged instead. Used by snapshot tests of command-line
7272
/// paths-to-steps handling.
7373
#[expect(clippy::type_complexity)]
74-
log_cli_step_for_tests: Option<Box<dyn Fn(&StepDescription, &[PathSet], &[TargetSelection])>>,
74+
log_cli_step_for_tests:
75+
Option<Box<dyn Fn(&StepDescription, &[StepSelectors], &[TargetSelection])>>,
7576
}
7677

7778
impl Deref for Builder<'_> {
@@ -242,7 +243,7 @@ impl StepMetadata {
242243
pub struct RunConfig<'a> {
243244
pub builder: &'a Builder<'a>,
244245
pub target: TargetSelection,
245-
pub paths: Vec<PathSet>,
246+
pub paths: Vec<StepSelectors>,
246247
}
247248

248249
impl RunConfig<'_> {
@@ -349,7 +350,7 @@ impl Debug for StepSelection {
349350

350351
/// Collection of paths used to match a task rule.
351352
#[derive(Debug, Clone, PartialOrd, Ord, PartialEq, Eq)]
352-
pub enum PathSet {
353+
pub enum StepSelectors {
353354
/// A collection of individual paths or aliases.
354355
///
355356
/// These are generally matched as a path suffix. For example, a
@@ -370,21 +371,21 @@ pub enum PathSet {
370371
TestSuite(StepSelection),
371372
}
372373

373-
impl PathSet {
374-
fn empty() -> PathSet {
375-
PathSet::Set(BTreeSet::new())
374+
impl StepSelectors {
375+
fn empty() -> StepSelectors {
376+
StepSelectors::Set(BTreeSet::new())
376377
}
377378

378-
fn one<P: Into<PathBuf>>(path: P, kind: Kind) -> PathSet {
379+
fn one<P: Into<PathBuf>>(path: P, kind: Kind) -> StepSelectors {
379380
let mut set = BTreeSet::new();
380381
set.insert(StepSelection { path: path.into(), kind: Some(kind) });
381-
PathSet::Set(set)
382+
StepSelectors::Set(set)
382383
}
383384

384385
fn has(&self, needle: &Path, module: Kind) -> bool {
385386
match self {
386-
PathSet::Set(set) => set.iter().any(|p| Self::check(p, needle, module)),
387-
PathSet::TestSuite(suite) => Self::check(suite, needle, module),
387+
StepSelectors::Set(set) => set.iter().any(|p| Self::check(p, needle, module)),
388+
StepSelectors::TestSuite(suite) => Self::check(suite, needle, module),
388389
}
389390
}
390391

@@ -403,7 +404,7 @@ impl PathSet {
403404
/// This is used for `StepDescription::krate`, which passes all matching crates at once to
404405
/// `Step::make_run`, rather than calling it many times with a single crate.
405406
/// See `tests.rs` for examples.
406-
fn intersection_removing_matches(&self, needles: &mut [CLIStepPath], module: Kind) -> PathSet {
407+
fn intersection_removing_matches(&self, needles: &mut [CLIStepPath], module: Kind) -> StepSelectors {
407408
let mut check = |p| {
408409
let mut result = false;
409410
for n in needles.iter_mut() {
@@ -416,12 +417,12 @@ impl PathSet {
416417
result
417418
};
418419
match self {
419-
PathSet::Set(set) => PathSet::Set(set.iter().filter(|&p| check(p)).cloned().collect()),
420-
PathSet::TestSuite(suite) => {
420+
StepSelectors::Set(set) => StepSelectors::Set(set.iter().filter(|&p| check(p)).cloned().collect()),
421+
StepSelectors::TestSuite(suite) => {
421422
if check(suite) {
422423
self.clone()
423424
} else {
424-
PathSet::empty()
425+
StepSelectors::empty()
425426
}
426427
}
427428
}
@@ -433,11 +434,11 @@ impl PathSet {
433434
#[track_caller]
434435
pub fn assert_single_path(&self) -> &StepSelection {
435436
match self {
436-
PathSet::Set(set) => {
437+
StepSelectors::Set(set) => {
437438
assert_eq!(set.len(), 1, "called assert_single_path on multiple paths");
438439
set.iter().next().unwrap()
439440
}
440-
PathSet::TestSuite(_) => unreachable!("called assert_single_path on a Suite path"),
441+
StepSelectors::TestSuite(_) => unreachable!("called assert_single_path on a Suite path"),
441442
}
442443
}
443444
}
@@ -454,7 +455,7 @@ impl StepDescription {
454455
}
455456
}
456457

457-
fn maybe_run(&self, builder: &Builder<'_>, mut pathsets: Vec<PathSet>) {
458+
fn maybe_run(&self, builder: &Builder<'_>, mut pathsets: Vec<StepSelectors>) {
458459
pathsets.retain(|set| !self.is_excluded(builder, set));
459460

460461
if pathsets.is_empty() {
@@ -477,7 +478,7 @@ impl StepDescription {
477478
}
478479
}
479480

480-
fn is_excluded(&self, builder: &Builder<'_>, pathset: &PathSet) -> bool {
481+
fn is_excluded(&self, builder: &Builder<'_>, pathset: &StepSelectors) -> bool {
481482
if builder.config.skip.iter().any(|e| pathset.has(e, builder.kind)) {
482483
if !matches!(builder.config.get_dry_run(), DryRun::SelfCheck) {
483484
println!("Skipping {pathset:?} because it is excluded");
@@ -510,7 +511,7 @@ pub struct ShouldRun<'a> {
510511
kind: Kind,
511512

512513
// use a BTreeSet to maintain sort order
513-
paths: BTreeSet<PathSet>,
514+
paths: BTreeSet<StepSelectors>,
514515
}
515516

516517
impl<'a> ShouldRun<'a> {
@@ -535,7 +536,7 @@ impl<'a> ShouldRun<'a> {
535536
pub(crate) fn crates(mut self, crates: Vec<&Crate>) -> Self {
536537
for krate in crates {
537538
let path = krate.local_path(self.builder);
538-
self.paths.insert(PathSet::one(path, self.kind));
539+
self.paths.insert(StepSelectors::one(path, self.kind));
539540
}
540541
self
541542
}
@@ -549,7 +550,7 @@ impl<'a> ShouldRun<'a> {
549550
self.kind == Kind::Setup || !self.builder.src.join(alias).exists(),
550551
"use `builder.path()` for real paths: {alias}"
551552
);
552-
self.paths.insert(PathSet::Set(
553+
self.paths.insert(StepSelectors::Set(
553554
std::iter::once(StepSelection { path: alias.into(), kind: Some(self.kind) }).collect(),
554555
));
555556
self
@@ -574,7 +575,7 @@ impl<'a> ShouldRun<'a> {
574575
pub fn paths(mut self, paths: &[&str]) -> Self {
575576
let submodules_paths = self.builder.submodule_paths();
576577

577-
self.paths.insert(PathSet::Set(
578+
self.paths.insert(StepSelectors::Set(
578579
paths
579580
.iter()
580581
.map(|p| {
@@ -594,21 +595,21 @@ impl<'a> ShouldRun<'a> {
594595
}
595596

596597
/// Handles individual files (not directories) within a test suite.
597-
fn is_suite_path(&self, requested_path: &Path) -> Option<&PathSet> {
598+
fn is_suite_path(&self, requested_path: &Path) -> Option<&StepSelectors> {
598599
self.paths.iter().find(|pathset| match pathset {
599-
PathSet::TestSuite(suite) => requested_path.starts_with(&suite.path),
600-
PathSet::Set(_) => false,
600+
StepSelectors::TestSuite(suite) => requested_path.starts_with(&suite.path),
601+
StepSelectors::Set(_) => false,
601602
})
602603
}
603604

604605
pub fn suite_path(mut self, suite: &str) -> Self {
605-
self.paths.insert(PathSet::TestSuite(StepSelection { path: suite.into(), kind: Some(self.kind) }));
606+
self.paths.insert(StepSelectors::TestSuite(StepSelection { path: suite.into(), kind: Some(self.kind) }));
606607
self
607608
}
608609

609610
// allows being more explicit about why should_run in Step returns the value passed to it
610611
pub fn never(mut self) -> ShouldRun<'a> {
611-
self.paths.insert(PathSet::empty());
612+
self.paths.insert(StepSelectors::empty());
612613
self
613614
}
614615

@@ -625,11 +626,11 @@ impl<'a> ShouldRun<'a> {
625626
&self,
626627
paths: &mut [CLIStepPath],
627628
kind: Kind,
628-
) -> Vec<PathSet> {
629+
) -> Vec<StepSelectors> {
629630
let mut sets = vec![];
630631
for pathset in &self.paths {
631632
let subset = pathset.intersection_removing_matches(paths, kind);
632-
if subset != PathSet::empty() {
633+
if subset != StepSelectors::empty() {
633634
sets.push(subset);
634635
}
635636
}
@@ -1062,12 +1063,12 @@ impl<'a> Builder<'a> {
10621063
};
10631064
for pathset in should_run.paths {
10641065
match pathset {
1065-
PathSet::Set(set) => {
1066+
StepSelectors::Set(set) => {
10661067
for path in set {
10671068
add_path(&path.path);
10681069
}
10691070
}
1070-
PathSet::TestSuite(path) => {
1071+
StepSelectors::TestSuite(path) => {
10711072
add_path(&path.path.join("..."));
10721073
}
10731074
}
@@ -1653,7 +1654,7 @@ Alternatively, you can set `build.local-rebuild=true` and use a stage0 compiler
16531654
if should_run.paths.iter().any(|s| s.has(path, desc.kind))
16541655
&& !desc.is_excluded(
16551656
self,
1656-
&PathSet::TestSuite(StepSelection { path: path.clone(), kind: Some(desc.kind) }),
1657+
&StepSelectors::TestSuite(StepSelection { path: path.clone(), kind: Some(desc.kind) }),
16571658
)
16581659
{
16591660
return true;

src/bootstrap/src/core/builder/selectors.rs

Lines changed: 2 additions & 2 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, PathSet, ShouldRun, StepDescription};
8+
use crate::core::builder::{Builder, Kind, StepSelectors, ShouldRun, StepDescription};
99

1010
#[cfg(test)]
1111
mod tests;
@@ -99,7 +99,7 @@ struct StepExtra<'a> {
9999
struct StepToRun<'a> {
100100
sort_index: usize,
101101
desc: &'a StepDescription,
102-
pathsets: Vec<PathSet>,
102+
pathsets: Vec<StepSelectors>,
103103
}
104104

105105
pub(crate) fn match_paths_to_steps_and_run(

src/bootstrap/src/core/builder/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ fn test_invalid() {
8383
#[test]
8484
fn test_intersection() {
8585
let set = |paths: &[&str]| {
86-
PathSet::Set(paths.into_iter().map(|p| TaskPath { path: p.into(), kind: None }).collect())
86+
StepSelectors::Set(paths.into_iter().map(|p| StepSelection { selector: p.into(), kind: None }).collect())
8787
};
8888
let library_set = set(&["library/core", "library/alloc", "library/std"]);
8989
let mut command_paths = vec![
@@ -106,7 +106,7 @@ fn test_intersection() {
106106
#[test]
107107
fn test_resolve_parent_and_subpaths() {
108108
let set = |paths: &[&str]| {
109-
PathSet::Set(paths.into_iter().map(|p| TaskPath { path: p.into(), kind: None }).collect())
109+
StepSelectors::Set(paths.into_iter().map(|p| StepSelection { selector: p.into(), kind: None }).collect())
110110
};
111111

112112
let mut command_paths = vec![

src/bootstrap/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ use crate::utils::helpers::{self, dir_is_empty, exe, libdir, set_file_times, spl
4242
mod core;
4343
mod utils;
4444

45-
pub use core::builder::PathSet;
4645
#[cfg(feature = "tracing")]
4746
pub use core::builder::STEP_SPAN_TARGET;
47+
pub use core::builder::StepSelectors;
4848
pub use core::config::flags::{Flags, Subcommand};
4949
pub use core::config::{ChangeId, Config};
5050

0 commit comments

Comments
 (0)