Skip to content
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

Add well known values to --check-cfg implementation #94362

Merged
merged 2 commits into from
Mar 5, 2022

Conversation

Urgau
Copy link
Member

@Urgau Urgau commented Feb 25, 2022

This pull-request adds well known values for the well known names via --check-cfg=values().

RFC 3013: Checking conditional compilation at compile time doesn't define this at all, but this seems a nice improvement.
The activation is done by a empty values() (new syntax) similar to names() except that names(foo) also activate well known names while values(aa, "aa", "kk") would not.

As stated this use a different activation logic because well known values for the well known names are not always sufficient.
In fact this is problematic for every target_* cfg because of non builtin targets, as the current implementation use those built-ins targets to create the list the well known values.

The implementation is straight forward, first we gather (if necessary) all the values (lazily or not) and then we apply them.

r? @petrochenkov

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Feb 25, 2022
@rust-highfive
Copy link
Collaborator

⚠️ Warning ⚠️

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 25, 2022
@rust-log-analyzer

This comment has been minimized.

src/test/ui/check-cfg/empty-values.rs Show resolved Hide resolved
compiler/rustc_session/src/config.rs Outdated Show resolved Hide resolved
compiler/rustc_session/src/config.rs Outdated Show resolved Hide resolved
compiler/rustc_target/src/spec/mod.rs Outdated Show resolved Hide resolved
compiler/rustc_session/src/config.rs Outdated Show resolved Hide resolved
@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 Mar 3, 2022
@Urgau Urgau force-pushed the check-cfg-values branch from 8cc0669 to 483f984 Compare March 3, 2022 12:25
@rust-log-analyzer

This comment has been minimized.

@Urgau Urgau force-pushed the check-cfg-values branch from 483f984 to 70282e9 Compare March 3, 2022 12:36
@Urgau
Copy link
Member Author

Urgau commented Mar 3, 2022

I've addressed all review comments and responded to all questions.
This is ready for another review.

@rustbot ready

@rustbot rustbot 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 Mar 3, 2022
@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 Mar 4, 2022
@petrochenkov
Copy link
Contributor

r=me after addressing the last comment #94362 (comment)

@Urgau Urgau force-pushed the check-cfg-values branch from 70282e9 to 4aa92af Compare March 4, 2022 10:16
@Urgau
Copy link
Member Author

Urgau commented Mar 4, 2022

I don't have bors permissions to r=you but it's ready.
@rustbot ready

@rustbot
Copy link
Collaborator

rustbot commented Mar 4, 2022

Error: Parsing shortcut command in comment failed: ...'tbot ready' | error: expected end of command at >| ' but I don'...

Please let @rust-lang/release know if you're having trouble with this bot.

@rustbot rustbot 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 Mar 4, 2022
@GuillaumeGomez
Copy link
Member

@bors: r=petrochenkov

@bors
Copy link
Contributor

bors commented Mar 4, 2022

📌 Commit 4aa92af has been approved by petrochenkov

@bors bors removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 4, 2022
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Mar 4, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Mar 4, 2022
Add well known values to `--check-cfg` implementation

This pull-request adds well known values for the well known names via `--check-cfg=values()`.

[RFC 3013: Checking conditional compilation at compile time](https://rust-lang.github.io/rfcs/3013-conditional-compilation-checking.html#checking-conditional-compilation-at-compile-time) doesn't define this at all, but this seems a nice improvement.
The activation is done by a empty `values()` (new syntax) similar to `names()` except that `names(foo)` also activate well known names while `values(aa, "aa", "kk")` would not.

As stated this use a different activation logic because well known values for the well known names are not always sufficient.
In fact this is problematic for every `target_*` cfg because of non builtin targets, as the current implementation use those built-ins targets to create the list the well known values.

The implementation is straight forward, first we gather (if necessary) all the values (lazily or not) and then we apply them.

r? ```@petrochenkov```
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Mar 4, 2022
Add well known values to `--check-cfg` implementation

This pull-request adds well known values for the well known names via `--check-cfg=values()`.

[RFC 3013: Checking conditional compilation at compile time](https://rust-lang.github.io/rfcs/3013-conditional-compilation-checking.html#checking-conditional-compilation-at-compile-time) doesn't define this at all, but this seems a nice improvement.
The activation is done by a empty `values()` (new syntax) similar to `names()` except that `names(foo)` also activate well known names while `values(aa, "aa", "kk")` would not.

As stated this use a different activation logic because well known values for the well known names are not always sufficient.
In fact this is problematic for every `target_*` cfg because of non builtin targets, as the current implementation use those built-ins targets to create the list the well known values.

The implementation is straight forward, first we gather (if necessary) all the values (lazily or not) and then we apply them.

r? `@petrochenkov`
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Mar 4, 2022
Add well known values to `--check-cfg` implementation

This pull-request adds well known values for the well known names via `--check-cfg=values()`.

[RFC 3013: Checking conditional compilation at compile time](https://rust-lang.github.io/rfcs/3013-conditional-compilation-checking.html#checking-conditional-compilation-at-compile-time) doesn't define this at all, but this seems a nice improvement.
The activation is done by a empty `values()` (new syntax) similar to `names()` except that `names(foo)` also activate well known names while `values(aa, "aa", "kk")` would not.

As stated this use a different activation logic because well known values for the well known names are not always sufficient.
In fact this is problematic for every `target_*` cfg because of non builtin targets, as the current implementation use those built-ins targets to create the list the well known values.

The implementation is straight forward, first we gather (if necessary) all the values (lazily or not) and then we apply them.

r? ``@petrochenkov``
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 5, 2022
Rollup of 5 pull requests

Successful merges:

 - rust-lang#94362 (Add well known values to `--check-cfg` implementation)
 - rust-lang#94577 (only disable SIMD for doctests in Miri (not for the stdlib build itself))
 - rust-lang#94595 (Fix invalid `unresolved imports` errors for a single-segment import)
 - rust-lang#94596 (Delay bug in expr adjustment when check_expr is called multiple times)
 - rust-lang#94618 (Don't round stack size up for created threads in Windows)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit afa85f0 into rust-lang:master Mar 5, 2022
@rustbot rustbot added this to the 1.61.0 milestone Mar 5, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 13, 2022
…ark-Simulacrum

Enable conditional checking of values in the Rust codebase

This pull-request enable conditional checking of (well known) values in the Rust codebase.

Well known values were added in rust-lang#94362. All the `target_*` values are taken from all the built-in targets which is why some extra values were needed do be added as they are not (yet ?) defined in any built-in targets.

r? `@Mark-Simulacrum`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 21, 2022
…k, r=petrochenkov

Update the unstable book with the new `values()` form of check-cfg

Forgot to update the unstable book in rust-lang#94362

r? `@petrochenkov`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 21, 2022
…k, r=petrochenkov

Update the unstable book with the new `values()` form of check-cfg

Forgot to update the unstable book in rust-lang#94362

r? ``@petrochenkov``
@Urgau Urgau deleted the check-cfg-values branch May 5, 2023 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

7 participants