diff --git a/src/parse_utils.rs b/src/parse_utils.rs index 4e2372f..729bd8a 100644 --- a/src/parse_utils.rs +++ b/src/parse_utils.rs @@ -142,7 +142,7 @@ fn consume_attributes_with_inner(tokens: &mut TokenIter, expect_inner: bool) -> Some(TokenTree::Punct(punct)) if punct.as_char() == '=' => { let tk_equals = punct.clone(); attribute_tokens.next(); - let value = attribute_tokens.into_iter().collect(); + let value = attribute_tokens.collect(); AttributeValue::Equals(tk_equals, value) } _ => unreachable!(), diff --git a/src/types_edition.rs b/src/types_edition.rs index 4373d64..8e6d888 100644 --- a/src/types_edition.rs +++ b/src/types_edition.rs @@ -7,6 +7,7 @@ pub use crate::types::{ use crate::types::{FnQualifiers, GenericArg, GenericArgList, Impl, Module, Path}; use crate::{Constant, Punctuated, Trait, TyDefinition}; use proc_macro2::{Group, Ident, Literal, Punct, Spacing, Span, TokenStream, TokenTree}; +use quote::spanned::Spanned; impl Declaration { /// Returns the [`Vec`] of the declaration. @@ -723,6 +724,46 @@ impl TyExpr { } } +macro_rules! implement_span { + ($Kind:ident) => { + impl $Kind { + /// Returns span of this item. + pub fn span(&self) -> Span { + self.__span() + } + } + }; +} + +implement_span!(Attribute); +implement_span!(AttributeValue); +implement_span!(Declaration); +implement_span!(Enum); +implement_span!(EnumVariant); +implement_span!(EnumVariantValue); +implement_span!(Function); + +implement_span!(GenericBound); +implement_span!(GenericParam); +implement_span!(GenericParamList); +implement_span!(NamedField); +implement_span!(Struct); + +implement_span!(StructFields); +implement_span!(TupleField); +implement_span!(TyExpr); +implement_span!(Union); +implement_span!(VisMarker); +implement_span!(WhereClause); +implement_span!(WhereClauseItem); + +impl InlineGenericArgs<'_> { + /// Returns span of this item. + pub fn span(&self) -> Span { + self.__span() + } +} + impl GroupSpan { /// Create from proc_macro2 Group. pub fn new(group: &Group) -> Self {