mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-14 17:59:56 +00:00
Generate From impls for Any* nodes
This commit is contained in:
parent
62a7468d46
commit
200a01adc4
3 changed files with 634 additions and 19 deletions
|
|
@ -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 }
|
||||
}
|
||||
}
|
||||
)*
|
||||
},
|
||||
)
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue