You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
rustfmt does not discover modules through cfg_select! #158371
In case this issue is a better fit for the rustfmt repo, feel free to move it there. Also, if this is not a good fit for the regression tag, please change it.
$ rustfmt src/lib.rs --verboseFormatting src/format_me_please_1.rsFormatting src/format_me_please_2.rsFormatting src/lib.rsSpent 0.004 secs in the parsing phase, and 0.002 secs in the formatting phase
Support for detecting module files through cfg_match! was addded in rust-lang/rustfmt#6522. But cfg_match! was renamed to cfg_select! in #137198, and if you change the code above to say cfg_select!, it no longer detects the module files:
$ rustfmt src/lib.rs --verboseFormatting src/lib.rsSpent 0.002 secs in the parsing phase, and 0.001 secs in the formatting phase
So anyone who has used cfg_select! to define modules in other files has possibly unformatted files. This is especially relevant due to the recent stabilization of cfg_select! (#149783) the migration from cfg_if! to cfg_select! in the ecosystem (e.g., rust-lang/compiler-builtins#1224).
#154202 does not appear to fix this issue. Renaming the corresponding occurrences in rustfmt fixes the issue for me, so I have opened #158372.
Activity
tgross35 commentedon Jun 24, 2026
Started a Zulip discussion #t-rustfmt > cfg_select module discovery
rustbot commentedon Jun 26, 2026
Assigning P-medium (discussion on Zulip).
Rollup merge of rust-lang#158372 - mkroening:rustfmt-cfg_select-modul…
Unrolled build for #158372
Rollup merge of #158372 - mkroening:rustfmt-cfg_select-modules, r=ytm…
Rollup merge of #158372 - mkroening:rustfmt-cfg_select-modules, r=ytm…