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