mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-13 17:11:02 +00:00
Use call_site in 'with' attribute
This commit is contained in:
@@ -12,6 +12,7 @@ readme = "README.md"
|
|||||||
include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
|
include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
proc-macro2 = "0.2"
|
||||||
syn = { version = "0.12", default-features = false, features = ["derive", "parsing", "clone-impls"] }
|
syn = { version = "0.12", default-features = false, features = ["derive", "parsing", "clone-impls"] }
|
||||||
|
|
||||||
[badges]
|
[badges]
|
||||||
|
|||||||
@@ -8,12 +8,14 @@
|
|||||||
|
|
||||||
use Ctxt;
|
use Ctxt;
|
||||||
use syn;
|
use syn;
|
||||||
|
use syn::Ident;
|
||||||
use syn::Meta::{List, NameValue, Word};
|
use syn::Meta::{List, NameValue, Word};
|
||||||
use syn::NestedMeta::{Literal, Meta};
|
use syn::NestedMeta::{Literal, Meta};
|
||||||
use syn::punctuated::Punctuated;
|
use syn::punctuated::Punctuated;
|
||||||
use syn::synom::Synom;
|
use syn::synom::Synom;
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
use proc_macro2::Span;
|
||||||
|
|
||||||
// This module handles parsing of `#[serde(...)]` attributes. The entrypoints
|
// This module handles parsing of `#[serde(...)]` attributes. The entrypoints
|
||||||
// are `attr::Container::from_ast`, `attr::Variant::from_ast`, and
|
// are `attr::Container::from_ast`, `attr::Variant::from_ast`, and
|
||||||
@@ -577,10 +579,10 @@ impl Variant {
|
|||||||
Meta(NameValue(ref m)) if m.ident == "with" => {
|
Meta(NameValue(ref m)) if m.ident == "with" => {
|
||||||
if let Ok(path) = parse_lit_into_path(cx, m.ident.as_ref(), &m.lit) {
|
if let Ok(path) = parse_lit_into_path(cx, m.ident.as_ref(), &m.lit) {
|
||||||
let mut ser_path = path.clone();
|
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);
|
serialize_with.set(ser_path);
|
||||||
let mut de_path = 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);
|
deserialize_with.set(de_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -819,10 +821,10 @@ impl Field {
|
|||||||
Meta(NameValue(ref m)) if m.ident == "with" => {
|
Meta(NameValue(ref m)) if m.ident == "with" => {
|
||||||
if let Ok(path) = parse_lit_into_path(cx, m.ident.as_ref(), &m.lit) {
|
if let Ok(path) = parse_lit_into_path(cx, m.ident.as_ref(), &m.lit) {
|
||||||
let mut ser_path = path.clone();
|
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);
|
serialize_with.set(ser_path);
|
||||||
let mut de_path = 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);
|
deserialize_with.set(de_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate syn;
|
extern crate syn;
|
||||||
|
|
||||||
|
extern crate proc_macro2;
|
||||||
|
|
||||||
pub mod ast;
|
pub mod ast;
|
||||||
pub mod attr;
|
pub mod attr;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user