mirror of
https://github.com/latex-lsp/texlab.git
synced 2025-08-04 02:39:21 +00:00
Bump syn and quote to 1.0
This commit is contained in:
parent
dd48353812
commit
c804a41faa
5 changed files with 23 additions and 25 deletions
8
Cargo.lock
generated
8
Cargo.lock
generated
|
@ -382,8 +382,8 @@ dependencies = [
|
|||
name = "futures-boxed"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -622,8 +622,8 @@ name = "jsonrpc-derive"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"futures-boxed 0.1.0",
|
||||
"quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
@ -10,5 +10,5 @@ edition = "2018"
|
|||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
syn = { version = "0.15", features = ["full"] }
|
||||
quote = "0.6"
|
||||
syn = "1.0"
|
||||
quote = "1.0"
|
||||
|
|
|
@ -28,11 +28,11 @@ pub fn boxed(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
|||
fn boxed_fn(fn_: ItemFn) -> TokenStream {
|
||||
let attrs = &fn_.attrs;
|
||||
let vis = &fn_.vis;
|
||||
let decl = boxed_fn_decl(&fn_.decl, &fn_.constness, &fn_.ident);
|
||||
let sig = boxed_fn_sig(&fn_.sig);
|
||||
let block = &fn_.block;
|
||||
let tokens = quote! {
|
||||
#(#attrs)*
|
||||
#vis #decl {
|
||||
#vis #sig {
|
||||
use futures::future::FutureExt;
|
||||
let task = async move #block;
|
||||
task.boxed()
|
||||
|
@ -44,23 +44,21 @@ fn boxed_fn(fn_: ItemFn) -> TokenStream {
|
|||
|
||||
fn boxed_trait_method(method: TraitItemMethod) -> TokenStream {
|
||||
let attrs = &method.attrs;
|
||||
let decl = boxed_fn_decl(&method.sig.decl, &method.sig.constness, &method.sig.ident);
|
||||
let sig = boxed_fn_sig(&method.sig);
|
||||
let tokens = quote! {
|
||||
#(#attrs)*
|
||||
#decl;
|
||||
#sig;
|
||||
};
|
||||
|
||||
tokens.into()
|
||||
}
|
||||
|
||||
fn boxed_fn_decl(
|
||||
decl: &FnDecl,
|
||||
constness: &Option<syn::token::Const>,
|
||||
ident: &Ident,
|
||||
) -> TokenStream2 {
|
||||
let generics = &decl.generics;
|
||||
let inputs = &decl.inputs;
|
||||
let return_ty = match &decl.output {
|
||||
fn boxed_fn_sig(sig: &Signature) -> TokenStream2 {
|
||||
let constness = &sig.constness;
|
||||
let ident = &sig.ident;
|
||||
let generics = &sig.generics;
|
||||
let inputs = &sig.inputs;
|
||||
let return_ty = match &sig.output {
|
||||
ReturnType::Default => quote!(()),
|
||||
ReturnType::Type(_, ty) => ty.into_token_stream(),
|
||||
};
|
||||
|
|
|
@ -11,5 +11,5 @@ proc-macro = true
|
|||
|
||||
[dependencies]
|
||||
futures-boxed = { path = "../futures_boxed" }
|
||||
syn = { version = "0.15", features = ["full"] }
|
||||
quote = "0.6"
|
||||
syn = "1.0"
|
||||
quote = "1.0"
|
||||
|
|
|
@ -30,12 +30,12 @@ struct MethodMeta {
|
|||
impl MethodMeta {
|
||||
pub fn parse(attr: &Attribute) -> Self {
|
||||
let meta = attr.parse_meta().unwrap();
|
||||
if meta.name() != "jsonrpc_method" {
|
||||
if meta.path().get_ident().unwrap() != "jsonrpc_method" {
|
||||
panic!("Expected jsonrpc_method attribute");
|
||||
}
|
||||
|
||||
let nested = unwrap!(meta, Meta::List(x) => x.nested);
|
||||
let name = unwrap!(&nested[0], NestedMeta::Literal(Lit::Str(x)) => x.value());
|
||||
let name = unwrap!(&nested[0], NestedMeta::Lit(Lit::Str(x)) => x.value());
|
||||
let kind = {
|
||||
let lit = unwrap!(&nested[1], NestedMeta::Meta(Meta::NameValue(x)) => &x.lit);
|
||||
let kind = unwrap!(lit, Lit::Str(x) => x.value());
|
||||
|
@ -99,7 +99,7 @@ pub fn jsonrpc_client(attr: TokenStream, item: TokenStream) -> TokenStream {
|
|||
let trait_ident = &trait_.ident;
|
||||
let stubs = generate_client_stubs(&trait_.items);
|
||||
let attr: AttributeArgs = parse_macro_input!(attr);
|
||||
let struct_ident = unwrap!(attr.first().unwrap(), NestedMeta::Meta(Meta::Word(x)) => x);
|
||||
let struct_ident = unwrap!(attr.first().unwrap(), NestedMeta::Meta(Meta::Path(x)) => x);
|
||||
|
||||
let tokens = quote! {
|
||||
#trait_
|
||||
|
@ -144,7 +144,7 @@ fn generate_server_skeletons(items: &Vec<ImplItem>) -> (Vec<TokenStream2>, Vec<T
|
|||
}
|
||||
|
||||
let ident = &method.sig.ident;
|
||||
let param_ty = unwrap!(&method.sig.decl.inputs[1], FnArg::Captured(x) => &x.ty);
|
||||
let param_ty = unwrap!(&method.sig.inputs[1], FnArg::Typed(x) => &x.ty);
|
||||
let meta = MethodMeta::parse(method.attrs.first().unwrap());
|
||||
let name = &meta.name.as_str();
|
||||
|
||||
|
@ -183,7 +183,7 @@ fn generate_client_stubs(items: &Vec<TraitItem>) -> Vec<TokenStream2> {
|
|||
let method = unwrap!(item, TraitItem::Method(x) => x);
|
||||
let attrs = &method.attrs;
|
||||
let sig = &method.sig;
|
||||
let param = unwrap!(&sig.decl.inputs[1], FnArg::Captured(x) => &x.pat);
|
||||
let param = unwrap!(&sig.inputs[1], FnArg::Typed(x) => &x.pat);
|
||||
let meta = MethodMeta::parse(attrs.first().unwrap());
|
||||
let name = &meta.name;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue