rust-lang / cfg-if

A if/elif-like macro for Rust #[cfg] statements
Apache License 2.0
557 stars 40 forks source link

Get it to work with Rust 2018 module changes #16

Closed billyrieger closed 6 years ago

billyrieger commented 6 years ago

Currently cfg-if is unusable with the Rust 2018 module changes (playground).

As per this internals thread, the recommended solution to maintain Rust 2015 compatibility is to add the #[macro_export(local_inner_macros)] attribute to the macro.

To test that the fix works, create tests/rust2018.rs with the following content:

cfg_if::cfg_if! {
    if #[cfg(foo)] {
        struct Foo;
    }
}

Then, run cargo +beta test or cargo +nightly test. The test case isn't included in the PR because it doesn't compile on stable Rust.

alexcrichton commented 6 years ago

Thanks!

billyrieger commented 6 years ago

Thanks for the quick response!