Skip to content

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