Use call_site in 'with' attribute

This commit is contained in:
David Tolnay
2018-01-09 20:34:29 -08:00
parent b313f947dc
commit ddc4b50d4d
3 changed files with 9 additions and 4 deletions
+6 -4
View File
@@ -8,12 +8,14 @@
use Ctxt;
use syn;
use syn::Ident;
use syn::Meta::{List, NameValue, Word};
use syn::NestedMeta::{Literal, Meta};
use syn::punctuated::Punctuated;
use syn::synom::Synom;
use std::collections::BTreeSet;
use std::str::FromStr;
use proc_macro2::Span;
// This module handles parsing of `#[serde(...)]` attributes. The entrypoints
// are `attr::Container::from_ast`, `attr::Variant::from_ast`, and
@@ -577,10 +579,10 @@ impl Variant {
Meta(NameValue(ref m)) if m.ident == "with" => {
if let Ok(path) = parse_lit_into_path(cx, m.ident.as_ref(), &m.lit) {
let mut ser_path = path.clone();
ser_path.segments.push("serialize".into());
ser_path.segments.push(Ident::new("serialize", Span::call_site()).into());
serialize_with.set(ser_path);
let mut de_path = path;
de_path.segments.push("deserialize".into());
de_path.segments.push(Ident::new("deserialize", Span::call_site()).into());
deserialize_with.set(de_path);
}
}
@@ -819,10 +821,10 @@ impl Field {
Meta(NameValue(ref m)) if m.ident == "with" => {
if let Ok(path) = parse_lit_into_path(cx, m.ident.as_ref(), &m.lit) {
let mut ser_path = path.clone();
ser_path.segments.push("serialize".into());
ser_path.segments.push(Ident::new("serialize", Span::call_site()).into());
serialize_with.set(ser_path);
let mut de_path = path;
de_path.segments.push("deserialize".into());
de_path.segments.push(Ident::new("deserialize", Span::call_site()).into());
deserialize_with.set(de_path);
}
}