Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update syn, quote, and proc-macro2 to post-1.0 versions #318

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
Aaron1011 committed Sep 25, 2020
commit bc22ad607b21518a91bf6bd1afa9e7680f99ac2e
79 changes: 22 additions & 57 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions jsonrpc-types/internals/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
39 changes: 24 additions & 15 deletions jsonrpc-types/internals/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<syn::Attribute>,
}

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<Self> {
let attrs = input.call(syn::Attribute::parse_outer)?;
let typ: syn::Type = input.parse()?;
Ok(TypeWithAttrs { typ, attrs })
}
}

struct ParamsType {
Expand All @@ -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<Self> {
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.
Expand Down