commit | 92ab1b4e3e3bc6defa7716c95cb0af0a6d66f0f6 | [log] [tgz] |
---|---|---|
author | Alex Crichton <alex@alexcrichton.com> | Sun Dec 31 01:00:12 2017 -0600 |
committer | GitHub <noreply@github.com> | Sun Dec 31 01:00:12 2017 -0600 |
tree | 9cb4ea2fb07710624e01c9579f5e7f1b544557a3 | |
parent | 7b7157c7b1769e63ae040c47f2fead65becf98b6 [diff] | |
parent | 3aa5bdf4c6e23c423fe3e2ba914704c9e84b0d08 [diff] |
Merge pull request #36 from mystor/stable_span Support meaningful spans in the stable version of proc-macro2
A small shim over the proc_macro
crate in the compiler intended to multiplex the current stable interface (as of 2017-07-05) and the upcoming richer interface.
The upcoming support has features like:
The hope is that libraries ported to proc_macro2
will be trivial to port to the real proc_macro
crate once the support on nightly is stabilize.
This crate by default compiles on the stable version of the compiler. It only uses the stable surface area of the proc_macro
crate upstream in the compiler itself. Usage is done via:
[dependencies] proc-macro2 = "0.1"
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() }
If you'd like you can enable the unstable
feature in this crate. This will cause it to compile against the unstable and nightly-only features of the proc_macro
crate. This in turn requires a nightly compiler. This should help preserve span information, however, coming in from the compiler itself.
You can enable this feature via:
[dependencies] proc-macro2 = { version = "0.1", features = ["unstable"] }
proc-macro2
supports exporting some methods from proc_macro
which are currently highly unstable, and may not be stabilized in the first pass of proc_macro
stabilizations. These features are not exported by default.
To export these features, the procmacro2_unstable
config flag must be passed to rustc. To pass this flag, run cargo
with RUSTFLAGS='--cfg procmacro2_unstable' cargo build
.
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.