diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-08-19 11:17:23 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2019-08-19 11:17:23 +0100 |
commit | 2a34f5ca47157bdb5137a84daa8b5aa837e8ecbf (patch) | |
tree | fa5d522b8c4767c324da6c192cb9665349f58ea5 /crates/ra_tools | |
parent | 53241928e5866b5aa501710e59b264905beeca1a (diff) | |
parent | 00ccc6c292ded3bd79df7daa24c3fe8ab02dcd83 (diff) |
Merge #1698
1698: use derive(Debug) for SyntaxKind r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_tools')
-rw-r--r-- | crates/ra_tools/src/boilerplate_gen.rs | 30 |
1 files changed, 1 insertions, 29 deletions
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,)* |