Merge pull request #1372 from dtolnay/syn

Update to syn 0.15
This commit is contained in:
David Tolnay 2018-09-06 21:34:14 -07:00 committed by GitHub
commit bca8c115c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 14 deletions

View File

@ -26,7 +26,7 @@ proc-macro = true
[dependencies]
proc-macro2 = "0.4"
quote = "0.6.3"
syn = { version = "0.14", features = ["visit"] }
syn = { version = "0.15", features = ["visit"] }
[dev-dependencies]
serde = { version = "1.0", path = "../serde" }

View File

@ -11,8 +11,8 @@ use proc_macro2::{Group, Span, TokenStream, TokenTree};
use std::collections::BTreeSet;
use std::str::FromStr;
use syn;
use syn::parse::{self, Parse, ParseStream};
use syn::punctuated::Punctuated;
use syn::synom::{ParseError, Synom};
use syn::Ident;
use syn::Meta::{List, NameValue, Word};
use syn::NestedMeta::{Literal, Meta};
@ -1300,11 +1300,10 @@ fn parse_lit_into_lifetimes(
struct BorrowedLifetimes(Punctuated<syn::Lifetime, Token![+]>);
impl Synom for BorrowedLifetimes {
named!(parse -> Self, map!(
call!(Punctuated::parse_separated_nonempty),
BorrowedLifetimes
));
impl Parse for BorrowedLifetimes {
fn parse(input: ParseStream) -> parse::Result<Self> {
Punctuated::parse_separated_nonempty(input).map(BorrowedLifetimes)
}
}
if let Ok(BorrowedLifetimes(lifetimes)) = parse_lit_str(string) {
@ -1513,7 +1512,8 @@ fn collect_lifetimes(ty: &syn::Type, out: &mut BTreeSet<syn::Lifetime>) {
syn::GenericArgument::Binding(ref binding) => {
collect_lifetimes(&binding.ty, out);
}
syn::GenericArgument::Const(_) => {}
syn::GenericArgument::Constraint(_)
| syn::GenericArgument::Const(_) => {}
}
}
}
@ -1535,15 +1535,15 @@ fn collect_lifetimes(ty: &syn::Type, out: &mut BTreeSet<syn::Lifetime>) {
}
}
fn parse_lit_str<T>(s: &syn::LitStr) -> Result<T, ParseError>
fn parse_lit_str<T>(s: &syn::LitStr) -> parse::Result<T>
where
T: Synom,
T: Parse,
{
let tokens = try!(spanned_tokens(s));
syn::parse2(tokens)
}
fn spanned_tokens(s: &syn::LitStr) -> Result<TokenStream, ParseError> {
fn spanned_tokens(s: &syn::LitStr) -> parse::Result<TokenStream> {
let stream = try!(syn::parse_str(&s.value()));
Ok(respan_token_stream(stream, s.span()))
}

View File

@ -81,7 +81,7 @@ mod try;
#[proc_macro_derive(Serialize, attributes(serde))]
pub fn derive_serialize(input: TokenStream) -> TokenStream {
let input: DeriveInput = syn::parse(input).unwrap();
let input = parse_macro_input!(input as DeriveInput);
ser::expand_derive_serialize(&input)
.unwrap_or_else(compile_error)
.into()
@ -89,7 +89,7 @@ pub fn derive_serialize(input: TokenStream) -> TokenStream {
#[proc_macro_derive(Deserialize, attributes(serde))]
pub fn derive_deserialize(input: TokenStream) -> TokenStream {
let input: DeriveInput = syn::parse(input).unwrap();
let input = parse_macro_input!(input as DeriveInput);
de::expand_derive_deserialize(&input)
.unwrap_or_else(compile_error)
.into()

View File

@ -16,7 +16,7 @@ path = "lib.rs"
[dependencies]
proc-macro2 = "0.4"
syn = { version = "0.14", default-features = false, features = ["derive", "parsing", "clone-impls"] }
syn = { version = "0.15", default-features = false, features = ["derive", "parsing", "clone-impls"] }
[badges]
travis-ci = { repository = "serde-rs/serde" }