Skip to content

Commit bc22ad6

Browse files
committed
Update syn, quote, and proc-macro2 to post-1.0 versions
This crate will currently stop compiling once PR rust-lang/rust#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.
1 parent 5acb425 commit bc22ad6

File tree

3 files changed

+49
-75
lines changed

3 files changed

+49
-75
lines changed

Cargo.lock

Lines changed: 22 additions & 57 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jsonrpc-types/internals/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ license = "Apache-2.0"
66
edition = "2018"
77

88
[dependencies]
9-
syn = "0.14"
10-
quote = "0.6"
11-
proc-macro2 = "0.4"
9+
syn = "1.0.41"
10+
quote = "1"
11+
proc-macro2 = "1"
1212

1313
[lib]
1414
proc-macro = true

jsonrpc-types/internals/src/lib.rs

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,19 @@ extern crate syn;
1919
#[macro_use]
2020
extern crate quote;
2121

22+
use syn::parse::{Parse, ParseStream, Result};
23+
2224
struct TypeWithAttrs {
2325
typ: syn::Type,
2426
attrs: Vec<syn::Attribute>,
2527
}
2628

27-
impl syn::synom::Synom for TypeWithAttrs {
28-
named!(parse -> Self, do_parse!(
29-
attrs: many0!(syn::Attribute::parse_outer) >>
30-
typ: syn!(syn::Type) >>
31-
(TypeWithAttrs{ typ, attrs })
32-
));
29+
impl Parse for TypeWithAttrs {
30+
fn parse(input: ParseStream) -> Result<Self> {
31+
let attrs = input.call(syn::Attribute::parse_outer)?;
32+
let typ: syn::Type = input.parse()?;
33+
Ok(TypeWithAttrs { typ, attrs })
34+
}
3335
}
3436

3537
struct ParamsType {
@@ -41,15 +43,22 @@ struct ParamsType {
4143
resp: syn::Ident,
4244
}
4345

44-
impl syn::synom::Synom for ParamsType {
45-
named!(parse -> Self, do_parse!(
46-
name: syn!(syn::Ident) >>
47-
punct!(:) >>
48-
types: brackets!(call!(syn::punctuated::Punctuated::parse_separated)) >>
49-
punct!(,) >>
50-
resp: syn!(syn::Ident) >>
51-
(ParamsType { name, types, resp })
52-
));
46+
impl Parse for ParamsType {
47+
fn parse(input: ParseStream) -> Result<Self> {
48+
let name: syn::Ident = input.parse()?;
49+
let _colon: Token![:] = input.parse()?;
50+
51+
let inner;
52+
let bracket = bracketed!(inner in input);
53+
let types = syn::punctuated::Punctuated::parse_terminated(&inner)?;
54+
let _comma: Token![,] = input.parse()?;
55+
let resp: syn::Ident = input.parse()?;
56+
Ok(ParamsType {
57+
name,
58+
types: (bracket, types),
59+
resp,
60+
})
61+
}
5362
}
5463

5564
// Get JSON-RPC name from params name.

0 commit comments

Comments
 (0)