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.
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:Then, run
cargo +beta test
orcargo +nightly test
. The test case isn't included in the PR because it doesn't compile on stable Rust.