From 00ccc6c292ded3bd79df7daa24c3fe8ab02dcd83 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 19 Aug 2019 13:11:51 +0300 Subject: use derive(Debug) for SyntaxKind --- crates/ra_tools/src/boilerplate_gen.rs | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) (limited to 'crates/ra_tools/src') 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 { let ast = quote! { #![allow(bad_style, missing_docs, unreachable_pub)] - use super::SyntaxInfo; - /// The kind of syntax node, e.g. `IDENT`, `USE_KW`, or `STRUCT_DEF`. - #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] + #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] #[repr(u16)] pub enum SyntaxKind { // Technical SyntaxKinds: they appear temporally during parsing, @@ -219,19 +217,6 @@ fn generate_syntax_kinds(grammar: &Grammar) -> Result { } use self::SyntaxKind::*; - impl From for SyntaxKind { - fn from(d: u16) -> SyntaxKind { - assert!(d <= (__LAST as u16)); - unsafe { std::mem::transmute::(d) } - } - } - - impl From for u16 { - fn from(k: SyntaxKind) -> u16 { - k as u16 - } - } - impl SyntaxKind { pub fn is_keyword(self) -> bool { match self { @@ -254,19 +239,6 @@ fn generate_syntax_kinds(grammar: &Grammar) -> Result { } } - pub(crate) fn info(self) -> &'static SyntaxInfo { - match self { - #(#punctuation => &SyntaxInfo { name: stringify!(#punctuation) },)* - #(#all_keywords => &SyntaxInfo { name: stringify!(#all_keywords) },)* - #(#literals => &SyntaxInfo { name: stringify!(#literals) },)* - #(#tokens => &SyntaxInfo { name: stringify!(#tokens) },)* - #(#nodes => &SyntaxInfo { name: stringify!(#nodes) },)* - TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" }, - EOF => &SyntaxInfo { name: "EOF" }, - __LAST => &SyntaxInfo { name: "__LAST" }, - } - } - pub fn from_keyword(ident: &str) -> Option { let kw = match ident { #(#full_keywords_values => #full_keywords,)* -- cgit v1.2.3