Skip to content

Track items behind cfg_select in the same way we do for cfg - #157218

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
estebank:cfg_select_tracking
Aug 28, 2026
Merged

Track items behind cfg_select in the same way we do for cfg#157218
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
estebank:cfg_select_tracking

Conversation

@estebank

@estebank estebank commented May 31, 2026

Copy link
Copy Markdown
Contributor

View all comments

When annotating an item with #[cfg] we track both the item that got annotated (with an inert attr) and the names of items that got directly cfg'd out. Extend this mechanism to also work for items within a cfg_select!.

r? @jdonszelmann
cc @JonathanBrouwer

@rustbot

rustbot commented May 31, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 31, 2026
@rustbot

rustbot commented May 31, 2026

Copy link
Copy Markdown
Collaborator

jdonszelmann is currently at their maximum review capacity.
They may take a while to respond.

@estebank

Copy link
Copy Markdown
Contributor Author

This or something akin to this is needed for #129249. I'll clean up the code shortly, once I get that PR to the point it can run on crater.

@rustbot

rustbot commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

The Cranelift subtree was changed

cc @bjorn3

@estebank
estebank force-pushed the cfg_select_tracking branch from 2262d01 to 97da0c8 Compare June 1, 2026 00:59
@petrochenkov petrochenkov self-assigned this Jun 1, 2026
@petrochenkov

Copy link
Copy Markdown
Contributor

(I'd like to look at this, probably tomorrow, because the PR touches expansion infra.)

Comment thread compiler/rustc_expand/src/expand.rs
@estebank
estebank force-pushed the cfg_select_tracking branch from 97da0c8 to 677634c Compare June 2, 2026 00:23
@rustbot

This comment has been minimized.

Comment thread compiler/rustc_expand/src/expand.rs
Comment thread compiler/rustc_builtin_macros/src/cfg_select.rs Outdated
Comment thread compiler/rustc_builtin_macros/src/cfg_select.rs Outdated
Comment thread compiler/rustc_builtin_macros/src/cfg_select.rs Outdated
@petrochenkov petrochenkov 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 Jun 3, 2026
@rust-log-analyzer

This comment has been minimized.

@estebank
estebank force-pushed the cfg_select_tracking branch from 76ed1df to 34c1685 Compare June 3, 2026 18:22
@estebank estebank added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 3, 2026
@estebank
estebank force-pushed the cfg_select_tracking branch from 34c1685 to a04d12d Compare June 3, 2026 21:46
@petrochenkov petrochenkov removed their assignment Jun 4, 2026
@estebank

Copy link
Copy Markdown
Contributor Author

Gentle ping :)

@estebank
estebank force-pushed the cfg_select_tracking branch from a04d12d to eea0055 Compare June 19, 2026 22:54
@rustbot

This comment has been minimized.

@estebank
estebank force-pushed the cfg_select_tracking branch from eea0055 to 89a11d2 Compare June 19, 2026 22:55
@JonathanBrouwer

Copy link
Copy Markdown
Member

r? me
I can take a look at this this weekend

| | ^^^^^^^^^^^^
... |
LL | | _ => {}
| |_________- the item is gated here

@JonathanBrouwer JonathanBrouwer Aug 20, 2026

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.

Hmmm, I find the "the item is gated here" a bit wide, how hard would it be to make it point only to the cfg predicate?

View changes since the review

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.

Bonus point if we can point to the reason_span that is returned when attr::eval_config_entry returns EvalConfigResult::False, I worked hard to make that information available :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@JonathanBrouwer I think we'll need a larger change to make use of reason_span here. I noticed there are quite a few places where we immediately call .as_bool(), which completely discards that information and that might be a good place to look for further improvements.

@JonathanBrouwer JonathanBrouwer 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.

Other than that, this looks good :)
Sorry that this took so long to get reviewed, this is awesome work!

View changes since this review

@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 Aug 20, 2026
@rustbot

rustbot commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rust-bors

This comment has been minimized.

When annotating an item with `#[cfg]` we track both the item that got annotated (with an inert attr) and the names of items that got directly cfg'd out. Extend this mechanism to also work for items within a `cfg_select!`.
@estebank
estebank force-pushed the cfg_select_tracking branch from 89a11d2 to ce74313 Compare August 26, 2026 20:09
@rustbot

rustbot commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

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

@JonathanBrouwer JonathanBrouwer 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.

@bors r+ rollup
This is already a large improvement so lets get this merged.
I put it on my todo list to look at reason_span here.

View changes since this review

@rust-bors

rust-bors Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

📌 Commit ce74313 has been approved by JonathanBrouwer

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 Aug 28, 2026
rust-bors Bot pushed a commit that referenced this pull request Aug 28, 2026
…uwer

Rollup of 21 pull requests

Successful merges:

 - #150075 (Implement clamp_to)
 - #159103 (fix(reborrow): recursive implementation)
 - #160562 (add target feature ABI checks for SPARC)
 - #160848 (std: avoid aliasing violations when wrapping opaque C types)
 - #161421 (Include startup crt objects on WASI for more outputs)
 - #161805 (Prefer ambiguous candidates when deduplicating traits in scope, so `ambiguous_glob_imported_traits` doesn't depend on import order)
 - #161862 (Put data segment in specified section with link_section on wasm)
 - #161866 (delegation: add tests fixating behavior of delegating to default trait implementations)
 - #157218 (Track items behind `cfg_select` in the same way we do for `cfg`)
 - #161456 (reduce perf impact of scalar size checks)
 - #161528 (Add regression test to ensure optimal compilation)
 - #161666 (Print vendor instructions in `x vendor`)
 - #161730 (Improve type mismatch annotation for lets with block-wrapped initializers)
 - #161828 (Never type after-stabilization cleanup)
 - #161859 (Do not optimize MIR for comptime ConstFns)
 - #161860 (atomicptr.rs test: remove unused import)
 - #161870 (bind to [::1] instead of 127.0.0.1 in documentation examples for v6 UDP methods)
 - #161876 (rustdoc: Correctly handle when a macro generates multiple items in `--generate-macro-expansion`)
 - #161889 (Add link to ownership section in ptr::read docs)
 - #161890 (rustdoc: some clarifying comments)
 - #161891 (Mark `extern_item_impls` feature as incomplete)

Failed merges:

 - #161702 (Use `drop_guard` in some places in {core,alloc,std})
@rust-bors
rust-bors Bot merged commit 91c9639 into rust-lang:main Aug 28, 2026
13 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Aug 28, 2026
rust-bors Bot pushed a commit that referenced this pull request Aug 28, 2026
Rollup merge of #157218 - estebank:cfg_select_tracking, r=JonathanBrouwer

Track items behind `cfg_select` in the same way we do for `cfg`

When annotating an item with `#[cfg]` we track both the item that got annotated (with an inert attr) and the names of items that got directly cfg'd out. Extend this mechanism to also work for items within a `cfg_select!`.

r? @jdonszelmann
cc @JonathanBrouwer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants