commit | d7568e53327c614200ccf5d4b61bbbc62e566780 | [log] [tgz] |
---|---|---|
author | David Tolnay <dtolnay@gmail.com> | Sun Nov 11 15:23:32 2018 -0800 |
committer | David Tolnay <dtolnay@gmail.com> | Sun Nov 11 15:23:35 2018 -0800 |
tree | 5e561de789059e5341753c38bc3c15fca3025b42 | |
parent | c239f03ca8a4259cb8d164d7e8a5fe18e7e38be2 [diff] |
Work around when built as a dependency in docs.rs Our build script has: if cfg!(procmacro2_semver_exempt) { println!("cargo:rustc-cfg=super_unstable"); } But when proc-macro2 is built as a dependency of another crate in docs.rs, we are seeing the builder invoke rustc with `--cfg super_unstable` but without `--cfg procmacro2_semver_exempt`. The super_unstable flag is only set on that one line, so procmacro2_semver_exempt should have also been set. Hopefully this change will result in both flags being passed. We will need to figure out how to set unstable flags only when building our own docs.rs docs, not when building proc-macro2 as a dependency of a different crate.
A small shim over the proc_macro
crate in the compiler intended to multiplex the stable interface as of 1.15.0 and the interface as of 1.30.0.
New features added in Rust 1.30.0 include:
Libraries ported to proc_macro2
can retain support for older compilers while continuing to get all the nice benefits of using a 1.30.0+ compiler.
This crate compiles on all 1.15.0+ stable compilers and usage looks like:
[dependencies] proc-macro2 = "0.4"
followed by
extern crate proc_macro; extern crate proc_macro2; #[proc_macro_derive(MyDerive)] pub fn my_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let input: proc_macro2::TokenStream = input.into(); let output: proc_macro2::TokenStream = { /* transform input */ }; output.into() }
The 1.30.0 compiler is automatically detected and its interfaces are used when available.
proc-macro2
supports exporting some methods from proc_macro
which are currently highly unstable, and are not stabilized in the first pass of proc_macro
stabilizations. These features are not exported by default. Minor versions of proc-macro2
may make breaking changes to them at any time.
To enable these features, the procmacro2_semver_exempt
config flag must be passed to rustc.
RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo build
Note that this must not only be done for your crate, but for any crate that depends on your crate. This infectious nature is intentional, as it serves as a reminder that you are outside of the normal semver guarantees.
This project is licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Serde by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.