Add support for empty enum variants and enum variants that start with a digit

This commit is contained in:
Anton Danilkin
2018-08-04 00:19:06 +03:00
committed by Alex Crichton
parent 61b3d52dc9
commit 07b4ef5838
9 changed files with 9 additions and 2 deletions

View File

@ -30,6 +30,8 @@ pub fn rust_ident(name: &str) -> Ident {
panic!("tried to create empty Ident (from \"\")");
} else if is_rust_keyword(name) {
Ident::new(&format!("{}_", name), proc_macro2::Span::call_site())
} else if name.chars().next().unwrap().is_ascii_digit() {
Ident::new(&format!("N{}", name), proc_macro2::Span::call_site())
} else {
raw_ident(name)
}