aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_parser/src/syntax_kind.rs16
-rw-r--r--crates/ra_parser/src/syntax_kind/generated.rs248
-rw-r--r--crates/ra_tools/src/boilerplate_gen.rs30
3 files changed, 10 insertions, 284 deletions
diff --git a/crates/ra_parser/src/syntax_kind.rs b/crates/ra_parser/src/syntax_kind.rs
index 00faa7799..3efcfa403 100644
--- a/crates/ra_parser/src/syntax_kind.rs
+++ b/crates/ra_parser/src/syntax_kind.rs
@@ -1,19 +1,19 @@
1#[macro_use] 1#[macro_use]
2mod generated; 2mod generated;
3 3
4use std::fmt;
5
6pub use self::generated::SyntaxKind; 4pub use self::generated::SyntaxKind;
7 5
8impl fmt::Debug for SyntaxKind { 6impl From<u16> for SyntaxKind {
9 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 7 fn from(d: u16) -> SyntaxKind {
10 let name = self.info().name; 8 assert!(d <= (SyntaxKind::__LAST as u16));
11 f.write_str(name) 9 unsafe { std::mem::transmute::<u16, SyntaxKind>(d) }
12 } 10 }
13} 11}
14 12
15pub(crate) struct SyntaxInfo { 13impl From<SyntaxKind> for u16 {
16 pub name: &'static str, 14 fn from(k: SyntaxKind) -> u16 {
15 k as u16
16 }
17} 17}
18 18
19impl SyntaxKind { 19impl SyntaxKind {
diff --git a/crates/ra_parser/src/syntax_kind/generated.rs b/crates/ra_parser/src/syntax_kind/generated.rs
index 415839cb5..3a67d7ddd 100644
--- a/crates/ra_parser/src/syntax_kind/generated.rs
+++ b/crates/ra_parser/src/syntax_kind/generated.rs
@@ -1,9 +1,8 @@
1// Generated file, do not edit by hand, see `crate/ra_tools/src/codegen` 1// Generated file, do not edit by hand, see `crate/ra_tools/src/codegen`
2 2
3#![allow(bad_style, missing_docs, unreachable_pub)] 3#![allow(bad_style, missing_docs, unreachable_pub)]
4use super::SyntaxInfo;
5#[doc = r" The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`."] 4#[doc = r" The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`."]
6#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] 5#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
7#[repr(u16)] 6#[repr(u16)]
8pub enum SyntaxKind { 7pub enum SyntaxKind {
9 #[doc(hidden)] 8 #[doc(hidden)]
@@ -241,17 +240,6 @@ pub enum SyntaxKind {
241 __LAST, 240 __LAST,
242} 241}
243use self::SyntaxKind::*; 242use self::SyntaxKind::*;
244impl From<u16> for SyntaxKind {
245 fn from(d: u16) -> SyntaxKind {
246 assert!(d <= (__LAST as u16));
247 unsafe { std::mem::transmute::<u16, SyntaxKind>(d) }
248 }
249}
250impl From<SyntaxKind> for u16 {
251 fn from(k: SyntaxKind) -> u16 {
252 k as u16
253 }
254}
255impl SyntaxKind { 243impl SyntaxKind {
256 pub fn is_keyword(self) -> bool { 244 pub fn is_keyword(self) -> bool {
257 match self { 245 match self {
@@ -282,240 +270,6 @@ impl SyntaxKind {
282 _ => false, 270 _ => false,
283 } 271 }
284 } 272 }
285 pub(crate) fn info(self) -> &'static SyntaxInfo {
286 match self {
287 SEMI => &SyntaxInfo { name: stringify!(SEMI) },
288 COMMA => &SyntaxInfo { name: stringify!(COMMA) },
289 L_PAREN => &SyntaxInfo { name: stringify!(L_PAREN) },
290 R_PAREN => &SyntaxInfo { name: stringify!(R_PAREN) },
291 L_CURLY => &SyntaxInfo { name: stringify!(L_CURLY) },
292 R_CURLY => &SyntaxInfo { name: stringify!(R_CURLY) },
293 L_BRACK => &SyntaxInfo { name: stringify!(L_BRACK) },
294 R_BRACK => &SyntaxInfo { name: stringify!(R_BRACK) },
295 L_ANGLE => &SyntaxInfo { name: stringify!(L_ANGLE) },
296 R_ANGLE => &SyntaxInfo { name: stringify!(R_ANGLE) },
297 AT => &SyntaxInfo { name: stringify!(AT) },
298 POUND => &SyntaxInfo { name: stringify!(POUND) },
299 TILDE => &SyntaxInfo { name: stringify!(TILDE) },
300 QUESTION => &SyntaxInfo { name: stringify!(QUESTION) },
301 DOLLAR => &SyntaxInfo { name: stringify!(DOLLAR) },
302 AMP => &SyntaxInfo { name: stringify!(AMP) },
303 PIPE => &SyntaxInfo { name: stringify!(PIPE) },
304 PLUS => &SyntaxInfo { name: stringify!(PLUS) },
305 STAR => &SyntaxInfo { name: stringify!(STAR) },
306 SLASH => &SyntaxInfo { name: stringify!(SLASH) },
307 CARET => &SyntaxInfo { name: stringify!(CARET) },
308 PERCENT => &SyntaxInfo { name: stringify!(PERCENT) },
309 UNDERSCORE => &SyntaxInfo { name: stringify!(UNDERSCORE) },
310 DOT => &SyntaxInfo { name: stringify!(DOT) },
311 DOTDOT => &SyntaxInfo { name: stringify!(DOTDOT) },
312 DOTDOTDOT => &SyntaxInfo { name: stringify!(DOTDOTDOT) },
313 DOTDOTEQ => &SyntaxInfo { name: stringify!(DOTDOTEQ) },
314 COLON => &SyntaxInfo { name: stringify!(COLON) },
315 COLONCOLON => &SyntaxInfo { name: stringify!(COLONCOLON) },
316 EQ => &SyntaxInfo { name: stringify!(EQ) },
317 EQEQ => &SyntaxInfo { name: stringify!(EQEQ) },
318 FAT_ARROW => &SyntaxInfo { name: stringify!(FAT_ARROW) },
319 EXCL => &SyntaxInfo { name: stringify!(EXCL) },
320 NEQ => &SyntaxInfo { name: stringify!(NEQ) },
321 MINUS => &SyntaxInfo { name: stringify!(MINUS) },
322 THIN_ARROW => &SyntaxInfo { name: stringify!(THIN_ARROW) },
323 LTEQ => &SyntaxInfo { name: stringify!(LTEQ) },
324 GTEQ => &SyntaxInfo { name: stringify!(GTEQ) },
325 PLUSEQ => &SyntaxInfo { name: stringify!(PLUSEQ) },
326 MINUSEQ => &SyntaxInfo { name: stringify!(MINUSEQ) },
327 PIPEEQ => &SyntaxInfo { name: stringify!(PIPEEQ) },
328 AMPEQ => &SyntaxInfo { name: stringify!(AMPEQ) },
329 CARETEQ => &SyntaxInfo { name: stringify!(CARETEQ) },
330 SLASHEQ => &SyntaxInfo { name: stringify!(SLASHEQ) },
331 STAREQ => &SyntaxInfo { name: stringify!(STAREQ) },
332 PERCENTEQ => &SyntaxInfo { name: stringify!(PERCENTEQ) },
333 AMPAMP => &SyntaxInfo { name: stringify!(AMPAMP) },
334 PIPEPIPE => &SyntaxInfo { name: stringify!(PIPEPIPE) },
335 SHL => &SyntaxInfo { name: stringify!(SHL) },
336 SHR => &SyntaxInfo { name: stringify!(SHR) },
337 SHLEQ => &SyntaxInfo { name: stringify!(SHLEQ) },
338 SHREQ => &SyntaxInfo { name: stringify!(SHREQ) },
339 ASYNC_KW => &SyntaxInfo { name: stringify!(ASYNC_KW) },
340 USE_KW => &SyntaxInfo { name: stringify!(USE_KW) },
341 FN_KW => &SyntaxInfo { name: stringify!(FN_KW) },
342 STRUCT_KW => &SyntaxInfo { name: stringify!(STRUCT_KW) },
343 ENUM_KW => &SyntaxInfo { name: stringify!(ENUM_KW) },
344 TRAIT_KW => &SyntaxInfo { name: stringify!(TRAIT_KW) },
345 IMPL_KW => &SyntaxInfo { name: stringify!(IMPL_KW) },
346 DYN_KW => &SyntaxInfo { name: stringify!(DYN_KW) },
347 TRUE_KW => &SyntaxInfo { name: stringify!(TRUE_KW) },
348 FALSE_KW => &SyntaxInfo { name: stringify!(FALSE_KW) },
349 AS_KW => &SyntaxInfo { name: stringify!(AS_KW) },
350 EXTERN_KW => &SyntaxInfo { name: stringify!(EXTERN_KW) },
351 CRATE_KW => &SyntaxInfo { name: stringify!(CRATE_KW) },
352 MOD_KW => &SyntaxInfo { name: stringify!(MOD_KW) },
353 PUB_KW => &SyntaxInfo { name: stringify!(PUB_KW) },
354 SELF_KW => &SyntaxInfo { name: stringify!(SELF_KW) },
355 SUPER_KW => &SyntaxInfo { name: stringify!(SUPER_KW) },
356 IN_KW => &SyntaxInfo { name: stringify!(IN_KW) },
357 WHERE_KW => &SyntaxInfo { name: stringify!(WHERE_KW) },
358 FOR_KW => &SyntaxInfo { name: stringify!(FOR_KW) },
359 LOOP_KW => &SyntaxInfo { name: stringify!(LOOP_KW) },
360 WHILE_KW => &SyntaxInfo { name: stringify!(WHILE_KW) },
361 CONTINUE_KW => &SyntaxInfo { name: stringify!(CONTINUE_KW) },
362 BREAK_KW => &SyntaxInfo { name: stringify!(BREAK_KW) },
363 IF_KW => &SyntaxInfo { name: stringify!(IF_KW) },
364 ELSE_KW => &SyntaxInfo { name: stringify!(ELSE_KW) },
365 MATCH_KW => &SyntaxInfo { name: stringify!(MATCH_KW) },
366 CONST_KW => &SyntaxInfo { name: stringify!(CONST_KW) },
367 STATIC_KW => &SyntaxInfo { name: stringify!(STATIC_KW) },
368 MUT_KW => &SyntaxInfo { name: stringify!(MUT_KW) },
369 UNSAFE_KW => &SyntaxInfo { name: stringify!(UNSAFE_KW) },
370 TYPE_KW => &SyntaxInfo { name: stringify!(TYPE_KW) },
371 REF_KW => &SyntaxInfo { name: stringify!(REF_KW) },
372 LET_KW => &SyntaxInfo { name: stringify!(LET_KW) },
373 MOVE_KW => &SyntaxInfo { name: stringify!(MOVE_KW) },
374 RETURN_KW => &SyntaxInfo { name: stringify!(RETURN_KW) },
375 TRY_KW => &SyntaxInfo { name: stringify!(TRY_KW) },
376 BOX_KW => &SyntaxInfo { name: stringify!(BOX_KW) },
377 AWAIT_KW => &SyntaxInfo { name: stringify!(AWAIT_KW) },
378 AUTO_KW => &SyntaxInfo { name: stringify!(AUTO_KW) },
379 DEFAULT_KW => &SyntaxInfo { name: stringify!(DEFAULT_KW) },
380 EXISTENTIAL_KW => &SyntaxInfo { name: stringify!(EXISTENTIAL_KW) },
381 UNION_KW => &SyntaxInfo { name: stringify!(UNION_KW) },
382 INT_NUMBER => &SyntaxInfo { name: stringify!(INT_NUMBER) },
383 FLOAT_NUMBER => &SyntaxInfo { name: stringify!(FLOAT_NUMBER) },
384 CHAR => &SyntaxInfo { name: stringify!(CHAR) },
385 BYTE => &SyntaxInfo { name: stringify!(BYTE) },
386 STRING => &SyntaxInfo { name: stringify!(STRING) },
387 RAW_STRING => &SyntaxInfo { name: stringify!(RAW_STRING) },
388 BYTE_STRING => &SyntaxInfo { name: stringify!(BYTE_STRING) },
389 RAW_BYTE_STRING => &SyntaxInfo { name: stringify!(RAW_BYTE_STRING) },
390 ERROR => &SyntaxInfo { name: stringify!(ERROR) },
391 IDENT => &SyntaxInfo { name: stringify!(IDENT) },
392 WHITESPACE => &SyntaxInfo { name: stringify!(WHITESPACE) },
393 LIFETIME => &SyntaxInfo { name: stringify!(LIFETIME) },
394 COMMENT => &SyntaxInfo { name: stringify!(COMMENT) },
395 SHEBANG => &SyntaxInfo { name: stringify!(SHEBANG) },
396 L_DOLLAR => &SyntaxInfo { name: stringify!(L_DOLLAR) },
397 R_DOLLAR => &SyntaxInfo { name: stringify!(R_DOLLAR) },
398 SOURCE_FILE => &SyntaxInfo { name: stringify!(SOURCE_FILE) },
399 STRUCT_DEF => &SyntaxInfo { name: stringify!(STRUCT_DEF) },
400 ENUM_DEF => &SyntaxInfo { name: stringify!(ENUM_DEF) },
401 FN_DEF => &SyntaxInfo { name: stringify!(FN_DEF) },
402 RET_TYPE => &SyntaxInfo { name: stringify!(RET_TYPE) },
403 EXTERN_CRATE_ITEM => &SyntaxInfo { name: stringify!(EXTERN_CRATE_ITEM) },
404 MODULE => &SyntaxInfo { name: stringify!(MODULE) },
405 USE_ITEM => &SyntaxInfo { name: stringify!(USE_ITEM) },
406 STATIC_DEF => &SyntaxInfo { name: stringify!(STATIC_DEF) },
407 CONST_DEF => &SyntaxInfo { name: stringify!(CONST_DEF) },
408 TRAIT_DEF => &SyntaxInfo { name: stringify!(TRAIT_DEF) },
409 IMPL_BLOCK => &SyntaxInfo { name: stringify!(IMPL_BLOCK) },
410 TYPE_ALIAS_DEF => &SyntaxInfo { name: stringify!(TYPE_ALIAS_DEF) },
411 MACRO_CALL => &SyntaxInfo { name: stringify!(MACRO_CALL) },
412 TOKEN_TREE => &SyntaxInfo { name: stringify!(TOKEN_TREE) },
413 PAREN_TYPE => &SyntaxInfo { name: stringify!(PAREN_TYPE) },
414 TUPLE_TYPE => &SyntaxInfo { name: stringify!(TUPLE_TYPE) },
415 NEVER_TYPE => &SyntaxInfo { name: stringify!(NEVER_TYPE) },
416 PATH_TYPE => &SyntaxInfo { name: stringify!(PATH_TYPE) },
417 POINTER_TYPE => &SyntaxInfo { name: stringify!(POINTER_TYPE) },
418 ARRAY_TYPE => &SyntaxInfo { name: stringify!(ARRAY_TYPE) },
419 SLICE_TYPE => &SyntaxInfo { name: stringify!(SLICE_TYPE) },
420 REFERENCE_TYPE => &SyntaxInfo { name: stringify!(REFERENCE_TYPE) },
421 PLACEHOLDER_TYPE => &SyntaxInfo { name: stringify!(PLACEHOLDER_TYPE) },
422 FN_POINTER_TYPE => &SyntaxInfo { name: stringify!(FN_POINTER_TYPE) },
423 FOR_TYPE => &SyntaxInfo { name: stringify!(FOR_TYPE) },
424 IMPL_TRAIT_TYPE => &SyntaxInfo { name: stringify!(IMPL_TRAIT_TYPE) },
425 DYN_TRAIT_TYPE => &SyntaxInfo { name: stringify!(DYN_TRAIT_TYPE) },
426 REF_PAT => &SyntaxInfo { name: stringify!(REF_PAT) },
427 BIND_PAT => &SyntaxInfo { name: stringify!(BIND_PAT) },
428 PLACEHOLDER_PAT => &SyntaxInfo { name: stringify!(PLACEHOLDER_PAT) },
429 PATH_PAT => &SyntaxInfo { name: stringify!(PATH_PAT) },
430 STRUCT_PAT => &SyntaxInfo { name: stringify!(STRUCT_PAT) },
431 FIELD_PAT_LIST => &SyntaxInfo { name: stringify!(FIELD_PAT_LIST) },
432 FIELD_PAT => &SyntaxInfo { name: stringify!(FIELD_PAT) },
433 TUPLE_STRUCT_PAT => &SyntaxInfo { name: stringify!(TUPLE_STRUCT_PAT) },
434 TUPLE_PAT => &SyntaxInfo { name: stringify!(TUPLE_PAT) },
435 SLICE_PAT => &SyntaxInfo { name: stringify!(SLICE_PAT) },
436 RANGE_PAT => &SyntaxInfo { name: stringify!(RANGE_PAT) },
437 LITERAL_PAT => &SyntaxInfo { name: stringify!(LITERAL_PAT) },
438 TUPLE_EXPR => &SyntaxInfo { name: stringify!(TUPLE_EXPR) },
439 ARRAY_EXPR => &SyntaxInfo { name: stringify!(ARRAY_EXPR) },
440 PAREN_EXPR => &SyntaxInfo { name: stringify!(PAREN_EXPR) },
441 PATH_EXPR => &SyntaxInfo { name: stringify!(PATH_EXPR) },
442 LAMBDA_EXPR => &SyntaxInfo { name: stringify!(LAMBDA_EXPR) },
443 IF_EXPR => &SyntaxInfo { name: stringify!(IF_EXPR) },
444 WHILE_EXPR => &SyntaxInfo { name: stringify!(WHILE_EXPR) },
445 CONDITION => &SyntaxInfo { name: stringify!(CONDITION) },
446 LOOP_EXPR => &SyntaxInfo { name: stringify!(LOOP_EXPR) },
447 FOR_EXPR => &SyntaxInfo { name: stringify!(FOR_EXPR) },
448 CONTINUE_EXPR => &SyntaxInfo { name: stringify!(CONTINUE_EXPR) },
449 BREAK_EXPR => &SyntaxInfo { name: stringify!(BREAK_EXPR) },
450 LABEL => &SyntaxInfo { name: stringify!(LABEL) },
451 BLOCK_EXPR => &SyntaxInfo { name: stringify!(BLOCK_EXPR) },
452 RETURN_EXPR => &SyntaxInfo { name: stringify!(RETURN_EXPR) },
453 MATCH_EXPR => &SyntaxInfo { name: stringify!(MATCH_EXPR) },
454 MATCH_ARM_LIST => &SyntaxInfo { name: stringify!(MATCH_ARM_LIST) },
455 MATCH_ARM => &SyntaxInfo { name: stringify!(MATCH_ARM) },
456 MATCH_GUARD => &SyntaxInfo { name: stringify!(MATCH_GUARD) },
457 STRUCT_LIT => &SyntaxInfo { name: stringify!(STRUCT_LIT) },
458 NAMED_FIELD_LIST => &SyntaxInfo { name: stringify!(NAMED_FIELD_LIST) },
459 NAMED_FIELD => &SyntaxInfo { name: stringify!(NAMED_FIELD) },
460 TRY_BLOCK_EXPR => &SyntaxInfo { name: stringify!(TRY_BLOCK_EXPR) },
461 BOX_EXPR => &SyntaxInfo { name: stringify!(BOX_EXPR) },
462 CALL_EXPR => &SyntaxInfo { name: stringify!(CALL_EXPR) },
463 INDEX_EXPR => &SyntaxInfo { name: stringify!(INDEX_EXPR) },
464 METHOD_CALL_EXPR => &SyntaxInfo { name: stringify!(METHOD_CALL_EXPR) },
465 FIELD_EXPR => &SyntaxInfo { name: stringify!(FIELD_EXPR) },
466 AWAIT_EXPR => &SyntaxInfo { name: stringify!(AWAIT_EXPR) },
467 TRY_EXPR => &SyntaxInfo { name: stringify!(TRY_EXPR) },
468 CAST_EXPR => &SyntaxInfo { name: stringify!(CAST_EXPR) },
469 REF_EXPR => &SyntaxInfo { name: stringify!(REF_EXPR) },
470 PREFIX_EXPR => &SyntaxInfo { name: stringify!(PREFIX_EXPR) },
471 RANGE_EXPR => &SyntaxInfo { name: stringify!(RANGE_EXPR) },
472 BIN_EXPR => &SyntaxInfo { name: stringify!(BIN_EXPR) },
473 BLOCK => &SyntaxInfo { name: stringify!(BLOCK) },
474 EXTERN_BLOCK => &SyntaxInfo { name: stringify!(EXTERN_BLOCK) },
475 EXTERN_ITEM_LIST => &SyntaxInfo { name: stringify!(EXTERN_ITEM_LIST) },
476 ENUM_VARIANT => &SyntaxInfo { name: stringify!(ENUM_VARIANT) },
477 NAMED_FIELD_DEF_LIST => &SyntaxInfo { name: stringify!(NAMED_FIELD_DEF_LIST) },
478 NAMED_FIELD_DEF => &SyntaxInfo { name: stringify!(NAMED_FIELD_DEF) },
479 POS_FIELD_DEF_LIST => &SyntaxInfo { name: stringify!(POS_FIELD_DEF_LIST) },
480 POS_FIELD_DEF => &SyntaxInfo { name: stringify!(POS_FIELD_DEF) },
481 ENUM_VARIANT_LIST => &SyntaxInfo { name: stringify!(ENUM_VARIANT_LIST) },
482 ITEM_LIST => &SyntaxInfo { name: stringify!(ITEM_LIST) },
483 ATTR => &SyntaxInfo { name: stringify!(ATTR) },
484 META_ITEM => &SyntaxInfo { name: stringify!(META_ITEM) },
485 USE_TREE => &SyntaxInfo { name: stringify!(USE_TREE) },
486 USE_TREE_LIST => &SyntaxInfo { name: stringify!(USE_TREE_LIST) },
487 PATH => &SyntaxInfo { name: stringify!(PATH) },
488 PATH_SEGMENT => &SyntaxInfo { name: stringify!(PATH_SEGMENT) },
489 LITERAL => &SyntaxInfo { name: stringify!(LITERAL) },
490 ALIAS => &SyntaxInfo { name: stringify!(ALIAS) },
491 VISIBILITY => &SyntaxInfo { name: stringify!(VISIBILITY) },
492 WHERE_CLAUSE => &SyntaxInfo { name: stringify!(WHERE_CLAUSE) },
493 WHERE_PRED => &SyntaxInfo { name: stringify!(WHERE_PRED) },
494 ABI => &SyntaxInfo { name: stringify!(ABI) },
495 NAME => &SyntaxInfo { name: stringify!(NAME) },
496 NAME_REF => &SyntaxInfo { name: stringify!(NAME_REF) },
497 LET_STMT => &SyntaxInfo { name: stringify!(LET_STMT) },
498 EXPR_STMT => &SyntaxInfo { name: stringify!(EXPR_STMT) },
499 TYPE_PARAM_LIST => &SyntaxInfo { name: stringify!(TYPE_PARAM_LIST) },
500 LIFETIME_PARAM => &SyntaxInfo { name: stringify!(LIFETIME_PARAM) },
501 TYPE_PARAM => &SyntaxInfo { name: stringify!(TYPE_PARAM) },
502 TYPE_ARG_LIST => &SyntaxInfo { name: stringify!(TYPE_ARG_LIST) },
503 LIFETIME_ARG => &SyntaxInfo { name: stringify!(LIFETIME_ARG) },
504 TYPE_ARG => &SyntaxInfo { name: stringify!(TYPE_ARG) },
505 ASSOC_TYPE_ARG => &SyntaxInfo { name: stringify!(ASSOC_TYPE_ARG) },
506 PARAM_LIST => &SyntaxInfo { name: stringify!(PARAM_LIST) },
507 PARAM => &SyntaxInfo { name: stringify!(PARAM) },
508 SELF_PARAM => &SyntaxInfo { name: stringify!(SELF_PARAM) },
509 ARG_LIST => &SyntaxInfo { name: stringify!(ARG_LIST) },
510 TYPE_BOUND => &SyntaxInfo { name: stringify!(TYPE_BOUND) },
511 TYPE_BOUND_LIST => &SyntaxInfo { name: stringify!(TYPE_BOUND_LIST) },
512 MACRO_ITEMS => &SyntaxInfo { name: stringify!(MACRO_ITEMS) },
513 MACRO_STMTS => &SyntaxInfo { name: stringify!(MACRO_STMTS) },
514 TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" },
515 EOF => &SyntaxInfo { name: "EOF" },
516 __LAST => &SyntaxInfo { name: "__LAST" },
517 }
518 }
519 pub fn from_keyword(ident: &str) -> Option<SyntaxKind> { 273 pub fn from_keyword(ident: &str) -> Option<SyntaxKind> {
520 let kw = match ident { 274 let kw = match ident {
521 "async" => ASYNC_KW, 275 "async" => ASYNC_KW,
diff --git a/crates/ra_tools/src/boilerplate_gen.rs b/crates/ra_tools/src/boilerplate_gen.rs
index 7ef51e82a..486a3fdec 100644
--- a/crates/ra_tools/src/boilerplate_gen.rs
+++ b/crates/ra_tools/src/boilerplate_gen.rs
@@ -195,10 +195,8 @@ fn generate_syntax_kinds(grammar: &Grammar) -> Result<String> {
195 195
196 let ast = quote! { 196 let ast = quote! {
197 #![allow(bad_style, missing_docs, unreachable_pub)] 197 #![allow(bad_style, missing_docs, unreachable_pub)]
198 use super::SyntaxInfo;
199
200 /// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`. 198 /// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`.
201 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] 199 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
202 #[repr(u16)] 200 #[repr(u16)]
203 pub enum SyntaxKind { 201 pub enum SyntaxKind {
204 // Technical SyntaxKinds: they appear temporally during parsing, 202 // Technical SyntaxKinds: they appear temporally during parsing,
@@ -219,19 +217,6 @@ fn generate_syntax_kinds(grammar: &Grammar) -> Result<String> {
219 } 217 }
220 use self::SyntaxKind::*; 218 use self::SyntaxKind::*;
221 219
222 impl From<u16> for SyntaxKind {
223 fn from(d: u16) -> SyntaxKind {
224 assert!(d <= (__LAST as u16));
225 unsafe { std::mem::transmute::<u16, SyntaxKind>(d) }
226 }
227 }
228
229 impl From<SyntaxKind> for u16 {
230 fn from(k: SyntaxKind) -> u16 {
231 k as u16
232 }
233 }
234
235 impl SyntaxKind { 220 impl SyntaxKind {
236 pub fn is_keyword(self) -> bool { 221 pub fn is_keyword(self) -> bool {
237 match self { 222 match self {
@@ -254,19 +239,6 @@ fn generate_syntax_kinds(grammar: &Grammar) -> Result<String> {
254 } 239 }
255 } 240 }
256 241
257 pub(crate) fn info(self) -> &'static SyntaxInfo {
258 match self {
259 #(#punctuation => &SyntaxInfo { name: stringify!(#punctuation) },)*
260 #(#all_keywords => &SyntaxInfo { name: stringify!(#all_keywords) },)*
261 #(#literals => &SyntaxInfo { name: stringify!(#literals) },)*
262 #(#tokens => &SyntaxInfo { name: stringify!(#tokens) },)*
263 #(#nodes => &SyntaxInfo { name: stringify!(#nodes) },)*
264 TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" },
265 EOF => &SyntaxInfo { name: "EOF" },
266 __LAST => &SyntaxInfo { name: "__LAST" },
267 }
268 }
269
270 pub fn from_keyword(ident: &str) -> Option<SyntaxKind> { 242 pub fn from_keyword(ident: &str) -> Option<SyntaxKind> {
271 let kw = match ident { 243 let kw = match ident {
272 #(#full_keywords_values => #full_keywords,)* 244 #(#full_keywords_values => #full_keywords,)*