From d67b02266556283eb612c593f8cc74542bf05e5c Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Fri, 25 Sep 2020 13:38:36 -0400 Subject: [PATCH] Update `syn`, `quote`, and `proc-macro2` to post-1.0 versions This crate will currently stop compiling once PR https://github.com/rust-lang/rust/pull/76130 (a bugfix to the Rust compiler) is merged, due to the fact than old version of `syn` is in use. Newer versions of `syn` can parse the `TokenStream` passed by newer versions of rustc, allowing this crate to compile under both older and newer versions of rustc. --- Cargo.lock | 79 +++++++++--------------------- jsonrpc-types/internals/Cargo.toml | 6 +-- jsonrpc-types/internals/src/lib.rs | 39 +++++++++------ 3 files changed, 49 insertions(+), 75 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ef0f1329..74b0c46a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -729,9 +729,9 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "030a733c8287d6213886dd487564ff5c8f6aae10278b3588ed177f9d18f8d231" dependencies = [ - "proc-macro2 1.0.9", - "quote 1.0.3", - "syn 1.0.16", + "proc-macro2", + "quote", + "syn", "synstructure", ] @@ -1030,9 +1030,9 @@ dependencies = [ name = "jsonrpc-types-internals" version = "0.1.0" dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.14.9", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -1626,20 +1626,11 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "0.4.30" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +checksum = "36e28516df94f3dd551a587da5357459d9b36d945a7c37c3557928c1c2ff2a2c" dependencies = [ - "unicode-xid 0.1.0", -] - -[[package]] -name = "proc-macro2" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435" -dependencies = [ - "unicode-xid 0.2.0", + "unicode-xid", ] [[package]] @@ -1680,22 +1671,13 @@ version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" -[[package]] -name = "quote" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -dependencies = [ - "proc-macro2 0.4.30", -] - [[package]] name = "quote" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" dependencies = [ - "proc-macro2 1.0.9", + "proc-macro2", ] [[package]] @@ -2138,9 +2120,9 @@ version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" dependencies = [ - "proc-macro2 1.0.9", - "quote 1.0.3", - "syn 1.0.16", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -2257,24 +2239,13 @@ checksum = "f8c6d128ce6eff23dd4a2df63c61a96f729455cf776911917eed1a4c92155f9f" [[package]] name = "syn" -version = "0.14.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "unicode-xid 0.1.0", -] - -[[package]] -name = "syn" -version = "1.0.16" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "123bd9499cfb380418d509322d7a6d52e5315f064fe4b3ad18a53d6b92c07859" +checksum = "6690e3e9f692504b941dc6c3b188fd28df054f7fb8469ab40680df52fdcc842b" dependencies = [ - "proc-macro2 1.0.9", - "quote 1.0.3", - "unicode-xid 0.2.0", + "proc-macro2", + "quote", + "unicode-xid", ] [[package]] @@ -2283,10 +2254,10 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" dependencies = [ - "proc-macro2 1.0.9", - "quote 1.0.3", - "syn 1.0.16", - "unicode-xid 0.2.0", + "proc-macro2", + "quote", + "syn", + "unicode-xid", ] [[package]] @@ -2768,12 +2739,6 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" - [[package]] name = "unicode-xid" version = "0.2.0" diff --git a/jsonrpc-types/internals/Cargo.toml b/jsonrpc-types/internals/Cargo.toml index 78590807..8a599ed6 100644 --- a/jsonrpc-types/internals/Cargo.toml +++ b/jsonrpc-types/internals/Cargo.toml @@ -6,9 +6,9 @@ license = "Apache-2.0" edition = "2018" [dependencies] -syn = "0.14" -quote = "0.6" -proc-macro2 = "0.4" +syn = "1.0.41" +quote = "1" +proc-macro2 = "1" [lib] proc-macro = true diff --git a/jsonrpc-types/internals/src/lib.rs b/jsonrpc-types/internals/src/lib.rs index d82f2db4..edb927be 100644 --- a/jsonrpc-types/internals/src/lib.rs +++ b/jsonrpc-types/internals/src/lib.rs @@ -19,17 +19,19 @@ extern crate syn; #[macro_use] extern crate quote; +use syn::parse::{Parse, ParseStream, Result}; + struct TypeWithAttrs { typ: syn::Type, attrs: Vec, } -impl syn::synom::Synom for TypeWithAttrs { - named!(parse -> Self, do_parse!( - attrs: many0!(syn::Attribute::parse_outer) >> - typ: syn!(syn::Type) >> - (TypeWithAttrs{ typ, attrs }) - )); +impl Parse for TypeWithAttrs { + fn parse(input: ParseStream) -> Result { + let attrs = input.call(syn::Attribute::parse_outer)?; + let typ: syn::Type = input.parse()?; + Ok(TypeWithAttrs { typ, attrs }) + } } struct ParamsType { @@ -41,15 +43,22 @@ struct ParamsType { resp: syn::Ident, } -impl syn::synom::Synom for ParamsType { - named!(parse -> Self, do_parse!( - name: syn!(syn::Ident) >> - punct!(:) >> - types: brackets!(call!(syn::punctuated::Punctuated::parse_separated)) >> - punct!(,) >> - resp: syn!(syn::Ident) >> - (ParamsType { name, types, resp }) - )); +impl Parse for ParamsType { + fn parse(input: ParseStream) -> Result { + let name: syn::Ident = input.parse()?; + let _colon: Token![:] = input.parse()?; + + let inner; + let bracket = bracketed!(inner in input); + let types = syn::punctuated::Punctuated::parse_terminated(&inner)?; + let _comma: Token![,] = input.parse()?; + let resp: syn::Ident = input.parse()?; + Ok(ParamsType { + name, + types: (bracket, types), + resp + }) + } } // Get JSON-RPC name from params name.