Globally upgrade to syn 2.x and latest quote and proc_macro2 1x versions (#13846)

* globally upgrade quote to latest 1.0.x (1.0.26)

* globally upgrade syn to final 1.0.x version (1.0.109)

* globally upgrade proc-macro2 to 1.0.56

* upgrade to syn v2.0.13 and fix everything except NestedMeta

* fix parse nested metadata code in decl_runtime_apis.rs

* Port more stuff to syn 2.0

* Make the rest compile

* Ignore error

* update to syn 2.0.14

---------

Co-authored-by: Bastian Köcher <info@kchr.de>
This commit is contained in:
Sam Johnson
2023-04-12 14:42:22 -04:00
committed by GitHub
parent 03c99fe003
commit b83bf4784e
62 changed files with 402 additions and 478 deletions
@@ -22,7 +22,7 @@ use syn::{
ImplItem, ItemImpl, Pat, Path, PathArguments, Result, ReturnType, Signature, Type, TypePath,
};
use quote::{format_ident, quote};
use quote::{format_ident, quote, ToTokens};
use proc_macro_crate::{crate_name, FoundCrate};
@@ -158,7 +158,7 @@ pub fn extract_all_signature_types(items: &[ImplItem]) -> Vec<Type> {
items
.iter()
.filter_map(|i| match i {
ImplItem::Method(method) => Some(&method.sig),
ImplItem::Fn(method) => Some(&method.sig),
_ => None,
})
.flat_map(|sig| {
@@ -263,18 +263,20 @@ pub fn get_doc_literals(attrs: &[syn::Attribute]) -> Vec<syn::Lit> {
attrs
.iter()
.filter_map(|attr| {
let Ok(syn::Meta::NameValue(meta)) = attr.parse_meta() else {
let syn::Meta::NameValue(meta) = &attr.meta else {
return None
};
meta.path.get_ident().filter(|ident| *ident == "doc").map(|_| meta.lit)
let Ok(lit) = syn::parse2::<syn::Lit>(meta.value.to_token_stream()) else {
unreachable!("non-lit doc attribute values do not exist");
};
meta.path.get_ident().filter(|ident| *ident == "doc").map(|_| lit)
})
.collect()
}
/// Filters all attributes except the cfg ones.
pub fn filter_cfg_attributes(attrs: &[syn::Attribute]) -> Vec<syn::Attribute> {
attrs.iter().filter(|a| a.path.is_ident("cfg")).cloned().collect()
attrs.iter().filter(|a| a.path().is_ident("cfg")).cloned().collect()
}
#[cfg(test)]