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

[cfg_match] Adjust syntax #133720

Merged
merged 1 commit into from
Jan 16, 2025
Merged

Conversation

c410-f3r
Copy link
Contributor

@c410-f3r c410-f3r commented Dec 1, 2024

A year has passed since the creation of #115585 and the feature, as expected, is not moving forward. Let's change that.

This PR proposes changing the arm's syntax from cfg(SOME_CONDITION) => { ... } to SOME_CODITION => {}.

match_cfg! {
   unix => {
        fn foo() { /* unix specific functionality */ }
    }
    target_pointer_width = "32" => {
        fn foo() { /* non-unix, 32-bit functionality */ }
    }
    _ => {
        fn foo() { /* fallback implementation */ }
    }
}

Why? Because after several manual migrations in #116342 it became clear, at least for me, that cfg prefixes are unnecessary, verbose and redundant.

Again, everything is just a proposal to move things forward. If the shown syntax isn't ideal, feel free to close this PR or suggest other alternatives.

@rustbot
Copy link
Collaborator

rustbot commented Dec 1, 2024

r? @davidtwco

rustbot has assigned @davidtwco.
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 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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Dec 1, 2024
@c410-f3r c410-f3r changed the title [macro_metavar_expr_concat] Adjust syntax [cfg_match] Adjust syntax Dec 1, 2024
@c410-f3r
Copy link
Contributor Author

c410-f3r commented Dec 1, 2024

@rustbot modify labels: +T-libs-api -T-compiler

@rustbot rustbot added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 1, 2024
@rust-log-analyzer

This comment has been minimized.

@c410-f3r c410-f3r force-pushed the cfg-match-foo-bar-baz branch from d3bc54d to 7087e0d Compare December 1, 2024 23:58
@rust-log-analyzer

This comment has been minimized.

@c410-f3r c410-f3r force-pushed the cfg-match-foo-bar-baz branch from 7087e0d to bf503ec Compare December 2, 2024 00:11
@rust-log-analyzer

This comment has been minimized.

@c410-f3r c410-f3r force-pushed the cfg-match-foo-bar-baz branch from bf503ec to 093de3c Compare December 2, 2024 00:24
@rust-log-analyzer

This comment has been minimized.

@c410-f3r c410-f3r force-pushed the cfg-match-foo-bar-baz branch from 093de3c to 7dedd32 Compare December 2, 2024 00:37
@rust-log-analyzer

This comment has been minimized.

@c410-f3r c410-f3r force-pushed the cfg-match-foo-bar-baz branch from 7dedd32 to 6a107c8 Compare December 2, 2024 01:09
@rust-log-analyzer

This comment has been minimized.

@c410-f3r c410-f3r force-pushed the cfg-match-foo-bar-baz branch from 6a107c8 to 5c363b1 Compare December 2, 2024 01:31
@davidtwco
Copy link
Member

r? libs-api

@rustbot rustbot assigned m-ou-se and unassigned davidtwco Dec 2, 2024
@c410-f3r c410-f3r force-pushed the cfg-match-foo-bar-baz branch from 5c363b1 to c635f0d Compare December 4, 2024 13:18
@c410-f3r
Copy link
Contributor Author

r? libs-api

@rustbot rustbot assigned joshtriplett and unassigned m-ou-se Dec 11, 2024
@joshtriplett
Copy link
Member

This looks great. Let's ship it.

@c410-f3r
Copy link
Contributor Author

Thank you for the review, @joshtriplett.

For what it is worth, my personal preference falls under the current duplicated strategy because of it is already in place 🦥

@joshtriplett
Copy link
Member

Thank you for the review, @joshtriplett.

For what it is worth, my personal preference falls under the current duplicated strategy because of it is already in place 🦥

That was what I was suggesting. I don't think it's worth the additional delay to avoid the duplication.

@c410-f3r c410-f3r force-pushed the cfg-match-foo-bar-baz branch from 4ed46e8 to 0c7310d Compare December 22, 2024 19:53
@rust-log-analyzer

This comment has been minimized.

@c410-f3r c410-f3r force-pushed the cfg-match-foo-bar-baz branch from 0c7310d to c89f0dc Compare December 22, 2024 20:12
@c410-f3r
Copy link
Contributor Author

@joshtriplett All concerns were addressed and this PR is waiting for a r+.

@joshtriplett
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jan 16, 2025

📌 Commit c89f0dc has been approved by joshtriplett

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 Jan 16, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 16, 2025
…joshtriplett

[cfg_match] Adjust syntax

A year has passed since the creation of rust-lang#115585 and the feature, as expected, is not moving forward. Let's change that.

This PR proposes changing the arm's syntax from  `cfg(SOME_CONDITION) => { ... }` to `SOME_CODITION => {}`.

```rust
match_cfg! {
   unix => {
        fn foo() { /* unix specific functionality */ }
    }
    target_pointer_width = "32" => {
        fn foo() { /* non-unix, 32-bit functionality */ }
    }
    _ => {
        fn foo() { /* fallback implementation */ }
    }
}
```

Why? Because after several manual migrations in rust-lang#116342 it became clear,  at least for me, that `cfg` prefixes are unnecessary, verbose and redundant.

Again, everything is just a proposal to move things forward. If the shown syntax isn't ideal, feel free to close this PR or suggest other alternatives.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 16, 2025
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#133720 ([cfg_match] Adjust syntax)
 - rust-lang#134496 (Update documentation for Arc::from_raw, Arc::increment_strong_count, and Arc::decrement_strong_count to clarify allocator requirement)
 - rust-lang#134754 (Implement `use` associated items of traits)
 - rust-lang#135249 (Fix overflows in the implementation of `overflowing_literals` lint's help)
 - rust-lang#135251 (Only treat plain literal patterns as short)
 - rust-lang#135556 (Clarify note in `std::sync::LazyLock` example)
 - rust-lang#135560 (Update `compiler-builtins` to 0.1.144)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 16, 2025
…joshtriplett

[cfg_match] Adjust syntax

A year has passed since the creation of rust-lang#115585 and the feature, as expected, is not moving forward. Let's change that.

This PR proposes changing the arm's syntax from  `cfg(SOME_CONDITION) => { ... }` to `SOME_CODITION => {}`.

```rust
match_cfg! {
   unix => {
        fn foo() { /* unix specific functionality */ }
    }
    target_pointer_width = "32" => {
        fn foo() { /* non-unix, 32-bit functionality */ }
    }
    _ => {
        fn foo() { /* fallback implementation */ }
    }
}
```

Why? Because after several manual migrations in rust-lang#116342 it became clear,  at least for me, that `cfg` prefixes are unnecessary, verbose and redundant.

Again, everything is just a proposal to move things forward. If the shown syntax isn't ideal, feel free to close this PR or suggest other alternatives.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 16, 2025
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#133720 ([cfg_match] Adjust syntax)
 - rust-lang#134496 (Update documentation for Arc::from_raw, Arc::increment_strong_count, and Arc::decrement_strong_count to clarify allocator requirement)
 - rust-lang#135249 (Fix overflows in the implementation of `overflowing_literals` lint's help)
 - rust-lang#135251 (Only treat plain literal patterns as short)
 - rust-lang#135556 (Clarify note in `std::sync::LazyLock` example)
 - rust-lang#135560 (Update `compiler-builtins` to 0.1.144)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 16, 2025
…iaskrgr

Rollup of 5 pull requests

Successful merges:

 - rust-lang#133720 ([cfg_match] Adjust syntax)
 - rust-lang#134496 (Update documentation for Arc::from_raw, Arc::increment_strong_count, and Arc::decrement_strong_count to clarify allocator requirement)
 - rust-lang#135249 (Fix overflows in the implementation of `overflowing_literals` lint's help)
 - rust-lang#135251 (Only treat plain literal patterns as short)
 - rust-lang#135556 (Clarify note in `std::sync::LazyLock` example)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit fca1481 into rust-lang:master Jan 16, 2025
6 checks passed
@rustbot rustbot added this to the 1.86.0 milestone Jan 16, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jan 16, 2025
Rollup merge of rust-lang#133720 - c410-f3r:cfg-match-foo-bar-baz, r=joshtriplett

[cfg_match] Adjust syntax

A year has passed since the creation of rust-lang#115585 and the feature, as expected, is not moving forward. Let's change that.

This PR proposes changing the arm's syntax from  `cfg(SOME_CONDITION) => { ... }` to `SOME_CODITION => {}`.

```rust
match_cfg! {
   unix => {
        fn foo() { /* unix specific functionality */ }
    }
    target_pointer_width = "32" => {
        fn foo() { /* non-unix, 32-bit functionality */ }
    }
    _ => {
        fn foo() { /* fallback implementation */ }
    }
}
```

Why? Because after several manual migrations in rust-lang#116342 it became clear,  at least for me, that `cfg` prefixes are unnecessary, verbose and redundant.

Again, everything is just a proposal to move things forward. If the shown syntax isn't ideal, feel free to close this PR or suggest other alternatives.
jieyouxu added a commit to jieyouxu/rust that referenced this pull request Jan 21, 2025
…tgross35,jhpratt

[cfg_match] Document the use of expressions.

cc rust-lang#115585

Adds documentation to this new feature introduced in rust-lang#133720.
jieyouxu added a commit to jieyouxu/rust that referenced this pull request Jan 21, 2025
…tgross35,jhpratt

[cfg_match] Document the use of expressions.

cc rust-lang#115585

Adds documentation to this new feature introduced in rust-lang#133720.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 21, 2025
…tgross35,jhpratt

[cfg_match] Document the use of expressions.

cc rust-lang#115585

Adds documentation to this new feature introduced in rust-lang#133720.
Zalathar added a commit to Zalathar/rust that referenced this pull request Jan 29, 2025
…tgross35,jhpratt

[cfg_match] Document the use of expressions.

cc rust-lang#115585

Adds documentation to this new feature introduced in rust-lang#133720.
fmease added a commit to fmease/rust that referenced this pull request Jan 29, 2025
…tgross35,jhpratt

[cfg_match] Document the use of expressions.

cc rust-lang#115585

Adds documentation to this new feature introduced in rust-lang#133720.
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jan 29, 2025
Rollup merge of rust-lang#135625 - c410-f3r:cfg-match-foo-bar-baz, r=tgross35,jhpratt

[cfg_match] Document the use of expressions.

cc rust-lang#115585

Adds documentation to this new feature introduced in rust-lang#133720.
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-libs Relevant to the library team, which will review and decide on the PR/issue. 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.

8 participants