diff options
Diffstat (limited to 'crates/ra_syntax/src/ast/generated.rs.tera')
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs.tera | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs.tera b/crates/ra_syntax/src/ast/generated.rs.tera index d4fc6b5bd..131ee09ec 100644 --- a/crates/ra_syntax/src/ast/generated.rs.tera +++ b/crates/ra_syntax/src/ast/generated.rs.tera | |||
@@ -11,6 +11,8 @@ the below applies to the result of this template | |||
11 | 11 | ||
12 | #![cfg_attr(rustfmt, rustfmt_skip)] | 12 | #![cfg_attr(rustfmt, rustfmt_skip)] |
13 | 13 | ||
14 | use std::hash::{Hash, Hasher}; | ||
15 | |||
14 | use crate::{ | 16 | use crate::{ |
15 | ast, | 17 | ast, |
16 | SyntaxNode, SyntaxNodeRef, AstNode, | 18 | SyntaxNode, SyntaxNodeRef, AstNode, |
@@ -21,7 +23,7 @@ use crate::{ | |||
21 | // {{ node }} | 23 | // {{ node }} |
22 | 24 | ||
23 | {%- if methods.enum %} | 25 | {%- if methods.enum %} |
24 | #[derive(Debug, Clone, Copy)] | 26 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
25 | pub enum {{ node }}<'a> { | 27 | pub enum {{ node }}<'a> { |
26 | {%- for kind in methods.enum %} | 28 | {%- for kind in methods.enum %} |
27 | {{ kind }}({{ kind }}<'a>), | 29 | {{ kind }}({{ kind }}<'a>), |
@@ -46,12 +48,20 @@ impl<'a> AstNode<'a> for {{ node }}<'a> { | |||
46 | } | 48 | } |
47 | } | 49 | } |
48 | {% else %} | 50 | {% else %} |
49 | #[derive(Debug, Clone, Copy)] | 51 | #[derive(Debug, Clone, Copy,)] |
50 | pub struct {{ node }}Node<R: TreeRoot<RaTypes> = OwnedRoot> { | 52 | pub struct {{ node }}Node<R: TreeRoot<RaTypes> = OwnedRoot> { |
51 | syntax: SyntaxNode<R>, | 53 | pub(crate) syntax: SyntaxNode<R>, |
52 | } | 54 | } |
53 | pub type {{ node }}<'a> = {{ node }}Node<RefRoot<'a>>; | 55 | pub type {{ node }}<'a> = {{ node }}Node<RefRoot<'a>>; |
54 | 56 | ||
57 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<{{node}}Node<R1>> for {{node}}Node<R2> { | ||
58 | fn eq(&self, other: &{{node}}Node<R1>) -> bool { self.syntax == other.syntax } | ||
59 | } | ||
60 | impl<R: TreeRoot<RaTypes>> Eq for {{node}}Node<R> {} | ||
61 | impl<R: TreeRoot<RaTypes>> Hash for {{node}}Node<R> { | ||
62 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
63 | } | ||
64 | |||
55 | impl<'a> AstNode<'a> for {{ node }}<'a> { | 65 | impl<'a> AstNode<'a> for {{ node }}<'a> { |
56 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 66 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
57 | match syntax.kind() { | 67 | match syntax.kind() { |