Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'xtask/src/codegen/grammar.rs')
-rw-r--r--xtask/src/codegen/grammar.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/xtask/src/codegen/grammar.rs b/xtask/src/codegen/grammar.rs
index 44f12ba4ad..0352539754 100644
--- a/xtask/src/codegen/grammar.rs
+++ b/xtask/src/codegen/grammar.rs
@@ -261,7 +261,7 @@ fn generate_nodes(kinds: KindsSrc, grammar: &AstSrc) -> String {
.iter()
.map(|name| format_ident!("{}", to_upper_snake_case(&name.name.to_string())))
.collect();
-
+ let nodes = nodes.iter().map(|node| format_ident!("{}", node.name));
(
quote! {
#[pretty_doc_comment_placeholder_workaround]
@@ -294,6 +294,15 @@ fn generate_nodes(kinds: KindsSrc, grammar: &AstSrc) -> String {
&self.syntax
}
}
+
+ #(
+ impl From<#nodes> for #name {
+ #[inline]
+ fn from(node: #nodes) -> #name {
+ #name { syntax: node.syntax }
+ }
+ }
+ )*
},
)
})