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 rustversion::cfg! macro #30

Merged
merged 1 commit into from
Dec 6, 2021
Merged

Add rustversion::cfg! macro #30

merged 1 commit into from
Dec 6, 2021

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented Dec 6, 2021

A function-like procedural macro named cfg! was disallowed prior to Rust 1.38:

error: name `cfg` is reserved in macro namespace
   --> src/lib.rs:233:8
    |
233 | pub fn cfg(input: TokenStream) -> TokenStream {
    |        ^^^

but this restriction was lifted by rust-lang/rust#62243 (rust-lang/rust@3274507) and rust-lang/rust#62476.

Usage:

if rustversion::cfg!(nightly) {
    ...
} else {
    ...
}

Closes #7.

@dtolnay dtolnay merged commit ad98471 into master Dec 6, 2021
@dtolnay dtolnay deleted the cfg branch December 6, 2021 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Analog to std::cfg! macro
1 participant