diff --git a/instant-xml-macros/Cargo.toml b/instant-xml-macros/Cargo.toml index 838459e..5926677 100644 --- a/instant-xml-macros/Cargo.toml +++ b/instant-xml-macros/Cargo.toml @@ -16,4 +16,4 @@ proc-macro = true heck = "0.4" proc-macro2 = "1.0.39" quote = "1.0.18" -syn = { version = "1.0.86", features = ["full"] } +syn = { version = "2", features = ["full"] } diff --git a/instant-xml-macros/src/lib.rs b/instant-xml-macros/src/lib.rs index 3cb60e7..ba70254 100644 --- a/instant-xml-macros/src/lib.rs +++ b/instant-xml-macros/src/lib.rs @@ -76,7 +76,7 @@ impl<'input> ContainerMeta<'input> { fn xml_generics(&self, borrowed: BTreeSet) -> Generics { let mut xml_generics = self.input.generics.clone(); - let mut xml = syn::LifetimeDef::new(syn::Lifetime::new("'xml", Span::call_site())); + let mut xml = syn::LifetimeParam::new(syn::Lifetime::new("'xml", Span::call_site())); xml.bounds.extend(borrowed.into_iter()); xml_generics.params.push(xml.into()); @@ -285,9 +285,7 @@ fn discard_path_lifetimes( syn::GenericArgument::Type(ty) => { discard_lifetimes(ty, borrowed, borrow, false) } - syn::GenericArgument::Binding(_) - | syn::GenericArgument::Constraint(_) - | syn::GenericArgument::Const(_) => {} + _ => {} }) } syn::PathArguments::Parenthesized(args) => args diff --git a/instant-xml-macros/src/meta.rs b/instant-xml-macros/src/meta.rs index 9f577c2..8b258a3 100644 --- a/instant-xml-macros/src/meta.rs +++ b/instant-xml-macros/src/meta.rs @@ -4,7 +4,6 @@ use std::fmt; use proc_macro2::{Delimiter, Group, Ident, Literal, Punct, Span, TokenStream, TokenTree}; use quote::ToTokens; use syn::punctuated::Punctuated; -use syn::token::Colon2; use super::Mode; @@ -81,9 +80,10 @@ impl NamespaceMeta { segments.push_value(id.into()); syn::Path { - leading_colon: Some(Colon2 { - spans: [colon1.span(), colon2.span()], - }), + leading_colon: Some(syn::Token![::]([ + colon1.span(), + colon2.span(), + ])), segments, } } @@ -203,9 +203,10 @@ impl NamespaceMeta { segments.push_value(id.into()); syn::Path { - leading_colon: Some(Colon2 { - spans: [colon1.span(), colon2.span()], - }), + leading_colon: Some(syn::Token![::]([ + colon1.span(), + colon2.span(), + ])), segments, } } @@ -266,26 +267,17 @@ impl NamespaceMeta { } pub(crate) fn meta_items(attrs: &[syn::Attribute]) -> Vec<(MetaItem, Span)> { + let list = match attrs.iter().find(|attr| attr.path().is_ident("xml")) { + Some(attr) => match &attr.meta { + syn::Meta::List(list) => list, + _ => panic!("expected list in xml attribute"), + }, + None => return Vec::new(), + }; + let mut items = Vec::new(); - let attr = match attrs.iter().find(|attr| attr.path.is_ident("xml")) { - Some(attr) => attr, - None => return items, - }; - - let mut iter = attr.tokens.clone().into_iter(); - let first = match iter.next() { - Some(TokenTree::Group(group)) if group.delimiter() == Delimiter::Parenthesis => { - group.stream() - } - _ => panic!("expected parenthesized group in xml attribute"), - }; - - if iter.next().is_some() { - panic!("expected single token tree in xml attribute"); - } - let mut state = MetaState::Start; - for tree in first { + for tree in list.tokens.clone() { let span = tree.span(); state = match (state, tree) { (MetaState::Start, TokenTree::Ident(id)) => {