diff options
Diffstat (limited to 'xtask')
-rw-r--r-- | xtask/src/codegen/gen_syntax.rs | 12 |
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 } |