Upgrade to syn 2
This commit is contained in:
parent
ff00c96ac9
commit
083cd567a1
|
@ -16,4 +16,4 @@ proc-macro = true
|
||||||
heck = "0.4"
|
heck = "0.4"
|
||||||
proc-macro2 = "1.0.39"
|
proc-macro2 = "1.0.39"
|
||||||
quote = "1.0.18"
|
quote = "1.0.18"
|
||||||
syn = { version = "1.0.86", features = ["full"] }
|
syn = { version = "2", features = ["full"] }
|
||||||
|
|
|
@ -76,7 +76,7 @@ impl<'input> ContainerMeta<'input> {
|
||||||
|
|
||||||
fn xml_generics(&self, borrowed: BTreeSet<syn::Lifetime>) -> Generics {
|
fn xml_generics(&self, borrowed: BTreeSet<syn::Lifetime>) -> Generics {
|
||||||
let mut xml_generics = self.input.generics.clone();
|
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.bounds.extend(borrowed.into_iter());
|
||||||
xml_generics.params.push(xml.into());
|
xml_generics.params.push(xml.into());
|
||||||
|
|
||||||
|
@ -285,9 +285,7 @@ fn discard_path_lifetimes(
|
||||||
syn::GenericArgument::Type(ty) => {
|
syn::GenericArgument::Type(ty) => {
|
||||||
discard_lifetimes(ty, borrowed, borrow, false)
|
discard_lifetimes(ty, borrowed, borrow, false)
|
||||||
}
|
}
|
||||||
syn::GenericArgument::Binding(_)
|
_ => {}
|
||||||
| syn::GenericArgument::Constraint(_)
|
|
||||||
| syn::GenericArgument::Const(_) => {}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
syn::PathArguments::Parenthesized(args) => args
|
syn::PathArguments::Parenthesized(args) => args
|
||||||
|
|
|
@ -4,7 +4,6 @@ use std::fmt;
|
||||||
use proc_macro2::{Delimiter, Group, Ident, Literal, Punct, Span, TokenStream, TokenTree};
|
use proc_macro2::{Delimiter, Group, Ident, Literal, Punct, Span, TokenStream, TokenTree};
|
||||||
use quote::ToTokens;
|
use quote::ToTokens;
|
||||||
use syn::punctuated::Punctuated;
|
use syn::punctuated::Punctuated;
|
||||||
use syn::token::Colon2;
|
|
||||||
|
|
||||||
use super::Mode;
|
use super::Mode;
|
||||||
|
|
||||||
|
@ -81,9 +80,10 @@ impl NamespaceMeta {
|
||||||
segments.push_value(id.into());
|
segments.push_value(id.into());
|
||||||
|
|
||||||
syn::Path {
|
syn::Path {
|
||||||
leading_colon: Some(Colon2 {
|
leading_colon: Some(syn::Token![::]([
|
||||||
spans: [colon1.span(), colon2.span()],
|
colon1.span(),
|
||||||
}),
|
colon2.span(),
|
||||||
|
])),
|
||||||
segments,
|
segments,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,9 +203,10 @@ impl NamespaceMeta {
|
||||||
segments.push_value(id.into());
|
segments.push_value(id.into());
|
||||||
|
|
||||||
syn::Path {
|
syn::Path {
|
||||||
leading_colon: Some(Colon2 {
|
leading_colon: Some(syn::Token![::]([
|
||||||
spans: [colon1.span(), colon2.span()],
|
colon1.span(),
|
||||||
}),
|
colon2.span(),
|
||||||
|
])),
|
||||||
segments,
|
segments,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -266,26 +267,17 @@ impl NamespaceMeta {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn meta_items(attrs: &[syn::Attribute]) -> Vec<(MetaItem, Span)> {
|
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 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;
|
let mut state = MetaState::Start;
|
||||||
for tree in first {
|
for tree in list.tokens.clone() {
|
||||||
let span = tree.span();
|
let span = tree.span();
|
||||||
state = match (state, tree) {
|
state = match (state, tree) {
|
||||||
(MetaState::Start, TokenTree::Ident(id)) => {
|
(MetaState::Start, TokenTree::Ident(id)) => {
|
||||||
|
|
Loading…
Reference in New Issue