fix deserialize_struct passing the original field names instead of the renamed ones

This commit is contained in:
Oliver Schneider 2017-01-12 20:17:02 +01:00
parent 110d36fa14
commit abe305dbfe

View File

@ -717,6 +717,7 @@ fn deserialize_struct_visitor(
let field_exprs = fields.iter() let field_exprs = fields.iter()
.map(|field| field.attrs.name().deserialize_name()) .map(|field| field.attrs.name().deserialize_name())
.collect(); .collect();
let field_names = field_exprs.clone();
let field_visitor = deserialize_field_visitor( let field_visitor = deserialize_field_visitor(
field_exprs, field_exprs,
@ -732,10 +733,6 @@ fn deserialize_struct_visitor(
item_attrs, item_attrs,
); );
let field_names = fields.iter().map(|field| {
field.ident.clone().expect("struct contains unnamed field").to_string()
});
let fields_stmt = quote! { let fields_stmt = quote! {
const FIELDS: &'static [&'static str] = &[ #(#field_names),* ]; const FIELDS: &'static [&'static str] = &[ #(#field_names),* ];
}; };