Skip to content

cfg_select: Support unbraced expressions #145233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 15, 2025

Conversation

joshtriplett
Copy link
Member

@joshtriplett joshtriplett commented Aug 10, 2025

Tracking issue for cfg_select: #115585

When operating on expressions, cfg_select! can now handle expressions
without braces. (It still requires braces for other things, such as
items.)

Expand the test coverage and documentation accordingly.


I'm not sure whether deciding to extend cfg_select! in this way is T-lang or T-libs-api. I've labeled for both, with the request that both teams don't block on each other. :)

When operating on expressions, `cfg_select!` can now handle expressions
without braces. (It still requires braces for other things, such as
items.)

Expand the test coverage and documentation accordingly.
@joshtriplett joshtriplett added T-lang Relevant to the language team T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. I-lang-nominated Nominated for discussion during a lang team meeting. I-libs-api-nominated Nominated for discussion during a libs-api team meeting. labels Aug 10, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 10, 2025

r? @jieyouxu

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

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 10, 2025
@traviscross traviscross added the P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang label Aug 12, 2025
@Amanieu
Copy link
Member

Amanieu commented Aug 12, 2025

We discussed this in the @rust-lang/libs-api meeting and everyone was happy with this change.

@joshtriplett joshtriplett removed the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Aug 13, 2025
@traviscross
Copy link
Contributor

We discussed this in the lang meeting. We were all happy to see this land in nightly. Thanks to @joshtriplett for putting this forward.

@traviscross traviscross added I-lang-radar Items that are on lang's radar and will need eventual work or consideration. and removed I-lang-nominated Nominated for discussion during a lang team meeting. P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang labels Aug 14, 2025
@jieyouxu jieyouxu added the F-cfg_select `#![feature(cfg_select)]` label Aug 14, 2025
@jieyouxu
Copy link
Member

jieyouxu commented Aug 14, 2025

I updated the PR description to point to the tracking issue #115585. It seems like the tracking issue was very outdated, so I tried to update that as well (but I probably missed a few still). You may wish to update the tracking issue example (#115585 (comment)) to demonstrate this syntax allowance.

Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

Implementation wise, this looks good, thanks!

@jieyouxu
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Aug 14, 2025

📌 Commit 38df158 has been approved by jieyouxu

It is now in the queue for this repository.

@bors bors 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 Aug 14, 2025
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Aug 14, 2025
…eyouxu

cfg_select: Support unbraced expressions

Tracking issue for `cfg_select`: rust-lang#115585

When operating on expressions, `cfg_select!` can now handle expressions
without braces. (It still requires braces for other things, such as
items.)

Expand the test coverage and documentation accordingly.

---

I'm not sure whether deciding to extend `cfg_select!` in this way is T-lang or T-libs-api. I've labeled for both, with the request that both teams don't block on each other. :)
bors added a commit that referenced this pull request Aug 14, 2025
Rollup of 9 pull requests

Successful merges:

 - #118087 (Add Ref/RefMut try_map method)
 - #140794 (Add information about group a lint belongs to)
 - #144947 (Fix description of unsigned `checked_exact_div`)
 - #145005 (strip prefix of temporary file names when it exceeds filesystem name length limit)
 - #145233 (cfg_select: Support unbraced expressions)
 - #145243 (take attr style into account in diagnostics)
 - #145353 (bootstrap: Fix jemalloc 64K page support for aarch64 tools)
 - #145379 (bootstrap: Support passing `--timings` to cargo)
 - #145389 ([rustdoc] Revert "rustdoc search: prefer stable items in search results")

Failed merges:

 - #144983 (Rehome 37 `tests/ui/issues/` tests to other subdirectories under `tests/ui/`)
 - #145065 (resolve: Introduce `RibKind::Block`)

r? `@ghost`
`@rustbot` modify labels: rollup
Kobzol added a commit to Kobzol/rust that referenced this pull request Aug 14, 2025
…eyouxu

cfg_select: Support unbraced expressions

Tracking issue for `cfg_select`: rust-lang#115585

When operating on expressions, `cfg_select!` can now handle expressions
without braces. (It still requires braces for other things, such as
items.)

Expand the test coverage and documentation accordingly.

---

I'm not sure whether deciding to extend `cfg_select!` in this way is T-lang or T-libs-api. I've labeled for both, with the request that both teams don't block on each other. :)
@joshtriplett
Copy link
Member Author

I updated the PR description to point to the tracking issue #115585. It seems like the tracking issue was very outdated, so I tried to update that as well (but I probably missed a few still). You may wish to update the tracking issue example (#115585 (comment)) to demonstrate this syntax allowance.

Done.

bors added a commit that referenced this pull request Aug 14, 2025
Rollup of 11 pull requests

Successful merges:

 - #137872 (Include whitespace in "remove |" suggestion and make it hidden)
 - #144631 (Fix test intrinsic-raw_eq-const-bad for big-endian)
 - #145233 (cfg_select: Support unbraced expressions)
 - #145261 (Improve tracing in bootstrap)
 - #145324 (Rename and document `ONLY_HOSTS` in bootstrap)
 - #145353 (bootstrap: Fix jemalloc 64K page support for aarch64 tools)
 - #145379 (bootstrap: Support passing `--timings` to cargo)
 - #145397 (Rust documentation, use `rustc-dev-guide` :3)
 - #145398 (Use `default_field_values` in `Resolver`)
 - #145401 (cleanup: Remove useless `[T].iter().last()`)
 - #145403 (Adjust error message grammar to be less awkward)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 01bd889 into rust-lang:master Aug 15, 2025
10 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 15, 2025
rust-timer added a commit that referenced this pull request Aug 15, 2025
Rollup merge of #145233 - joshtriplett:cfg-select-expr, r=jieyouxu

cfg_select: Support unbraced expressions

Tracking issue for `cfg_select`: #115585

When operating on expressions, `cfg_select!` can now handle expressions
without braces. (It still requires braces for other things, such as
items.)

Expand the test coverage and documentation accordingly.

---

I'm not sure whether deciding to extend `cfg_select!` in this way is T-lang or T-libs-api. I've labeled for both, with the request that both teams don't block on each other. :)
@Kobzol
Copy link
Member

Kobzol commented Aug 15, 2025

@rust-timer build b7907e9

Testing for #145407.

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b7907e9): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.2% [0.2%, 0.4%] 36
Regressions ❌
(secondary)
0.3% [0.2%, 0.5%] 20
Improvements ✅
(primary)
-2.0% [-3.0%, -0.9%] 2
Improvements ✅
(secondary)
-0.2% [-0.2%, -0.1%] 9
All ❌✅ (primary) 0.1% [-3.0%, 0.4%] 38

Max RSS (memory usage)

Results (primary -3.4%, secondary -2.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.8% [0.8%, 0.8%] 1
Improvements ✅
(primary)
-3.4% [-3.4%, -3.4%] 1
Improvements ✅
(secondary)
-3.5% [-4.0%, -2.9%] 2
All ❌✅ (primary) -3.4% [-3.4%, -3.4%] 1

Cycles

Results (primary -2.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.7% [-3.2%, -2.1%] 3
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.7% [-3.2%, -2.1%] 3

Binary size

Results (primary -0.2%, secondary -0.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.2% [-0.6%, -0.1%] 4
Improvements ✅
(secondary)
-0.1% [-0.3%, -0.1%] 7
All ❌✅ (primary) -0.2% [-0.6%, -0.1%] 4

Bootstrap: 470.516s -> 470.62s (0.02%)
Artifact size: 377.36 MiB -> 377.36 MiB (-0.00%)

@rustbot rustbot added the perf-regression Performance regression. label Aug 15, 2025
@joshtriplett joshtriplett deleted the cfg-select-expr branch August 15, 2025 09:17
@joshtriplett
Copy link
Member Author

joshtriplett commented Aug 15, 2025

The perf results there don't seem particularly likely from this PR; looking at some of the deltas they're in places like LLVM codegen, which this doesn't even touch. Are those spurious/noise?

@Kobzol
Copy link
Member

Kobzol commented Aug 15, 2025

No, it's just this PR. But I think that this might actually be noise, similar to your PR with multiple macro kinds. Maybe modifying the compiler around this area triggers some back-and-forth LLVM codegen differences.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-cfg_select `#![feature(cfg_select)]` I-lang-radar Items that are on lang's radar and will need eventual work or consideration. perf-regression Performance regression. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-lang Relevant to the language team T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants