aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/codegen
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-04-09 17:08:54 +0100
committerAleksey Kladov <[email protected]>2020-04-09 17:08:54 +0100
commit9285cbffb66e1c497469fedc5c181b7f295742fd (patch)
tree085ed3a0f8d31c7e1ceac60f37ea3a0fb6740b22 /xtask/src/codegen
parent6fd2a1249589c0c732b04177e3e7484ac6440fd8 (diff)
More compact
Diffstat (limited to 'xtask/src/codegen')
-rw-r--r--xtask/src/codegen/gen_syntax.rs12
1 files changed, 2 insertions, 10 deletions
diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs
index 9801a3dba..f9a50c5b9 100644
--- a/xtask/src/codegen/gen_syntax.rs
+++ b/xtask/src/codegen/gen_syntax.rs
@@ -75,12 +75,7 @@ fn generate_tokens(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
75 } 75 }
76 76
77 impl AstToken for #name { 77 impl AstToken for #name {
78 fn can_cast(kind: SyntaxKind) -> bool { 78 fn can_cast(kind: SyntaxKind) -> bool { kind == #kind }
79 match kind {
80 #kind => true,
81 _ => false,
82 }
83 }
84 fn cast(syntax: SyntaxToken) -> Option<Self> { 79 fn cast(syntax: SyntaxToken) -> Option<Self> {
85 if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } 80 if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
86 } 81 }
@@ -243,10 +238,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
243 238
244 impl AstNode for #name { 239 impl AstNode for #name {
245 fn can_cast(kind: SyntaxKind) -> bool { 240 fn can_cast(kind: SyntaxKind) -> bool {
246 match kind { 241 kind == #kind
247 #kind => true,
248 _ => false,
249 }
250 } 242 }
251 fn cast(syntax: SyntaxNode) -> Option<Self> { 243 fn cast(syntax: SyntaxNode) -> Option<Self> {
252 if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } 244 if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }