cfg meta variables
Nobody has claimed this yet.
- Dominant language
- Markdown
- Stars
- 6.6k
- Forks
- 1.7k
- Avg merge
- 16h 14m
- Merged PRs (30d)
- 1
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the cfg duplication example in src/libstd/thread_local/mod.rs and compare it with the proposed cfg_shortcut syntax in this issue. Define the shortcut's intended scope and behavior for #[cfg(foo)] and #[cfg(not(foo))], then document how completion would be validated against the repeated platform clauses.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100