Skip to content

bootstrap: Refactor and rename a bunch of path handling#151930

Open
jyn514 wants to merge 9 commits intorust-lang:mainfrom
jyn514:bootstrap-selectors
Open

bootstrap: Refactor and rename a bunch of path handling#151930
jyn514 wants to merge 9 commits intorust-lang:mainfrom
jyn514:bootstrap-selectors

Conversation

@jyn514
Copy link
Member

@jyn514 jyn514 commented Feb 1, 2026

This PR looks really scary BUT I promise that there's not actually many changes. Almost all of them are renames and the rest are just moving code around.

See https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Path.20filters.20in.20bootstrap/with/571240765 for background on why I'm making these changes, and https://hackmd.io/9J4UKJPBQOSwHr5WXQac0Q?edit for a sketch of what I think the long-term plan should be for path handling.

I highly highly recommend reviewing this commit by commit with --ignore-all-space --color-moved=dimmed-zebra --color-moved-ws=ignore-space-change.

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Feb 1, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 1, 2026

r? @Zalathar

rustbot has assigned @Zalathar.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@jyn514
Copy link
Member Author

jyn514 commented Feb 1, 2026

and FWIW I'm happy to split out changes, most of these I did with LSP assistance so they won't take me long to redo.

@rust-log-analyzer

This comment has been minimized.

@Zalathar
Copy link
Member

Zalathar commented Feb 1, 2026

I think some of these renames are straightforwardly good, and some will require a bit more explanation/haggling.

I'll try to find an uncontroversial subset that we can land easily, and then we can concentrate on what's left.

@Zalathar
Copy link
Member

Zalathar commented Feb 1, 2026

E.g. a thing I'm concerned about is that some of these new names are “aspirational” but not actually accurate to how things currently work, so they'd end up being misleading.

@Zalathar
Copy link
Member

Zalathar commented Feb 1, 2026

So far these are the parts I think are fairly straightforward:

  • Unnecessary uses of paths for codgen backends
  • cli_pathsselectors (but with updated module docs to explain that “selector” is our term for positional CLI args that tell bootstrap what parts to check/build/test etc.)
  • SuiteTestSuite (but not SetAlias)
  • rust-analyzer-proc-macro-srv (but with some snapshot tests, and an explanation of what the alias is for)

const IS_HOST: bool = true;

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.paths(&["src/librustdoc", "src/tools/rustdoc"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember being reluctant to change this in the past, because I wasn't entirely sure what special behaviour it enables, and whether that behaviour is important.

I would certainly like to get rid of paths, but I would like to either be cautious about it, or acknowledge that we're going to YOLO this change and that rustdoc folks will have to tell us if they notice problems.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, IIRC this case is the primary reason why PathSet::Set holds a BTreeSet<TaskPath> instead of just a singular path (selector?).

So if we do get rid of it, I would ideally want to get rid of the BTreeSet at the same time.

(An empty BTreeSet is also used to represent PathSet::empty, but we can probably use a separate enum variant for that case, and in the long run that variant will hopefully disappear if we split off user-visible steps from dependency nodes.)

Copy link
Member Author

@jyn514 jyn514 Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me talk about paths() a bit.

The original intent @Mark-Simulacrum had when he introduced PathSet, to my knowledge, was that multiple paths could be aliases for the same step. That's what rustdoc is doing here; both paths here run exactly the same Step, regardless of whether one or both are present.

That never really caught on. To my knowledge, this is the only usage of paths() there's ever been.

Later, in #95503, I repurposed PathSet to mean "each crate in this set should be passed to Step::make_run in RunConfig". That was not the previous meaning.

Rustdoc never looks at run.paths in make_run, so it's safe to just treat it as an alias, like elsewhere in bootstrap.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd be willing to take a separate PR that does try to YOLO get rid of paths, because if we can get away with it then that's a nice win.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(There might be some subtle differences in handling of things like --skip, but we should probably consider that sort of edge-case thing a lost cause until selector/step handling is in good enough shape that we can just have a sensible and understandable implementation.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think that reasoning is accurate. It was added in f104b12 (back in 2018!).

As that commit notes:

However, this meant that some Step specifications needed to be updated, since for example rustdoc can be built by ./x.py build src/librustdoc or ./x.py build src/tools/rustdoc. A PathSet abstraction is added that handles this: now, each Step can not only list path(...) but also paths(&[a, b, ...]) which will make it so that we don't invoke it with each of the individual paths, instead invoking it with the first path in the list (though this shouldn't be depended on).

It seems fine to me to remove support for aliases.

@rust-log-analyzer

This comment has been minimized.

@Zalathar
Copy link
Member

Zalathar commented Feb 2, 2026

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 2, 2026
Copy link
Member

@Kobzol Kobzol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renaming some of these things sounds like a good idea, but I'm not sure if all those changes are worth the churn, especially if we plan to actually rewrite how path handling works, during which I assume we will make large changes to it, which might cause additional renames.

But apart from the CargoCommand and Alias change the new names look reasonable to me.

View changes since this review

@jyn514 jyn514 force-pushed the bootstrap-selectors branch from 0e813c4 to 6393246 Compare February 6, 2026 01:48
@jyn514 jyn514 force-pushed the bootstrap-selectors branch from 6393246 to 727a9e9 Compare February 6, 2026 01:53
@jyn514
Copy link
Member Author

jyn514 commented Feb 6, 2026

ok, I have removed the Set -> Alias and Kind -> CargoSubcommand renames. I've also split out the paths removal, I'll put that in a separate PR.

@rust-log-analyzer

This comment has been minimized.

@jyn514 jyn514 force-pushed the bootstrap-selectors branch from 727a9e9 to 6c3852a Compare February 6, 2026 02:03
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 6, 2026
bootstrap: Remove `ShouldRun::paths`

Split out from rust-lang#151930. I've copied my comment in rust-lang#151930 (comment) into the commit description.

r? @Zalathar cc @Mark-Simulacrum @Kobzol

---

Some history about `paths()`. The original intent @Mark-Simulacrum had
when he introduced PathSet in rust-lang@f104b12, to my knowledge, was that multiple paths
could be aliases for the same step. That's what rustdoc is doing; both
paths for rustdoc run exactly the same Step, regardless of whether one
or both are present.

That never really caught on. To my knowledge, rustdoc is the only usage
of paths() there's ever been.

Later, in rust-lang#95503, I repurposed PathSet to mean "each crate in this set
should be passed to Step::make_run in RunConfig". That was not the
previous meaning.

Rustdoc never looks at run.paths in make_run, so it's safe to just treat
it as an alias, like elsewhere in bootstrap. Same for all the other tool
steps.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 6, 2026
bootstrap: Remove `ShouldRun::paths`

Split out from rust-lang#151930. I've copied my comment in rust-lang#151930 (comment) into the commit description.

r? @Zalathar cc @Mark-Simulacrum @Kobzol

---

Some history about `paths()`. The original intent @Mark-Simulacrum had
when he introduced PathSet in rust-lang@f104b12, to my knowledge, was that multiple paths
could be aliases for the same step. That's what rustdoc is doing; both
paths for rustdoc run exactly the same Step, regardless of whether one
or both are present.

That never really caught on. To my knowledge, rustdoc is the only usage
of paths() there's ever been.

Later, in rust-lang#95503, I repurposed PathSet to mean "each crate in this set
should be passed to Step::make_run in RunConfig". That was not the
previous meaning.

Rustdoc never looks at run.paths in make_run, so it's safe to just treat
it as an alias, like elsewhere in bootstrap. Same for all the other tool
steps.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 6, 2026
bootstrap: Remove `ShouldRun::paths`

Split out from rust-lang#151930. I've copied my comment in rust-lang#151930 (comment) into the commit description.

r? @Zalathar cc @Mark-Simulacrum @Kobzol

---

Some history about `paths()`. The original intent @Mark-Simulacrum had
when he introduced PathSet in rust-lang@f104b12, to my knowledge, was that multiple paths
could be aliases for the same step. That's what rustdoc is doing; both
paths for rustdoc run exactly the same Step, regardless of whether one
or both are present.

That never really caught on. To my knowledge, rustdoc is the only usage
of paths() there's ever been.

Later, in rust-lang#95503, I repurposed PathSet to mean "each crate in this set
should be passed to Step::make_run in RunConfig". That was not the
previous meaning.

Rustdoc never looks at run.paths in make_run, so it's safe to just treat
it as an alias, like elsewhere in bootstrap. Same for all the other tool
steps.
rust-timer added a commit that referenced this pull request Feb 6, 2026
Rollup merge of #152196 - jyn514:remove-paths, r=Zalathar

bootstrap: Remove `ShouldRun::paths`

Split out from #151930. I've copied my comment in #151930 (comment) into the commit description.

r? @Zalathar cc @Mark-Simulacrum @Kobzol

---

Some history about `paths()`. The original intent @Mark-Simulacrum had
when he introduced PathSet in f104b12, to my knowledge, was that multiple paths
could be aliases for the same step. That's what rustdoc is doing; both
paths for rustdoc run exactly the same Step, regardless of whether one
or both are present.

That never really caught on. To my knowledge, rustdoc is the only usage
of paths() there's ever been.

Later, in #95503, I repurposed PathSet to mean "each crate in this set
should be passed to Step::make_run in RunConfig". That was not the
previous meaning.

Rustdoc never looks at run.paths in make_run, so it's safe to just treat
it as an alias, like elsewhere in bootstrap. Same for all the other tool
steps.
@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 6, 2026

☔ The latest upstream changes (presumably #152230) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants