Add a feature for linking to `proc-macro`
This commit adds a feature to this crate which enables linking to the
upstream `proc_macro` crate. This should help this compile on targets
which don't have `proc_macro` and allow it to also be suitable for
embedding in Rust binaries.
This feature is turned on by default for backwards compatibility right
now.
diff --git a/src/stable.rs b/src/stable.rs
index 41a7c4b..5421060 100644
--- a/src/stable.rs
+++ b/src/stable.rs
@@ -11,7 +11,6 @@
use std::str::FromStr;
use std::vec;
-use proc_macro;
use unicode_xid::UnicodeXID;
use strnom::{Cursor, PResult, skip_whitespace, block_comment, whitespace, word_break};
@@ -120,14 +119,16 @@
}
}
-impl From<proc_macro::TokenStream> for TokenStream {
- fn from(inner: proc_macro::TokenStream) -> TokenStream {
+#[cfg(feature = "proc-macro")]
+impl From<::proc_macro::TokenStream> for TokenStream {
+ fn from(inner: ::proc_macro::TokenStream) -> TokenStream {
inner.to_string().parse().expect("compiler token stream parse failed")
}
}
-impl From<TokenStream> for proc_macro::TokenStream {
- fn from(inner: TokenStream) -> proc_macro::TokenStream {
+#[cfg(feature = "proc-macro")]
+impl From<TokenStream> for ::proc_macro::TokenStream {
+ fn from(inner: TokenStream) -> ::proc_macro::TokenStream {
inner.to_string().parse().expect("failed to parse to compiler tokens")
}
}