about summary refs log tree commit diff
path: root/src/tools/rust-analyzer/xtask
diff options
context:
space:
mode:
authorChayim Refael Friedman <chayimfr@gmail.com>2024-12-30 03:13:17 +0200
committerChayim Refael Friedman <chayimfr@gmail.com>2024-12-30 03:13:17 +0200
commitca0c8da517ccc352e080ac3dcd53c263a3a79b4f (patch)
tree79a59d6913bef73abb8e418cebfb0fae0b1343f2 /src/tools/rust-analyzer/xtask
parent259eaf9c90317f4bd3827e2d03a6620afb9db7f8 (diff)
downloadrust-ca0c8da517ccc352e080ac3dcd53c263a3a79b4f.tar.gz
rust-ca0c8da517ccc352e080ac3dcd53c263a3a79b4f.zip
Generate a method for static retrieval of the SyntaxKind of a node, where possible
This will help for the quote macro for `ast::make`.
Diffstat (limited to 'src/tools/rust-analyzer/xtask')
-rw-r--r--src/tools/rust-analyzer/xtask/src/codegen/grammar.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/tools/rust-analyzer/xtask/src/codegen/grammar.rs b/src/tools/rust-analyzer/xtask/src/codegen/grammar.rs
index e7534582f2b..d39231f1c28 100644
--- a/src/tools/rust-analyzer/xtask/src/codegen/grammar.rs
+++ b/src/tools/rust-analyzer/xtask/src/codegen/grammar.rs
@@ -163,6 +163,13 @@ fn generate_nodes(kinds: KindsSrc, grammar: &AstSrc) -> String {
                 quote! {
                     impl AstNode for #name {
                         #[inline]
+                        fn kind() -> SyntaxKind
+                        where
+                            Self: Sized
+                        {
+                            #kind
+                        }
+                        #[inline]
                         fn can_cast(kind: SyntaxKind) -> bool {
                             kind == #kind
                         }