Skip to content

cfg meta variables #831

@alexcrichton

Description

@alexcrichton

It's quite often that a cfg directive in an attribute becomes fairy complicated when support for more platforms are added. Even worse, a cfg block is then often duplicated among many locations to configure off different items.

The thread_local/mod.rs file is a good example of the amount of duplication.

It would be nice to have something like the following

#![cfg_shortcut(foo, any(super, long, clause))]

#[cfg(foo)] ...
#[cfg(not(foo))] ...

Here the clause any(super, long, clause) would be shortened to the identifier foo which could then be used elsewhere. In general it would just be nice to make these long cfg directives much shorter and less error prone to copy-paste.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-langRelevant to the language team, which will review and decide on the RFC.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions