Use call_site as the span of unnamed member access
This commit is contained in:
parent
16bc9fb99e
commit
b313f947dc
@ -6,7 +6,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use syn::{self, Ident, Member};
|
||||
use syn::{self, Ident, Index, Member};
|
||||
use syn::punctuated::Punctuated;
|
||||
use quote::{ToTokens, Tokens};
|
||||
use proc_macro2::{Literal, Span, Term};
|
||||
@ -624,7 +624,10 @@ fn deserialize_seq_in_place(
|
||||
let field_name = field
|
||||
.ident
|
||||
.map(Member::Named)
|
||||
.unwrap_or_else(|| Member::Unnamed(field_index.into()));
|
||||
.unwrap_or_else(|| Member::Unnamed(Index {
|
||||
index: field_index as u32,
|
||||
span: Span::call_site(),
|
||||
}));
|
||||
|
||||
if field.attrs.skip_deserializing() {
|
||||
let default = Expr(expr_is_missing(field, cattrs));
|
||||
@ -2314,7 +2317,10 @@ fn wrap_deserialize_variant_with(
|
||||
let (wrapper, wrapper_ty) =
|
||||
wrap_deserialize_with(params, "e!((#(#field_tys),*)), deserialize_with);
|
||||
|
||||
let field_access = (0..variant.fields.len()).map(|n| Member::Unnamed(n.into()));
|
||||
let field_access = (0..variant.fields.len()).map(|n| Member::Unnamed(Index {
|
||||
index: n as u32,
|
||||
span: Span::call_site(),
|
||||
}));
|
||||
let unwrap_fn = match variant.style {
|
||||
Style::Struct => {
|
||||
let field_idents = variant
|
||||
|
@ -6,7 +6,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use syn::{self, Ident, Member};
|
||||
use syn::{self, Ident, Index, Member};
|
||||
use quote::Tokens;
|
||||
use proc_macro2::Span;
|
||||
|
||||
@ -202,7 +202,10 @@ fn serialize_newtype_struct(
|
||||
) -> Fragment {
|
||||
let type_name = cattrs.name().serialize_name();
|
||||
|
||||
let mut field_expr = get_member(params, field, &Member::Unnamed(0.into()));
|
||||
let mut field_expr = get_member(params, field, &Member::Unnamed(Index {
|
||||
index: 0,
|
||||
span: Span::call_site(),
|
||||
}));
|
||||
if let Some(path) = field.attrs.serialize_with() {
|
||||
field_expr = wrap_serialize_field_with(params, field.ty, path, &field_expr);
|
||||
}
|
||||
@ -817,7 +820,10 @@ fn serialize_tuple_struct_visitor(
|
||||
let id = Ident::new(&format!("__field{}", i), Span::def_site());
|
||||
quote!(#id)
|
||||
} else {
|
||||
get_member(params, field, &Member::Unnamed(i.into()))
|
||||
get_member(params, field, &Member::Unnamed(Index {
|
||||
index: i as u32,
|
||||
span: Span::call_site(),
|
||||
}))
|
||||
};
|
||||
|
||||
let skip = field
|
||||
@ -940,7 +946,10 @@ fn wrap_serialize_with(
|
||||
};
|
||||
let (wrapper_impl_generics, wrapper_ty_generics, _) = wrapper_generics.split_for_impl();
|
||||
|
||||
let field_access = (0..field_exprs.len()).map(|n| Member::Unnamed(n.into()));
|
||||
let field_access = (0..field_exprs.len()).map(|n| Member::Unnamed(Index {
|
||||
index: n as u32,
|
||||
span: Span::call_site(),
|
||||
}));
|
||||
|
||||
quote!({
|
||||
struct __SerializeWith #wrapper_impl_generics #where_clause {
|
||||
|
@ -9,6 +9,7 @@ unstable = ["serde/unstable", "compiletest_rs"]
|
||||
|
||||
[dev-dependencies]
|
||||
fnv = "1.0"
|
||||
proc-macro2 = "0.2"
|
||||
rustc-serialize = "0.3.16"
|
||||
serde = { path = "../serde", features = ["rc"] }
|
||||
serde_derive = { path = "../serde_derive", features = ["deserialize_in_place"] }
|
||||
|
Loading…
Reference in New Issue
Block a user