Fix doctests and macros
diff --git a/src/generics.rs b/src/generics.rs
index cb0ef81..e1e1cc5 100644
--- a/src/generics.rs
+++ b/src/generics.rs
@@ -308,12 +308,14 @@
/// for that type.
///
/// ```
+ /// # extern crate proc_macro2;
/// # extern crate syn;
/// # #[macro_use]
/// # extern crate quote;
+ /// # use proc_macro2::{Span, Ident};
/// # fn main() {
/// # let generics: syn::Generics = Default::default();
- /// # let name = syn::Ident::from("MyType");
+ /// # let name = Ident::new("MyType", Span::call_site());
/// let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
/// quote! {
/// impl #impl_generics MyTrait for #name #ty_generics #where_clause {
diff --git a/src/parsers.rs b/src/parsers.rs
index 7691074..ebe229c 100644
--- a/src/parsers.rs
+++ b/src/parsers.rs
@@ -217,7 +217,7 @@
/// #[macro_use]
/// extern crate syn;
///
-/// use syn::{Expr, Ident};
+/// use syn::Expr;
///
/// /// Parses any expression that does not begin with a `-` minus sign.
/// named!(not_negative_expr -> Expr, do_parse!(
@@ -251,8 +251,10 @@
/// ```rust
/// #[macro_use]
/// extern crate syn;
+/// extern crate proc_macro2;
///
-/// use syn::{Ident, MacroDelimiter};
+/// use proc_macro2::Ident;
+/// use syn::MacroDelimiter;
/// use syn::token::{Paren, Bracket, Brace};
/// use syn::synom::Synom;
///
@@ -416,8 +418,10 @@
/// ```rust
/// #[macro_use]
/// extern crate syn;
+/// extern crate proc_macro2;
///
-/// use syn::{Ident, Item};
+/// use proc_macro2::Ident;
+/// use syn::Item;
/// use syn::token::Brace;
/// use syn::synom::Synom;
///
@@ -526,8 +530,9 @@
/// ```rust
/// #[macro_use]
/// extern crate syn;
+/// extern crate proc_macro2;
///
-/// use syn::Ident;
+/// use proc_macro2::Ident;
/// use syn::token::Brace;
/// use syn::synom::Synom;
///
@@ -620,8 +625,9 @@
/// ```rust
/// #[macro_use]
/// extern crate syn;
+/// extern crate proc_macro2;
///
-/// use syn::Ident;
+/// use proc_macro2::Ident;
/// use syn::token::Brace;
/// use syn::synom::Synom;
///
@@ -811,15 +817,16 @@
/// ```rust
/// #[macro_use]
/// extern crate syn;
+/// extern crate proc_macro2;
///
-/// use syn::Ident;
+/// use proc_macro2::{Ident, Span};
///
/// // Parse any identifier token, or the `!` token in which case the
/// // identifier is treated as `"BANG"`.
/// named!(ident_or_bang -> Ident, alt!(
/// syn!(Ident)
/// |
-/// punct!(!) => { |_| "BANG".into() }
+/// punct!(!) => { |_| Ident::new("BANG", Span::call_site()) }
/// ));
/// #
/// # fn main() {}
@@ -926,10 +933,10 @@
/// extern crate syn;
/// extern crate proc_macro2;
///
-/// use syn::Ident;
+/// use proc_macro2::Ident;
+/// use proc_macro2::TokenStream;
/// use syn::token::Paren;
/// use syn::synom::Synom;
-/// use proc_macro2::TokenStream;
///
/// /// Parse a macro invocation that uses `(` `)` parentheses.
/// ///
@@ -1222,8 +1229,10 @@
/// ```rust
/// #[macro_use]
/// extern crate syn;
+/// extern crate proc_macro2;
///
-/// use syn::{Ident, Item};
+/// use proc_macro2::Ident;
+/// use syn::Item;
/// use syn::token::Brace;
/// use syn::synom::Synom;
///
@@ -1275,8 +1284,9 @@
/// ```rust
/// #[macro_use]
/// extern crate syn;
+/// extern crate proc_macro2;
///
-/// use syn::Ident;
+/// use proc_macro2::Ident;
/// use syn::synom::Synom;
///
/// struct Flag {
@@ -1301,10 +1311,14 @@
#[macro_export]
macro_rules! custom_keyword {
($i:expr, $keyword:ident) => {
- match <$crate::Ident as $crate::synom::Synom>::parse($i) {
+ match <
+ $crate::parsers::__custom_keyword_inner::Ident
+ as
+ $crate::synom::Synom
+ >::parse($i) {
::std::result::Result::Err(err) => ::std::result::Result::Err(err),
::std::result::Result::Ok((token, i)) => {
- if token == stringify!($keyword) {
+ if token.to_string() == stringify!($keyword) {
::std::result::Result::Ok((token, i))
} else {
$crate::parse_error()
@@ -1314,6 +1328,11 @@
};
}
+#[doc(hidden)]
+pub mod __custom_keyword_inner {
+ pub use proc_macro2::Ident;
+}
+
/// Parse inside of `(` `)` parentheses.
///
/// This macro parses a set of balanced parentheses and invokes a sub-parser on
diff --git a/src/path.rs b/src/path.rs
index f27d6b2..499ad25 100644
--- a/src/path.rs
+++ b/src/path.rs
@@ -32,9 +32,11 @@
/// ```rust
/// extern crate syn;
/// extern crate quote;
+/// extern crate proc_macro2;
///
/// use syn::{QSelf, Path, PathTokens};
-/// use quote::{Tokens, ToTokens};
+/// use proc_macro2::TokenStream;
+/// use quote::ToTokens;
///
/// struct MyNode {
/// qself: Option<QSelf>,
diff --git a/src/token.rs b/src/token.rs
index 6278ef8..f0ed103 100644
--- a/src/token.rs
+++ b/src/token.rs
@@ -23,8 +23,10 @@
//! ```
//! # #[macro_use]
//! # extern crate syn;
+//! # extern crate proc_macro2;
//! #
-//! # use syn::{Attribute, Visibility, Ident, Type, Expr};
+//! # use proc_macro2::Ident;
+//! # use syn::{Attribute, Visibility, Type, Expr};
//! #
//! pub struct ItemStatic {
//! pub attrs: Vec<Attribute>,
@@ -58,9 +60,11 @@
//! ```
//! #[macro_use]
//! extern crate syn;
+//! extern crate proc_macro2;
//!
+//! use proc_macro2::Ident;
//! use syn::synom::Synom;
-//! use syn::{Attribute, Visibility, Ident, Type, Expr};
+//! use syn::{Attribute, Visibility, Type, Expr};
//! #
//! # struct ItemStatic;
//! # use syn::ItemStatic as SynItemStatic;