File tree Expand file tree Collapse file tree 1 file changed +20
-8
lines changed Expand file tree Collapse file tree 1 file changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -158,16 +158,28 @@ fn generate_class_bindings(
158
158
}
159
159
}
160
160
161
+ #[ rustfmt:: skip]
161
162
fn rust_safe_name ( name : & str ) -> proc_macro2:: Ident {
163
+ // Keywords obtained from https://doc.rust-lang.org/reference/keywords.html
162
164
match name {
163
- "use" => format_ident ! ( "_use" ) ,
164
- "type" => format_ident ! ( "_type" ) ,
165
- "loop" => format_ident ! ( "_loop" ) ,
166
- "in" => format_ident ! ( "_in" ) ,
167
- "override" => format_ident ! ( "_override" ) ,
168
- "where" => format_ident ! ( "_where" ) ,
169
- "enum" => format_ident ! ( "_enum" ) ,
170
- name => format_ident ! ( "{}" , name) ,
165
+ // Lexer 2015
166
+ "as" | "break" | "const" | "continue" | "crate" | "else" | "enum" | "extern" | "false" | "fn" | "for" |
167
+ "if" | "impl" | "in" | "let" | "loop" | "match" | "mod" | "move" | "mut" | "pub" | "ref" | "return" |
168
+ "self" | "Self" | "static" | "struct" | "super" | "trait" | "true" | "type" | "unsafe" | "use" |
169
+ "where" | "while" |
170
+
171
+ // Lexer 2018
172
+ "async" | "await" | "dyn" |
173
+
174
+ // Lexer 2018+
175
+ "try" |
176
+
177
+ // Reserved words
178
+ "abstract" | "become" | "box" | "do" | "final" | "macro" | "override" | "priv" | "typeof" |
179
+ "unsized" | "virtual" | "yield"
180
+ => format_ident ! ( "{}_" , name) ,
181
+
182
+ _ => format_ident ! ( "{}" , name)
171
183
}
172
184
}
173
185
You can’t perform that action at this time.
0 commit comments