Avoid breaking keywords in labels.

Keywords such as `ref` previously lead to labels such as `__#ref__value`.
This should be `__ref__value`.
This commit is contained in:
marcelbuesing
2020-09-01 08:09:08 +02:00
parent 6e2930e2df
commit 798455faa8
3 changed files with 40 additions and 1 deletions

View File

@@ -3,6 +3,7 @@ use heck::CamelCase;
use proc_macro2::Span;
use proc_macro2::{Ident, TokenStream};
use std::fmt;
use syn::ext::IdentExt;
use syn::spanned::Spanned;
use syn::Type::Path;
@@ -43,7 +44,7 @@ impl YaSerdeField {
.syn_field
.ident
.clone()
.map(|ident| syn::Ident::new(&format!("__{}_value", ident.to_string()), ident.span()))
.map(|ident| syn::Ident::new(&format!("__{}_value", ident.unraw()), ident.span()))
}
pub fn renamed_label_without_namespace(&self) -> String {