Skip to content

Commit

Permalink
Merge pull request Marwes#21 from presciense/master
Browse files Browse the repository at this point in the history
Fix: All current and reserved keywords
  • Loading branch information
Marwes committed Jul 6, 2019
2 parents 7821561 + f96dad3 commit 939cb80
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/lib.rs
Expand Up @@ -79,10 +79,14 @@ fn replace_invalid_identifier_chars(s: &str) -> String {
}

fn rename_keyword(prefix: &str, s: &str) -> Option<TokenStream> {
if ["type", "struct", "enum", "as"]
.iter()
.any(|&keyword| keyword == s)
{
let keywords = [
"as", "break", "const", "continue", "crate", "else", "enum", "extern", "false", "fn",
"for", "if", "impl", "in", "let", "loop", "match", "mod", "move", "mut", "pub", "ref",
"return", "self", "static", "struct", "super", "trait", "true", "type", "unsafe", "use",
"where", "while", "abstract", "become", "box", "do", "final", "macro", "override", "priv",
"typeof", "unsized", "virtual", "yield", "async", "await", "try",
];
if keywords.iter().any(|&keyword| keyword == s) {
let n = syn::Ident::new(&format!("{}_", s), Span::call_site());
let prefix = syn::Ident::new(prefix, Span::call_site());
Some(quote! {
Expand Down

0 comments on commit 939cb80

Please sign in to comment.