Do not depend on quote when only parsing
diff --git a/Cargo.toml b/Cargo.toml
index ace63b1..a40b5fb 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -18,7 +18,7 @@
[features]
default = ["parsing", "printing", "clone-impls"]
full = []
-parsing = ["quote"]
+parsing = []
printing = ["quote"]
visit = []
visit_mut = []
@@ -29,7 +29,7 @@
all-features = []
[dependencies]
-quote = { git = 'https://github.com/dtolnay/quote', optional = true }
+quote = { git = "https://github.com/dtolnay/quote", optional = true }
proc-macro2 = "0.1"
unicode-xid = "0.1"
diff --git a/codegen/src/main.rs b/codegen/src/main.rs
index 99b26f8..833a85e 100644
--- a/codegen/src/main.rs
+++ b/codegen/src/main.rs
@@ -127,17 +127,16 @@
// Try to parse the AstItem declaration out of the item.
let found = if path_eq(&item.mac.path, &"ast_struct".into()) {
- syn::parse_tokens::<parsing::AstStruct>(item.mac.tts.clone().into_tokens())
+ syn::parse::<parsing::AstStruct>(item.mac.tts.clone().into())
.map_err(|_| err_msg("failed to parse ast_struct"))?
.0
} else if path_eq(&item.mac.path, &"ast_enum".into()) {
- syn::parse_tokens::<parsing::AstEnum>(item.mac.tts.clone().into_tokens())
+ syn::parse::<parsing::AstEnum>(item.mac.tts.clone().into())
.map_err(|_| err_msg("failed to parse ast_enum"))?
.0
} else if path_eq(&item.mac.path, &"ast_enum_of_structs".into()) {
- syn::parse_tokens::<parsing::AstEnumOfStructs>(
- item.mac.tts.clone().into_tokens(),
- ).map_err(|_| err_msg("failed to parse ast_enum_of_structs"))?
+ syn::parse::<parsing::AstEnumOfStructs>(item.mac.tts.clone().into())
+ .map_err(|_| err_msg("failed to parse ast_enum_of_structs"))?
.0
} else {
continue;
@@ -178,6 +177,7 @@
mod parsing {
use super::AstItem;
+ use syn;
use syn::synom::*;
use syn::*;
use quote::Tokens;
@@ -210,9 +210,9 @@
option!(manual_extra_traits) >>
rest: syn!(TokenStream) >>
(AstItem {
- ast: parse_tokens::<DeriveInput>(quote! {
+ ast: syn::parse(quote! {
pub struct #id #rest
- })?,
+ }.into())?,
features: features.0,
eos_full: features.1,
})
@@ -286,9 +286,9 @@
None => quote!(#name),
}
});
- parse_tokens::<DeriveInput>(quote! {
+ syn::parse(quote! {
pub enum #id { #(#variants),* }
- })?
+ }.into())?
};
let mut items = vec![AstItem {
ast: enum_item,
diff --git a/src/ident.rs b/src/ident.rs
index e61f801..bba6e1c 100644
--- a/src/ident.rs
+++ b/src/ident.rs
@@ -21,12 +21,10 @@
/// - A lifetime is not an identifier. Use `syn::Lifetime` instead.
///
/// An identifier constructed with `Ident::new` is permitted to be a Rust
-/// keyword, though parsing input with [`parse`], [`parse_str`] or
-/// [`parse_tokens`] rejects Rust keywords.
+/// keyword, though parsing one through its [`Synom`] implementation rejects
+/// Rust keywords.
///
-/// [`parse`]: fn.parse.html
-/// [`parse_str`]: fn.parse_str.html
-/// [`parse_tokens`]: fn.parse_tokens.html
+/// [`Synom`]: synom/trait.Synom.html
///
/// # Examples
///
diff --git a/src/lib.rs b/src/lib.rs
index 5382a36..5ba8c20 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -7,7 +7,7 @@
extern crate proc_macro;
extern crate unicode_xid;
-#[cfg(any(feature = "printing", feature = "parsing"))]
+#[cfg(feature = "printing")]
extern crate quote;
#[cfg(feature = "parsing")]
@@ -202,34 +202,6 @@
}
}
-/// Parse a `quote::Tokens` of Rust code into the chosen syn data type.
-///
-/// # Examples
-///
-/// ```rust
-/// extern crate syn;
-/// #
-/// # #[macro_use]
-/// # extern crate quote;
-/// #
-/// # type Result<T> = std::result::Result<T, Box<std::error::Error>>;
-///
-/// use syn::Expr;
-///
-/// fn run() -> Result<()> {
-/// let code = quote!(assert_eq!(u8::max_value(), 255));
-/// let expr = syn::parse_tokens::<Expr>(code)?;
-/// println!("{:#?}", expr);
-/// Ok(())
-/// }
-/// #
-/// # fn main() { run().unwrap() }
-/// ```
-#[cfg(feature = "parsing")]
-pub fn parse_tokens<T: Synom>(tokens: quote::Tokens) -> Result<T, ParseError> {
- _parse(tokens.into())
-}
-
/// Parse a string of Rust code into the chosen syn data type.
///
/// # Examples