diff --git a/Cargo.toml b/Cargo.toml index cb35f854..83884f52 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,3 +6,8 @@ members = [ "serde_test", "test_suite", ] + +[patch.crates-io] +proc-macro2 = { git = 'https://github.com/alexcrichton/proc-macro2', branch = 'v3' } +quote = { git = 'https://github.com/alexcrichton/quote', branch = 'v3' } +syn = { git = 'https://github.com/alexcrichton/syn', branch = 'v3' } diff --git a/serde_derive/Cargo.toml b/serde_derive/Cargo.toml index b0394886..c4caed59 100644 --- a/serde_derive/Cargo.toml +++ b/serde_derive/Cargo.toml @@ -23,10 +23,10 @@ name = "serde_derive" proc-macro = true [dependencies] -proc-macro2 = "0.2" -quote = "0.4" +proc-macro2 = "0.3" +quote = "0.5" serde_derive_internals = { version = "=0.22.2", default-features = false, path = "../serde_derive_internals" } -syn = { version = "0.12", features = ["visit"] } +syn = { version = "0.13", features = ["visit"] } [dev-dependencies] serde = { version = "1.0", path = "../serde" } diff --git a/serde_derive/src/bound.rs b/serde_derive/src/bound.rs index d6346bfa..9de233cb 100644 --- a/serde_derive/src/bound.rs +++ b/serde_derive/src/bound.rs @@ -249,7 +249,7 @@ pub fn with_self_bound( } pub fn with_lifetime_bound(generics: &syn::Generics, lifetime: &str) -> syn::Generics { - let bound = syn::Lifetime::new(Term::intern(lifetime), Span::call_site()); + let bound = syn::Lifetime::new(Term::new(lifetime, Span::call_site())); let def = syn::LifetimeDef { attrs: Vec::new(), lifetime: bound, diff --git a/serde_derive/src/de.rs b/serde_derive/src/de.rs index cbdeb0a1..d058be43 100644 --- a/serde_derive/src/de.rs +++ b/serde_derive/src/de.rs @@ -181,8 +181,8 @@ enum BorrowedLifetimes { impl BorrowedLifetimes { fn de_lifetime(&self) -> syn::Lifetime { match *self { - BorrowedLifetimes::Borrowed(_) => syn::Lifetime::new(Term::intern("'de"), Span::call_site()), - BorrowedLifetimes::Static => syn::Lifetime::new(Term::intern("'static"), Span::call_site()), + BorrowedLifetimes::Borrowed(_) => syn::Lifetime::new(Term::new("'de", Span::call_site())), + BorrowedLifetimes::Static => syn::Lifetime::new(Term::new("'static", Span::call_site())), } } @@ -190,7 +190,7 @@ impl BorrowedLifetimes { match *self { BorrowedLifetimes::Borrowed(ref bounds) => Some(syn::LifetimeDef { attrs: Vec::new(), - lifetime: syn::Lifetime::new(Term::intern("'de"), Span::call_site()), + lifetime: syn::Lifetime::new(Term::new("'de", Span::call_site())), colon_token: None, bounds: bounds.iter().cloned().collect(), }), @@ -2721,7 +2721,7 @@ impl<'a> ToTokens for DeTypeGenerics<'a> { if self.0.borrowed.de_lifetime_def().is_some() { let def = syn::LifetimeDef { attrs: Vec::new(), - lifetime: syn::Lifetime::new(Term::intern("'de"), Span::call_site()), + lifetime: syn::Lifetime::new(Term::new("'de", Span::call_site())), colon_token: None, bounds: Punctuated::new(), }; @@ -2747,7 +2747,7 @@ impl<'a> ToTokens for InPlaceTypeGenerics<'a> { if self.0.borrowed.de_lifetime_def().is_some() { let def = syn::LifetimeDef { attrs: Vec::new(), - lifetime: syn::Lifetime::new(Term::intern("'de"), Span::call_site()), + lifetime: syn::Lifetime::new(Term::new("'de", Span::call_site())), colon_token: None, bounds: Punctuated::new(), }; @@ -2772,7 +2772,7 @@ impl<'a> DeTypeGenerics<'a> { fn place_lifetime() -> syn::LifetimeDef { syn::LifetimeDef { attrs: Vec::new(), - lifetime: syn::Lifetime::new(Term::intern("'place"), Span::call_site()), + lifetime: syn::Lifetime::new(Term::new("'place", Span::call_site())), colon_token: None, bounds: Punctuated::new(), } diff --git a/serde_derive_internals/Cargo.toml b/serde_derive_internals/Cargo.toml index ea185ef9..199b74d2 100644 --- a/serde_derive_internals/Cargo.toml +++ b/serde_derive_internals/Cargo.toml @@ -12,8 +12,8 @@ readme = "README.md" include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] [dependencies] -proc-macro2 = "0.2" -syn = { version = "0.12", default-features = false, features = ["derive", "parsing", "clone-impls"] } +proc-macro2 = "0.3" +syn = { version = "0.13", default-features = false, features = ["derive", "parsing", "clone-impls"] } [badges] travis-ci = { repository = "serde-rs/serde" } diff --git a/serde_derive_internals/src/attr.rs b/serde_derive_internals/src/attr.rs index b061b8cb..e4cea6d2 100644 --- a/serde_derive_internals/src/attr.rs +++ b/serde_derive_internals/src/attr.rs @@ -15,7 +15,7 @@ use syn::punctuated::Punctuated; use syn::synom::{Synom, ParseError}; use std::collections::BTreeSet; use std::str::FromStr; -use proc_macro2::{Span, TokenStream, TokenNode, TokenTree}; +use proc_macro2::{Span, TokenStream, TokenTree, Group}; // This module handles parsing of `#[serde(...)]` attributes. The entrypoints // are `attr::Container::from_ast`, `attr::Variant::from_ast`, and @@ -1160,7 +1160,7 @@ fn parse_lit_into_where( return Ok(Vec::new()); } - let where_string = syn::LitStr::new(&format!("where {}", string.value()), string.span); + let where_string = syn::LitStr::new(&format!("where {}", string.value()), string.span()); parse_lit_str::(&where_string) .map(|wh| wh.predicates.into_iter().collect()) @@ -1410,21 +1410,17 @@ where fn spanned_tokens(s: &syn::LitStr) -> Result { let stream = try!(syn::parse_str(&s.value())); - Ok(respan_token_stream(stream, s.span)) + Ok(respan_token_stream(stream, s.span())) } fn respan_token_stream(stream: TokenStream, span: Span) -> TokenStream { stream.into_iter().map(|token| respan_token_tree(token, span)).collect() } -fn respan_token_tree(token: TokenTree, span: Span) -> TokenTree { - TokenTree { - span: span, - kind: match token.kind { - TokenNode::Group(delimiter, nested) => { - TokenNode::Group(delimiter, respan_token_stream(nested, span)) - } - other => other, - }, +fn respan_token_tree(mut token: TokenTree, span: Span) -> TokenTree { + if let TokenTree::Group(ref mut g) = token { + *g = Group::new(g.delimiter(), respan_token_stream(g.stream().clone(), span)); } + token.set_span(span); + token } diff --git a/test_suite/Cargo.toml b/test_suite/Cargo.toml index 23a9fd79..5c0b65f3 100644 --- a/test_suite/Cargo.toml +++ b/test_suite/Cargo.toml @@ -9,7 +9,7 @@ unstable = ["serde/unstable", "compiletest_rs"] [dev-dependencies] fnv = "1.0" -proc-macro2 = "0.2" +proc-macro2 = "0.3" rustc-serialize = "0.3.16" serde = { path = "../serde", features = ["rc"] } serde_derive = { path = "../serde_derive", features = ["deserialize_in_place"] } diff --git a/test_suite/deps/Cargo.toml b/test_suite/deps/Cargo.toml index fbe2f2cd..46d39ece 100644 --- a/test_suite/deps/Cargo.toml +++ b/test_suite/deps/Cargo.toml @@ -9,3 +9,8 @@ publish = false [dependencies] serde = { path = "../../serde" } serde_derive = { path = "../../serde_derive" } + +[patch.crates-io] +proc-macro2 = { git = 'https://github.com/alexcrichton/proc-macro2', branch = 'v3' } +quote = { git = 'https://github.com/alexcrichton/quote', branch = 'v3' } +syn = { git = 'https://github.com/alexcrichton/syn', branch = 'v3' }