Skip to content

[cfg_match] Adjust syntax#133720

Merged
bors merged 1 commit intorust-lang:masterfrom
c410-f3r:cfg-match-foo-bar-baz
Jan 16, 2025
Merged

[cfg_match] Adjust syntax#133720
bors merged 1 commit intorust-lang:masterfrom
c410-f3r:cfg-match-foo-bar-baz

Conversation

@c410-f3r
Copy link
Copy Markdown
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.

Loading
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)]` 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.

10 participants