Skip to content

rustfmt: Discover modules via cfg_select!#158372

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
mkroening:rustfmt-cfg_select-modules
Jul 24, 2026
Merged

rustfmt: Discover modules via cfg_select!#158372
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
mkroening:rustfmt-cfg_select-modules

Conversation

@mkroening

@mkroening mkroening commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

View all comments

This PR renames all occurrences of cfg_match! in rustfmt to cfg_select!. This makes the module file detection logic from rust-lang/rustfmt#6522 kick in for cfg_select! instead of cfg_match!, which no longer exists.

This PR performs no other adjustments to the logic to be as small as possible.

I am opening this PR in this repo since that is also the target for the more comprehensive #154202, which covers more than merely detecting other files through cfg_select!.

Closes #158371.

CC: @ytmimi, @CAD97

@rustbot

rustbot commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

rustfmt is developed in its own repository. If possible, consider making this change to rust-lang/rustfmt instead.

cc @rust-lang/rustfmt

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustfmt Relevant to the rustfmt team, which will review and decide on the PR/issue. labels Jun 24, 2026
@rustbot

rustbot commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

r? @ytmimi

rustbot has assigned @ytmimi.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: rustfmt, rustfmt-contributors
  • rustfmt, rustfmt-contributors expanded to 6 candidates
  • Random selection from jieyouxu, ytmimi

@tgross35

Copy link
Copy Markdown
Contributor

@rustbot label +beta-nominated

cfg_select has already been stable for a few releases so there's a bit of a gap here. Since the only change is a renaming, it seems potentially feasible to backport.

@rustbot rustbot added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Jun 24, 2026
Comment thread src/tools/rustfmt/tests/target/cfg_select/lib.rs
@ytmimi

ytmimi commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Overall I think this is a good change, and although it would technically be breaking since we'd end up formatting modules listed inside the cfg_select! there is some president with let-else, which was mentioned in an earlier comment. I think as long as we mention this change in the release notes we should be fine, and I'm sure users would welcome this fix. I'm at work right now, but will review this today when I have some free time.

@ytmimi ytmimi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think there are still a few references to the old cfg_match! that we should change. Once that's done and we figure out how we'll disclose this breaking change you can r=me.

I think it's fine to get this out before cfg_select! formatting lands since I agree that the impact of entire modules being left unformatted is larger than what will change once we start formatting cfg_select! calls.

View changes since this review

Comment thread src/tools/rustfmt/src/modules/visitor.rs Outdated
Comment thread src/tools/rustfmt/src/modules/visitor.rs Outdated
@mkroening
mkroening force-pushed the rustfmt-cfg_select-modules branch from 3ba2282 to a71b047 Compare June 26, 2026 09:43
@rust-log-analyzer

This comment has been minimized.

@mkroening
mkroening force-pushed the rustfmt-cfg_select-modules branch from a71b047 to 4e98db3 Compare June 26, 2026 13:45
@mkroening
mkroening force-pushed the rustfmt-cfg_select-modules branch from 4e98db3 to facc787 Compare June 26, 2026 13:48
@cuviper

cuviper commented Jun 29, 2026

Copy link
Copy Markdown
Member

(As T-release) Please note that it's getting late for 1.97-beta backports -- ideally this should be merged and labeled beta-accepted before Friday, but at that point we won't have much meaningful beta testing time left either. Maybe it would be better to just let it ride the normal release train?

@jieyouxu

Copy link
Copy Markdown
Member

At that point, probably yeah.

@mkroening

Copy link
Copy Markdown
Contributor Author

I think the changes themselves should be fine now.

Once we figure out how we'll disclose this breaking change you can r=me.

Is there any way I can help with that? Should I write something for the release notes or do something else?

@tgross35 tgross35 added the relnotes Marks issues that should be documented in the release notes of the next release. label Jul 20, 2026
@tgross35

Copy link
Copy Markdown
Contributor

@jieyouxu would you be willing to merge this one since Yacin approved?

Once we figure out how we'll disclose this breaking change you can r=me.

Is there any way I can help with that? Should I write something for the release notes or do something else?

I added the relnotes label, you can add something to #159615.

@jieyouxu jieyouxu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, since the cfg_match -> cfg_select renames are now also done, and we have an associated relnotes issue...
@bors r=ytmimi,jieyouxu

View changes since this review

@rust-bors

rust-bors Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

📌 Commit facc787 has been approved by ytmimi,jieyouxu

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 24, 2026
rust-bors Bot pushed a commit that referenced this pull request Jul 24, 2026
Rollup of 14 pull requests

Successful merges:

 - #159765 (Avoid spurious rebuilds of JSON docs in bootstrap)
 - #159781 (Update bootstrap to use -Zembed-metadata=no instead of -Zno-embed-metadata)
 - #158362 (trait solver: account for universes from replace_bound_vars)
 - #158372 (rustfmt: Discover modules via `cfg_select!`)
 - #159173 (Add allowed list check on EII implementations attributes)
 - #159718 (Make `DocLinkResMap` an `FxIndexMap`)
 - #159722 ( [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature)
 - #159731 (std: Implement futex on wasip3 targets, update target spec)
 - #159755 (Improve consistency of attribute error messages)
 - #155795 (constify `vec![1, 2, 3]` macro)
 - #157776 (ci: Enable autodiff tests on x86_64 linux)
 - #158766 (Promote riscv64-unknown-linux-musl to tier 2 with host tools)
 - #159271 (str: add ASCII fast path to word_to_titlecase)
 - #159667 (Make some parser structured suggestions verbose and tweak their wording)
@rust-bors
rust-bors Bot merged commit 7a183d7 into rust-lang:main Jul 24, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 24, 2026
rust-timer added a commit that referenced this pull request Jul 24, 2026
Rollup merge of #158372 - mkroening:rustfmt-cfg_select-modules, r=ytmimi,jieyouxu

rustfmt: Discover modules via `cfg_select!`

This PR renames all occurrences of `cfg_match!` in rustfmt to `cfg_select!`. This makes the module file detection logic from rust-lang/rustfmt#6522 kick in for `cfg_select!` instead of `cfg_match!`, which no longer exists.

This PR performs no other adjustments to the logic to be as small as possible.

I am opening this PR in this repo since that is also the target for the more comprehensive #154202, which covers more than merely detecting other files through `cfg_select!`.

Closes #158371.

CC: @ytmimi, @CAD97
@mkroening
mkroening deleted the rustfmt-cfg_select-modules branch July 24, 2026 11:58
github-actions Bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Jul 25, 2026
Rollup of 14 pull requests

Successful merges:

 - rust-lang/rust#159765 (Avoid spurious rebuilds of JSON docs in bootstrap)
 - rust-lang/rust#159781 (Update bootstrap to use -Zembed-metadata=no instead of -Zno-embed-metadata)
 - rust-lang/rust#158362 (trait solver: account for universes from replace_bound_vars)
 - rust-lang/rust#158372 (rustfmt: Discover modules via `cfg_select!`)
 - rust-lang/rust#159173 (Add allowed list check on EII implementations attributes)
 - rust-lang/rust#159718 (Make `DocLinkResMap` an `FxIndexMap`)
 - rust-lang/rust#159722 ( [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature)
 - rust-lang/rust#159731 (std: Implement futex on wasip3 targets, update target spec)
 - rust-lang/rust#159755 (Improve consistency of attribute error messages)
 - rust-lang/rust#155795 (constify `vec![1, 2, 3]` macro)
 - rust-lang/rust#157776 (ci: Enable autodiff tests on x86_64 linux)
 - rust-lang/rust#158766 (Promote riscv64-unknown-linux-musl to tier 2 with host tools)
 - rust-lang/rust#159271 (str: add ASCII fast path to word_to_titlecase)
 - rust-lang/rust#159667 (Make some parser structured suggestions verbose and tweak their wording)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beta-nominated Nominated for backporting to the compiler in the beta channel. relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustfmt Relevant to the rustfmt team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rustfmt does not discover modules through cfg_select!

9 participants