diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs | 1142 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs.tera | 16 | ||||
-rw-r--r-- | crates/ra_syntax/src/lib.rs | 15 | ||||
-rw-r--r-- | crates/ra_syntax/src/validation.rs | 2 |
4 files changed, 969 insertions, 206 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 420d9090c..3878c99a8 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs | |||
@@ -9,6 +9,8 @@ | |||
9 | 9 | ||
10 | #![cfg_attr(rustfmt, rustfmt_skip)] | 10 | #![cfg_attr(rustfmt, rustfmt_skip)] |
11 | 11 | ||
12 | use std::hash::{Hash, Hasher}; | ||
13 | |||
12 | use crate::{ | 14 | use crate::{ |
13 | ast, | 15 | ast, |
14 | SyntaxNode, SyntaxNodeRef, AstNode, | 16 | SyntaxNode, SyntaxNodeRef, AstNode, |
@@ -17,12 +19,20 @@ use crate::{ | |||
17 | }; | 19 | }; |
18 | 20 | ||
19 | // ArgList | 21 | // ArgList |
20 | #[derive(Debug, Clone, Copy)] | 22 | #[derive(Debug, Clone, Copy,)] |
21 | pub struct ArgListNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 23 | pub struct ArgListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
22 | syntax: SyntaxNode<R>, | 24 | pub(crate) syntax: SyntaxNode<R>, |
23 | } | 25 | } |
24 | pub type ArgList<'a> = ArgListNode<RefRoot<'a>>; | 26 | pub type ArgList<'a> = ArgListNode<RefRoot<'a>>; |
25 | 27 | ||
28 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ArgListNode<R1>> for ArgListNode<R2> { | ||
29 | fn eq(&self, other: &ArgListNode<R1>) -> bool { self.syntax == other.syntax } | ||
30 | } | ||
31 | impl<R: TreeRoot<RaTypes>> Eq for ArgListNode<R> {} | ||
32 | impl<R: TreeRoot<RaTypes>> Hash for ArgListNode<R> { | ||
33 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
34 | } | ||
35 | |||
26 | impl<'a> AstNode<'a> for ArgList<'a> { | 36 | impl<'a> AstNode<'a> for ArgList<'a> { |
27 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 37 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
28 | match syntax.kind() { | 38 | match syntax.kind() { |
@@ -50,12 +60,20 @@ impl<'a> ArgList<'a> { | |||
50 | } | 60 | } |
51 | 61 | ||
52 | // ArrayExpr | 62 | // ArrayExpr |
53 | #[derive(Debug, Clone, Copy)] | 63 | #[derive(Debug, Clone, Copy,)] |
54 | pub struct ArrayExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 64 | pub struct ArrayExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
55 | syntax: SyntaxNode<R>, | 65 | pub(crate) syntax: SyntaxNode<R>, |
56 | } | 66 | } |
57 | pub type ArrayExpr<'a> = ArrayExprNode<RefRoot<'a>>; | 67 | pub type ArrayExpr<'a> = ArrayExprNode<RefRoot<'a>>; |
58 | 68 | ||
69 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ArrayExprNode<R1>> for ArrayExprNode<R2> { | ||
70 | fn eq(&self, other: &ArrayExprNode<R1>) -> bool { self.syntax == other.syntax } | ||
71 | } | ||
72 | impl<R: TreeRoot<RaTypes>> Eq for ArrayExprNode<R> {} | ||
73 | impl<R: TreeRoot<RaTypes>> Hash for ArrayExprNode<R> { | ||
74 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
75 | } | ||
76 | |||
59 | impl<'a> AstNode<'a> for ArrayExpr<'a> { | 77 | impl<'a> AstNode<'a> for ArrayExpr<'a> { |
60 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 78 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
61 | match syntax.kind() { | 79 | match syntax.kind() { |
@@ -79,12 +97,20 @@ impl<R: TreeRoot<RaTypes>> ArrayExprNode<R> { | |||
79 | impl<'a> ArrayExpr<'a> {} | 97 | impl<'a> ArrayExpr<'a> {} |
80 | 98 | ||
81 | // ArrayType | 99 | // ArrayType |
82 | #[derive(Debug, Clone, Copy)] | 100 | #[derive(Debug, Clone, Copy,)] |
83 | pub struct ArrayTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 101 | pub struct ArrayTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
84 | syntax: SyntaxNode<R>, | 102 | pub(crate) syntax: SyntaxNode<R>, |
85 | } | 103 | } |
86 | pub type ArrayType<'a> = ArrayTypeNode<RefRoot<'a>>; | 104 | pub type ArrayType<'a> = ArrayTypeNode<RefRoot<'a>>; |
87 | 105 | ||
106 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ArrayTypeNode<R1>> for ArrayTypeNode<R2> { | ||
107 | fn eq(&self, other: &ArrayTypeNode<R1>) -> bool { self.syntax == other.syntax } | ||
108 | } | ||
109 | impl<R: TreeRoot<RaTypes>> Eq for ArrayTypeNode<R> {} | ||
110 | impl<R: TreeRoot<RaTypes>> Hash for ArrayTypeNode<R> { | ||
111 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
112 | } | ||
113 | |||
88 | impl<'a> AstNode<'a> for ArrayType<'a> { | 114 | impl<'a> AstNode<'a> for ArrayType<'a> { |
89 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 115 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
90 | match syntax.kind() { | 116 | match syntax.kind() { |
@@ -108,12 +134,20 @@ impl<R: TreeRoot<RaTypes>> ArrayTypeNode<R> { | |||
108 | impl<'a> ArrayType<'a> {} | 134 | impl<'a> ArrayType<'a> {} |
109 | 135 | ||
110 | // Attr | 136 | // Attr |
111 | #[derive(Debug, Clone, Copy)] | 137 | #[derive(Debug, Clone, Copy,)] |
112 | pub struct AttrNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 138 | pub struct AttrNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
113 | syntax: SyntaxNode<R>, | 139 | pub(crate) syntax: SyntaxNode<R>, |
114 | } | 140 | } |
115 | pub type Attr<'a> = AttrNode<RefRoot<'a>>; | 141 | pub type Attr<'a> = AttrNode<RefRoot<'a>>; |
116 | 142 | ||
143 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<AttrNode<R1>> for AttrNode<R2> { | ||
144 | fn eq(&self, other: &AttrNode<R1>) -> bool { self.syntax == other.syntax } | ||
145 | } | ||
146 | impl<R: TreeRoot<RaTypes>> Eq for AttrNode<R> {} | ||
147 | impl<R: TreeRoot<RaTypes>> Hash for AttrNode<R> { | ||
148 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
149 | } | ||
150 | |||
117 | impl<'a> AstNode<'a> for Attr<'a> { | 151 | impl<'a> AstNode<'a> for Attr<'a> { |
118 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 152 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
119 | match syntax.kind() { | 153 | match syntax.kind() { |
@@ -141,12 +175,20 @@ impl<'a> Attr<'a> { | |||
141 | } | 175 | } |
142 | 176 | ||
143 | // BinExpr | 177 | // BinExpr |
144 | #[derive(Debug, Clone, Copy)] | 178 | #[derive(Debug, Clone, Copy,)] |
145 | pub struct BinExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 179 | pub struct BinExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
146 | syntax: SyntaxNode<R>, | 180 | pub(crate) syntax: SyntaxNode<R>, |
147 | } | 181 | } |
148 | pub type BinExpr<'a> = BinExprNode<RefRoot<'a>>; | 182 | pub type BinExpr<'a> = BinExprNode<RefRoot<'a>>; |
149 | 183 | ||
184 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<BinExprNode<R1>> for BinExprNode<R2> { | ||
185 | fn eq(&self, other: &BinExprNode<R1>) -> bool { self.syntax == other.syntax } | ||
186 | } | ||
187 | impl<R: TreeRoot<RaTypes>> Eq for BinExprNode<R> {} | ||
188 | impl<R: TreeRoot<RaTypes>> Hash for BinExprNode<R> { | ||
189 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
190 | } | ||
191 | |||
150 | impl<'a> AstNode<'a> for BinExpr<'a> { | 192 | impl<'a> AstNode<'a> for BinExpr<'a> { |
151 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 193 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
152 | match syntax.kind() { | 194 | match syntax.kind() { |
@@ -170,12 +212,20 @@ impl<R: TreeRoot<RaTypes>> BinExprNode<R> { | |||
170 | impl<'a> BinExpr<'a> {} | 212 | impl<'a> BinExpr<'a> {} |
171 | 213 | ||
172 | // BindPat | 214 | // BindPat |
173 | #[derive(Debug, Clone, Copy)] | 215 | #[derive(Debug, Clone, Copy,)] |
174 | pub struct BindPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 216 | pub struct BindPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
175 | syntax: SyntaxNode<R>, | 217 | pub(crate) syntax: SyntaxNode<R>, |
176 | } | 218 | } |
177 | pub type BindPat<'a> = BindPatNode<RefRoot<'a>>; | 219 | pub type BindPat<'a> = BindPatNode<RefRoot<'a>>; |
178 | 220 | ||
221 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<BindPatNode<R1>> for BindPatNode<R2> { | ||
222 | fn eq(&self, other: &BindPatNode<R1>) -> bool { self.syntax == other.syntax } | ||
223 | } | ||
224 | impl<R: TreeRoot<RaTypes>> Eq for BindPatNode<R> {} | ||
225 | impl<R: TreeRoot<RaTypes>> Hash for BindPatNode<R> { | ||
226 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
227 | } | ||
228 | |||
179 | impl<'a> AstNode<'a> for BindPat<'a> { | 229 | impl<'a> AstNode<'a> for BindPat<'a> { |
180 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 230 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
181 | match syntax.kind() { | 231 | match syntax.kind() { |
@@ -200,12 +250,20 @@ impl<'a> ast::NameOwner<'a> for BindPat<'a> {} | |||
200 | impl<'a> BindPat<'a> {} | 250 | impl<'a> BindPat<'a> {} |
201 | 251 | ||
202 | // Block | 252 | // Block |
203 | #[derive(Debug, Clone, Copy)] | 253 | #[derive(Debug, Clone, Copy,)] |
204 | pub struct BlockNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 254 | pub struct BlockNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
205 | syntax: SyntaxNode<R>, | 255 | pub(crate) syntax: SyntaxNode<R>, |
206 | } | 256 | } |
207 | pub type Block<'a> = BlockNode<RefRoot<'a>>; | 257 | pub type Block<'a> = BlockNode<RefRoot<'a>>; |
208 | 258 | ||
259 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<BlockNode<R1>> for BlockNode<R2> { | ||
260 | fn eq(&self, other: &BlockNode<R1>) -> bool { self.syntax == other.syntax } | ||
261 | } | ||
262 | impl<R: TreeRoot<RaTypes>> Eq for BlockNode<R> {} | ||
263 | impl<R: TreeRoot<RaTypes>> Hash for BlockNode<R> { | ||
264 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
265 | } | ||
266 | |||
209 | impl<'a> AstNode<'a> for Block<'a> { | 267 | impl<'a> AstNode<'a> for Block<'a> { |
210 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 268 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
211 | match syntax.kind() { | 269 | match syntax.kind() { |
@@ -237,12 +295,20 @@ impl<'a> Block<'a> { | |||
237 | } | 295 | } |
238 | 296 | ||
239 | // BlockExpr | 297 | // BlockExpr |
240 | #[derive(Debug, Clone, Copy)] | 298 | #[derive(Debug, Clone, Copy,)] |
241 | pub struct BlockExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 299 | pub struct BlockExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
242 | syntax: SyntaxNode<R>, | 300 | pub(crate) syntax: SyntaxNode<R>, |
243 | } | 301 | } |
244 | pub type BlockExpr<'a> = BlockExprNode<RefRoot<'a>>; | 302 | pub type BlockExpr<'a> = BlockExprNode<RefRoot<'a>>; |
245 | 303 | ||
304 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<BlockExprNode<R1>> for BlockExprNode<R2> { | ||
305 | fn eq(&self, other: &BlockExprNode<R1>) -> bool { self.syntax == other.syntax } | ||
306 | } | ||
307 | impl<R: TreeRoot<RaTypes>> Eq for BlockExprNode<R> {} | ||
308 | impl<R: TreeRoot<RaTypes>> Hash for BlockExprNode<R> { | ||
309 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
310 | } | ||
311 | |||
246 | impl<'a> AstNode<'a> for BlockExpr<'a> { | 312 | impl<'a> AstNode<'a> for BlockExpr<'a> { |
247 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 313 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
248 | match syntax.kind() { | 314 | match syntax.kind() { |
@@ -270,12 +336,20 @@ impl<'a> BlockExpr<'a> { | |||
270 | } | 336 | } |
271 | 337 | ||
272 | // BreakExpr | 338 | // BreakExpr |
273 | #[derive(Debug, Clone, Copy)] | 339 | #[derive(Debug, Clone, Copy,)] |
274 | pub struct BreakExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 340 | pub struct BreakExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
275 | syntax: SyntaxNode<R>, | 341 | pub(crate) syntax: SyntaxNode<R>, |
276 | } | 342 | } |
277 | pub type BreakExpr<'a> = BreakExprNode<RefRoot<'a>>; | 343 | pub type BreakExpr<'a> = BreakExprNode<RefRoot<'a>>; |
278 | 344 | ||
345 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<BreakExprNode<R1>> for BreakExprNode<R2> { | ||
346 | fn eq(&self, other: &BreakExprNode<R1>) -> bool { self.syntax == other.syntax } | ||
347 | } | ||
348 | impl<R: TreeRoot<RaTypes>> Eq for BreakExprNode<R> {} | ||
349 | impl<R: TreeRoot<RaTypes>> Hash for BreakExprNode<R> { | ||
350 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
351 | } | ||
352 | |||
279 | impl<'a> AstNode<'a> for BreakExpr<'a> { | 353 | impl<'a> AstNode<'a> for BreakExpr<'a> { |
280 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 354 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
281 | match syntax.kind() { | 355 | match syntax.kind() { |
@@ -299,12 +373,20 @@ impl<R: TreeRoot<RaTypes>> BreakExprNode<R> { | |||
299 | impl<'a> BreakExpr<'a> {} | 373 | impl<'a> BreakExpr<'a> {} |
300 | 374 | ||
301 | // CallExpr | 375 | // CallExpr |
302 | #[derive(Debug, Clone, Copy)] | 376 | #[derive(Debug, Clone, Copy,)] |
303 | pub struct CallExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 377 | pub struct CallExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
304 | syntax: SyntaxNode<R>, | 378 | pub(crate) syntax: SyntaxNode<R>, |
305 | } | 379 | } |
306 | pub type CallExpr<'a> = CallExprNode<RefRoot<'a>>; | 380 | pub type CallExpr<'a> = CallExprNode<RefRoot<'a>>; |
307 | 381 | ||
382 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<CallExprNode<R1>> for CallExprNode<R2> { | ||
383 | fn eq(&self, other: &CallExprNode<R1>) -> bool { self.syntax == other.syntax } | ||
384 | } | ||
385 | impl<R: TreeRoot<RaTypes>> Eq for CallExprNode<R> {} | ||
386 | impl<R: TreeRoot<RaTypes>> Hash for CallExprNode<R> { | ||
387 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
388 | } | ||
389 | |||
308 | impl<'a> AstNode<'a> for CallExpr<'a> { | 390 | impl<'a> AstNode<'a> for CallExpr<'a> { |
309 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 391 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
310 | match syntax.kind() { | 392 | match syntax.kind() { |
@@ -333,12 +415,20 @@ impl<'a> CallExpr<'a> { | |||
333 | } | 415 | } |
334 | 416 | ||
335 | // CastExpr | 417 | // CastExpr |
336 | #[derive(Debug, Clone, Copy)] | 418 | #[derive(Debug, Clone, Copy,)] |
337 | pub struct CastExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 419 | pub struct CastExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
338 | syntax: SyntaxNode<R>, | 420 | pub(crate) syntax: SyntaxNode<R>, |
339 | } | 421 | } |
340 | pub type CastExpr<'a> = CastExprNode<RefRoot<'a>>; | 422 | pub type CastExpr<'a> = CastExprNode<RefRoot<'a>>; |
341 | 423 | ||
424 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<CastExprNode<R1>> for CastExprNode<R2> { | ||
425 | fn eq(&self, other: &CastExprNode<R1>) -> bool { self.syntax == other.syntax } | ||
426 | } | ||
427 | impl<R: TreeRoot<RaTypes>> Eq for CastExprNode<R> {} | ||
428 | impl<R: TreeRoot<RaTypes>> Hash for CastExprNode<R> { | ||
429 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
430 | } | ||
431 | |||
342 | impl<'a> AstNode<'a> for CastExpr<'a> { | 432 | impl<'a> AstNode<'a> for CastExpr<'a> { |
343 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 433 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
344 | match syntax.kind() { | 434 | match syntax.kind() { |
@@ -362,12 +452,20 @@ impl<R: TreeRoot<RaTypes>> CastExprNode<R> { | |||
362 | impl<'a> CastExpr<'a> {} | 452 | impl<'a> CastExpr<'a> {} |
363 | 453 | ||
364 | // Char | 454 | // Char |
365 | #[derive(Debug, Clone, Copy)] | 455 | #[derive(Debug, Clone, Copy,)] |
366 | pub struct CharNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 456 | pub struct CharNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
367 | syntax: SyntaxNode<R>, | 457 | pub(crate) syntax: SyntaxNode<R>, |
368 | } | 458 | } |
369 | pub type Char<'a> = CharNode<RefRoot<'a>>; | 459 | pub type Char<'a> = CharNode<RefRoot<'a>>; |
370 | 460 | ||
461 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<CharNode<R1>> for CharNode<R2> { | ||
462 | fn eq(&self, other: &CharNode<R1>) -> bool { self.syntax == other.syntax } | ||
463 | } | ||
464 | impl<R: TreeRoot<RaTypes>> Eq for CharNode<R> {} | ||
465 | impl<R: TreeRoot<RaTypes>> Hash for CharNode<R> { | ||
466 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
467 | } | ||
468 | |||
371 | impl<'a> AstNode<'a> for Char<'a> { | 469 | impl<'a> AstNode<'a> for Char<'a> { |
372 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 470 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
373 | match syntax.kind() { | 471 | match syntax.kind() { |
@@ -391,12 +489,20 @@ impl<R: TreeRoot<RaTypes>> CharNode<R> { | |||
391 | impl<'a> Char<'a> {} | 489 | impl<'a> Char<'a> {} |
392 | 490 | ||
393 | // Comment | 491 | // Comment |
394 | #[derive(Debug, Clone, Copy)] | 492 | #[derive(Debug, Clone, Copy,)] |
395 | pub struct CommentNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 493 | pub struct CommentNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
396 | syntax: SyntaxNode<R>, | 494 | pub(crate) syntax: SyntaxNode<R>, |
397 | } | 495 | } |
398 | pub type Comment<'a> = CommentNode<RefRoot<'a>>; | 496 | pub type Comment<'a> = CommentNode<RefRoot<'a>>; |
399 | 497 | ||
498 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<CommentNode<R1>> for CommentNode<R2> { | ||
499 | fn eq(&self, other: &CommentNode<R1>) -> bool { self.syntax == other.syntax } | ||
500 | } | ||
501 | impl<R: TreeRoot<RaTypes>> Eq for CommentNode<R> {} | ||
502 | impl<R: TreeRoot<RaTypes>> Hash for CommentNode<R> { | ||
503 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
504 | } | ||
505 | |||
400 | impl<'a> AstNode<'a> for Comment<'a> { | 506 | impl<'a> AstNode<'a> for Comment<'a> { |
401 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 507 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
402 | match syntax.kind() { | 508 | match syntax.kind() { |
@@ -420,12 +526,20 @@ impl<R: TreeRoot<RaTypes>> CommentNode<R> { | |||
420 | impl<'a> Comment<'a> {} | 526 | impl<'a> Comment<'a> {} |
421 | 527 | ||
422 | // Condition | 528 | // Condition |
423 | #[derive(Debug, Clone, Copy)] | 529 | #[derive(Debug, Clone, Copy,)] |
424 | pub struct ConditionNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 530 | pub struct ConditionNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
425 | syntax: SyntaxNode<R>, | 531 | pub(crate) syntax: SyntaxNode<R>, |
426 | } | 532 | } |
427 | pub type Condition<'a> = ConditionNode<RefRoot<'a>>; | 533 | pub type Condition<'a> = ConditionNode<RefRoot<'a>>; |
428 | 534 | ||
535 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ConditionNode<R1>> for ConditionNode<R2> { | ||
536 | fn eq(&self, other: &ConditionNode<R1>) -> bool { self.syntax == other.syntax } | ||
537 | } | ||
538 | impl<R: TreeRoot<RaTypes>> Eq for ConditionNode<R> {} | ||
539 | impl<R: TreeRoot<RaTypes>> Hash for ConditionNode<R> { | ||
540 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
541 | } | ||
542 | |||
429 | impl<'a> AstNode<'a> for Condition<'a> { | 543 | impl<'a> AstNode<'a> for Condition<'a> { |
430 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 544 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
431 | match syntax.kind() { | 545 | match syntax.kind() { |
@@ -457,12 +571,20 @@ impl<'a> Condition<'a> { | |||
457 | } | 571 | } |
458 | 572 | ||
459 | // ConstDef | 573 | // ConstDef |
460 | #[derive(Debug, Clone, Copy)] | 574 | #[derive(Debug, Clone, Copy,)] |
461 | pub struct ConstDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 575 | pub struct ConstDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
462 | syntax: SyntaxNode<R>, | 576 | pub(crate) syntax: SyntaxNode<R>, |
463 | } | 577 | } |
464 | pub type ConstDef<'a> = ConstDefNode<RefRoot<'a>>; | 578 | pub type ConstDef<'a> = ConstDefNode<RefRoot<'a>>; |
465 | 579 | ||
580 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ConstDefNode<R1>> for ConstDefNode<R2> { | ||
581 | fn eq(&self, other: &ConstDefNode<R1>) -> bool { self.syntax == other.syntax } | ||
582 | } | ||
583 | impl<R: TreeRoot<RaTypes>> Eq for ConstDefNode<R> {} | ||
584 | impl<R: TreeRoot<RaTypes>> Hash for ConstDefNode<R> { | ||
585 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
586 | } | ||
587 | |||
466 | impl<'a> AstNode<'a> for ConstDef<'a> { | 588 | impl<'a> AstNode<'a> for ConstDef<'a> { |
467 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 589 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
468 | match syntax.kind() { | 590 | match syntax.kind() { |
@@ -489,12 +611,20 @@ impl<'a> ast::AttrsOwner<'a> for ConstDef<'a> {} | |||
489 | impl<'a> ConstDef<'a> {} | 611 | impl<'a> ConstDef<'a> {} |
490 | 612 | ||
491 | // ContinueExpr | 613 | // ContinueExpr |
492 | #[derive(Debug, Clone, Copy)] | 614 | #[derive(Debug, Clone, Copy,)] |
493 | pub struct ContinueExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 615 | pub struct ContinueExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
494 | syntax: SyntaxNode<R>, | 616 | pub(crate) syntax: SyntaxNode<R>, |
495 | } | 617 | } |
496 | pub type ContinueExpr<'a> = ContinueExprNode<RefRoot<'a>>; | 618 | pub type ContinueExpr<'a> = ContinueExprNode<RefRoot<'a>>; |
497 | 619 | ||
620 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ContinueExprNode<R1>> for ContinueExprNode<R2> { | ||
621 | fn eq(&self, other: &ContinueExprNode<R1>) -> bool { self.syntax == other.syntax } | ||
622 | } | ||
623 | impl<R: TreeRoot<RaTypes>> Eq for ContinueExprNode<R> {} | ||
624 | impl<R: TreeRoot<RaTypes>> Hash for ContinueExprNode<R> { | ||
625 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
626 | } | ||
627 | |||
498 | impl<'a> AstNode<'a> for ContinueExpr<'a> { | 628 | impl<'a> AstNode<'a> for ContinueExpr<'a> { |
499 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 629 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
500 | match syntax.kind() { | 630 | match syntax.kind() { |
@@ -518,12 +648,20 @@ impl<R: TreeRoot<RaTypes>> ContinueExprNode<R> { | |||
518 | impl<'a> ContinueExpr<'a> {} | 648 | impl<'a> ContinueExpr<'a> {} |
519 | 649 | ||
520 | // DynTraitType | 650 | // DynTraitType |
521 | #[derive(Debug, Clone, Copy)] | 651 | #[derive(Debug, Clone, Copy,)] |
522 | pub struct DynTraitTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 652 | pub struct DynTraitTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
523 | syntax: SyntaxNode<R>, | 653 | pub(crate) syntax: SyntaxNode<R>, |
524 | } | 654 | } |
525 | pub type DynTraitType<'a> = DynTraitTypeNode<RefRoot<'a>>; | 655 | pub type DynTraitType<'a> = DynTraitTypeNode<RefRoot<'a>>; |
526 | 656 | ||
657 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<DynTraitTypeNode<R1>> for DynTraitTypeNode<R2> { | ||
658 | fn eq(&self, other: &DynTraitTypeNode<R1>) -> bool { self.syntax == other.syntax } | ||
659 | } | ||
660 | impl<R: TreeRoot<RaTypes>> Eq for DynTraitTypeNode<R> {} | ||
661 | impl<R: TreeRoot<RaTypes>> Hash for DynTraitTypeNode<R> { | ||
662 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
663 | } | ||
664 | |||
527 | impl<'a> AstNode<'a> for DynTraitType<'a> { | 665 | impl<'a> AstNode<'a> for DynTraitType<'a> { |
528 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 666 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
529 | match syntax.kind() { | 667 | match syntax.kind() { |
@@ -547,12 +685,20 @@ impl<R: TreeRoot<RaTypes>> DynTraitTypeNode<R> { | |||
547 | impl<'a> DynTraitType<'a> {} | 685 | impl<'a> DynTraitType<'a> {} |
548 | 686 | ||
549 | // EnumDef | 687 | // EnumDef |
550 | #[derive(Debug, Clone, Copy)] | 688 | #[derive(Debug, Clone, Copy,)] |
551 | pub struct EnumDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 689 | pub struct EnumDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
552 | syntax: SyntaxNode<R>, | 690 | pub(crate) syntax: SyntaxNode<R>, |
553 | } | 691 | } |
554 | pub type EnumDef<'a> = EnumDefNode<RefRoot<'a>>; | 692 | pub type EnumDef<'a> = EnumDefNode<RefRoot<'a>>; |
555 | 693 | ||
694 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<EnumDefNode<R1>> for EnumDefNode<R2> { | ||
695 | fn eq(&self, other: &EnumDefNode<R1>) -> bool { self.syntax == other.syntax } | ||
696 | } | ||
697 | impl<R: TreeRoot<RaTypes>> Eq for EnumDefNode<R> {} | ||
698 | impl<R: TreeRoot<RaTypes>> Hash for EnumDefNode<R> { | ||
699 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
700 | } | ||
701 | |||
556 | impl<'a> AstNode<'a> for EnumDef<'a> { | 702 | impl<'a> AstNode<'a> for EnumDef<'a> { |
557 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 703 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
558 | match syntax.kind() { | 704 | match syntax.kind() { |
@@ -579,7 +725,7 @@ impl<'a> ast::AttrsOwner<'a> for EnumDef<'a> {} | |||
579 | impl<'a> EnumDef<'a> {} | 725 | impl<'a> EnumDef<'a> {} |
580 | 726 | ||
581 | // Expr | 727 | // Expr |
582 | #[derive(Debug, Clone, Copy)] | 728 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
583 | pub enum Expr<'a> { | 729 | pub enum Expr<'a> { |
584 | TupleExpr(TupleExpr<'a>), | 730 | TupleExpr(TupleExpr<'a>), |
585 | ArrayExpr(ArrayExpr<'a>), | 731 | ArrayExpr(ArrayExpr<'a>), |
@@ -694,12 +840,20 @@ impl<'a> AstNode<'a> for Expr<'a> { | |||
694 | impl<'a> Expr<'a> {} | 840 | impl<'a> Expr<'a> {} |
695 | 841 | ||
696 | // ExprStmt | 842 | // ExprStmt |
697 | #[derive(Debug, Clone, Copy)] | 843 | #[derive(Debug, Clone, Copy,)] |
698 | pub struct ExprStmtNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 844 | pub struct ExprStmtNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
699 | syntax: SyntaxNode<R>, | 845 | pub(crate) syntax: SyntaxNode<R>, |
700 | } | 846 | } |
701 | pub type ExprStmt<'a> = ExprStmtNode<RefRoot<'a>>; | 847 | pub type ExprStmt<'a> = ExprStmtNode<RefRoot<'a>>; |
702 | 848 | ||
849 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ExprStmtNode<R1>> for ExprStmtNode<R2> { | ||
850 | fn eq(&self, other: &ExprStmtNode<R1>) -> bool { self.syntax == other.syntax } | ||
851 | } | ||
852 | impl<R: TreeRoot<RaTypes>> Eq for ExprStmtNode<R> {} | ||
853 | impl<R: TreeRoot<RaTypes>> Hash for ExprStmtNode<R> { | ||
854 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
855 | } | ||
856 | |||
703 | impl<'a> AstNode<'a> for ExprStmt<'a> { | 857 | impl<'a> AstNode<'a> for ExprStmt<'a> { |
704 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 858 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
705 | match syntax.kind() { | 859 | match syntax.kind() { |
@@ -727,12 +881,20 @@ impl<'a> ExprStmt<'a> { | |||
727 | } | 881 | } |
728 | 882 | ||
729 | // ExternCrateItem | 883 | // ExternCrateItem |
730 | #[derive(Debug, Clone, Copy)] | 884 | #[derive(Debug, Clone, Copy,)] |
731 | pub struct ExternCrateItemNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 885 | pub struct ExternCrateItemNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
732 | syntax: SyntaxNode<R>, | 886 | pub(crate) syntax: SyntaxNode<R>, |
733 | } | 887 | } |
734 | pub type ExternCrateItem<'a> = ExternCrateItemNode<RefRoot<'a>>; | 888 | pub type ExternCrateItem<'a> = ExternCrateItemNode<RefRoot<'a>>; |
735 | 889 | ||
890 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ExternCrateItemNode<R1>> for ExternCrateItemNode<R2> { | ||
891 | fn eq(&self, other: &ExternCrateItemNode<R1>) -> bool { self.syntax == other.syntax } | ||
892 | } | ||
893 | impl<R: TreeRoot<RaTypes>> Eq for ExternCrateItemNode<R> {} | ||
894 | impl<R: TreeRoot<RaTypes>> Hash for ExternCrateItemNode<R> { | ||
895 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
896 | } | ||
897 | |||
736 | impl<'a> AstNode<'a> for ExternCrateItem<'a> { | 898 | impl<'a> AstNode<'a> for ExternCrateItem<'a> { |
737 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 899 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
738 | match syntax.kind() { | 900 | match syntax.kind() { |
@@ -756,12 +918,20 @@ impl<R: TreeRoot<RaTypes>> ExternCrateItemNode<R> { | |||
756 | impl<'a> ExternCrateItem<'a> {} | 918 | impl<'a> ExternCrateItem<'a> {} |
757 | 919 | ||
758 | // FieldExpr | 920 | // FieldExpr |
759 | #[derive(Debug, Clone, Copy)] | 921 | #[derive(Debug, Clone, Copy,)] |
760 | pub struct FieldExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 922 | pub struct FieldExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
761 | syntax: SyntaxNode<R>, | 923 | pub(crate) syntax: SyntaxNode<R>, |
762 | } | 924 | } |
763 | pub type FieldExpr<'a> = FieldExprNode<RefRoot<'a>>; | 925 | pub type FieldExpr<'a> = FieldExprNode<RefRoot<'a>>; |
764 | 926 | ||
927 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<FieldExprNode<R1>> for FieldExprNode<R2> { | ||
928 | fn eq(&self, other: &FieldExprNode<R1>) -> bool { self.syntax == other.syntax } | ||
929 | } | ||
930 | impl<R: TreeRoot<RaTypes>> Eq for FieldExprNode<R> {} | ||
931 | impl<R: TreeRoot<RaTypes>> Hash for FieldExprNode<R> { | ||
932 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
933 | } | ||
934 | |||
765 | impl<'a> AstNode<'a> for FieldExpr<'a> { | 935 | impl<'a> AstNode<'a> for FieldExpr<'a> { |
766 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 936 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
767 | match syntax.kind() { | 937 | match syntax.kind() { |
@@ -785,12 +955,20 @@ impl<R: TreeRoot<RaTypes>> FieldExprNode<R> { | |||
785 | impl<'a> FieldExpr<'a> {} | 955 | impl<'a> FieldExpr<'a> {} |
786 | 956 | ||
787 | // FieldPatList | 957 | // FieldPatList |
788 | #[derive(Debug, Clone, Copy)] | 958 | #[derive(Debug, Clone, Copy,)] |
789 | pub struct FieldPatListNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 959 | pub struct FieldPatListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
790 | syntax: SyntaxNode<R>, | 960 | pub(crate) syntax: SyntaxNode<R>, |
791 | } | 961 | } |
792 | pub type FieldPatList<'a> = FieldPatListNode<RefRoot<'a>>; | 962 | pub type FieldPatList<'a> = FieldPatListNode<RefRoot<'a>>; |
793 | 963 | ||
964 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<FieldPatListNode<R1>> for FieldPatListNode<R2> { | ||
965 | fn eq(&self, other: &FieldPatListNode<R1>) -> bool { self.syntax == other.syntax } | ||
966 | } | ||
967 | impl<R: TreeRoot<RaTypes>> Eq for FieldPatListNode<R> {} | ||
968 | impl<R: TreeRoot<RaTypes>> Hash for FieldPatListNode<R> { | ||
969 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
970 | } | ||
971 | |||
794 | impl<'a> AstNode<'a> for FieldPatList<'a> { | 972 | impl<'a> AstNode<'a> for FieldPatList<'a> { |
795 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 973 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
796 | match syntax.kind() { | 974 | match syntax.kind() { |
@@ -814,12 +992,20 @@ impl<R: TreeRoot<RaTypes>> FieldPatListNode<R> { | |||
814 | impl<'a> FieldPatList<'a> {} | 992 | impl<'a> FieldPatList<'a> {} |
815 | 993 | ||
816 | // FnDef | 994 | // FnDef |
817 | #[derive(Debug, Clone, Copy)] | 995 | #[derive(Debug, Clone, Copy,)] |
818 | pub struct FnDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 996 | pub struct FnDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
819 | syntax: SyntaxNode<R>, | 997 | pub(crate) syntax: SyntaxNode<R>, |
820 | } | 998 | } |
821 | pub type FnDef<'a> = FnDefNode<RefRoot<'a>>; | 999 | pub type FnDef<'a> = FnDefNode<RefRoot<'a>>; |
822 | 1000 | ||
1001 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<FnDefNode<R1>> for FnDefNode<R2> { | ||
1002 | fn eq(&self, other: &FnDefNode<R1>) -> bool { self.syntax == other.syntax } | ||
1003 | } | ||
1004 | impl<R: TreeRoot<RaTypes>> Eq for FnDefNode<R> {} | ||
1005 | impl<R: TreeRoot<RaTypes>> Hash for FnDefNode<R> { | ||
1006 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
1007 | } | ||
1008 | |||
823 | impl<'a> AstNode<'a> for FnDef<'a> { | 1009 | impl<'a> AstNode<'a> for FnDef<'a> { |
824 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1010 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
825 | match syntax.kind() { | 1011 | match syntax.kind() { |
@@ -859,12 +1045,20 @@ impl<'a> FnDef<'a> { | |||
859 | } | 1045 | } |
860 | 1046 | ||
861 | // FnPointerType | 1047 | // FnPointerType |
862 | #[derive(Debug, Clone, Copy)] | 1048 | #[derive(Debug, Clone, Copy,)] |
863 | pub struct FnPointerTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 1049 | pub struct FnPointerTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
864 | syntax: SyntaxNode<R>, | 1050 | pub(crate) syntax: SyntaxNode<R>, |
865 | } | 1051 | } |
866 | pub type FnPointerType<'a> = FnPointerTypeNode<RefRoot<'a>>; | 1052 | pub type FnPointerType<'a> = FnPointerTypeNode<RefRoot<'a>>; |
867 | 1053 | ||
1054 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<FnPointerTypeNode<R1>> for FnPointerTypeNode<R2> { | ||
1055 | fn eq(&self, other: &FnPointerTypeNode<R1>) -> bool { self.syntax == other.syntax } | ||
1056 | } | ||
1057 | impl<R: TreeRoot<RaTypes>> Eq for FnPointerTypeNode<R> {} | ||
1058 | impl<R: TreeRoot<RaTypes>> Hash for FnPointerTypeNode<R> { | ||
1059 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
1060 | } | ||
1061 | |||
868 | impl<'a> AstNode<'a> for FnPointerType<'a> { | 1062 | impl<'a> AstNode<'a> for FnPointerType<'a> { |
869 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1063 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
870 | match syntax.kind() { | 1064 | match syntax.kind() { |
@@ -888,12 +1082,20 @@ impl<R: TreeRoot<RaTypes>> FnPointerTypeNode<R> { | |||
888 | impl<'a> FnPointerType<'a> {} | 1082 | impl<'a> FnPointerType<'a> {} |
889 | 1083 | ||
890 | // ForExpr | 1084 | // ForExpr |
891 | #[derive(Debug, Clone, Copy)] | 1085 | #[derive(Debug, Clone, Copy,)] |
892 | pub struct ForExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 1086 | pub struct ForExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
893 | syntax: SyntaxNode<R>, | 1087 | pub(crate) syntax: SyntaxNode<R>, |
894 | } | 1088 | } |
895 | pub type ForExpr<'a> = ForExprNode<RefRoot<'a>>; | 1089 | pub type ForExpr<'a> = ForExprNode<RefRoot<'a>>; |
896 | 1090 | ||
1091 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ForExprNode<R1>> for ForExprNode<R2> { | ||
1092 | fn eq(&self, other: &ForExprNode<R1>) -> bool { self.syntax == other.syntax } | ||
1093 | } | ||
1094 | impl<R: TreeRoot<RaTypes>> Eq for ForExprNode<R> {} | ||
1095 | impl<R: TreeRoot<RaTypes>> Hash for ForExprNode<R> { | ||
1096 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
1097 | } | ||
1098 | |||
897 | impl<'a> AstNode<'a> for ForExpr<'a> { | 1099 | impl<'a> AstNode<'a> for ForExpr<'a> { |
898 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1100 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
899 | match syntax.kind() { | 1101 | match syntax.kind() { |
@@ -926,12 +1128,20 @@ impl<'a> ForExpr<'a> { | |||
926 | } | 1128 | } |
927 | 1129 | ||
928 | // ForType | 1130 | // ForType |
929 | #[derive(Debug, Clone, Copy)] | 1131 | #[derive(Debug, Clone, Copy,)] |
930 | pub struct ForTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 1132 | pub struct ForTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
931 | syntax: SyntaxNode<R>, | 1133 | pub(crate) syntax: SyntaxNode<R>, |
932 | } | 1134 | } |
933 | pub type ForType<'a> = ForTypeNode<RefRoot<'a>>; | 1135 | pub type ForType<'a> = ForTypeNode<RefRoot<'a>>; |
934 | 1136 | ||
1137 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ForTypeNode<R1>> for ForTypeNode<R2> { | ||
1138 | fn eq(&self, other: &ForTypeNode<R1>) -> bool { self.syntax == other.syntax } | ||
1139 | } | ||
1140 | impl<R: TreeRoot<RaTypes>> Eq for ForTypeNode<R> {} | ||
1141 | impl<R: TreeRoot<RaTypes>> Hash for ForTypeNode<R> { | ||
1142 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
1143 | } | ||
1144 | |||
935 | impl<'a> AstNode<'a> for ForType<'a> { | 1145 | impl<'a> AstNode<'a> for ForType<'a> { |
936 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1146 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
937 | match syntax.kind() { | 1147 | match syntax.kind() { |
@@ -955,12 +1165,20 @@ impl<R: TreeRoot<RaTypes>> ForTypeNode<R> { | |||
955 | impl<'a> ForType<'a> {} | 1165 | impl<'a> ForType<'a> {} |
956 | 1166 | ||
957 | // IfExpr | 1167 | // IfExpr |
958 | #[derive(Debug, Clone, Copy)] | 1168 | #[derive(Debug, Clone, Copy,)] |
959 | pub struct IfExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 1169 | pub struct IfExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
960 | syntax: SyntaxNode<R>, | 1170 | pub(crate) syntax: SyntaxNode<R>, |
961 | } | 1171 | } |
962 | pub type IfExpr<'a> = IfExprNode<RefRoot<'a>>; | 1172 | pub type IfExpr<'a> = IfExprNode<RefRoot<'a>>; |
963 | 1173 | ||
1174 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<IfExprNode<R1>> for IfExprNode<R2> { | ||
1175 | fn eq(&self, other: &IfExprNode<R1>) -> bool { self.syntax == other.syntax } | ||
1176 | } | ||
1177 | impl<R: TreeRoot<RaTypes>> Eq for IfExprNode<R> {} | ||
1178 | impl<R: TreeRoot<RaTypes>> Hash for IfExprNode<R> { | ||
1179 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
1180 | } | ||
1181 | |||
964 | impl<'a> AstNode<'a> for IfExpr<'a> { | 1182 | impl<'a> AstNode<'a> for IfExpr<'a> { |
965 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1183 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
966 | match syntax.kind() { | 1184 | match syntax.kind() { |
@@ -988,12 +1206,20 @@ impl<'a> IfExpr<'a> { | |||
988 | } | 1206 | } |
989 | 1207 | ||
990 | // ImplItem | 1208 | // ImplItem |
991 | #[derive(Debug, Clone, Copy)] | 1209 | #[derive(Debug, Clone, Copy,)] |
992 | pub struct ImplItemNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 1210 | pub struct ImplItemNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
993 | syntax: SyntaxNode<R>, | 1211 | pub(crate) syntax: SyntaxNode<R>, |
994 | } | 1212 | } |
995 | pub type ImplItem<'a> = ImplItemNode<RefRoot<'a>>; | 1213 | pub type ImplItem<'a> = ImplItemNode<RefRoot<'a>>; |
996 | 1214 | ||
1215 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ImplItemNode<R1>> for ImplItemNode<R2> { | ||
1216 | fn eq(&self, other: &ImplItemNode<R1>) -> bool { self.syntax == other.syntax } | ||
1217 | } | ||
1218 | impl<R: TreeRoot<RaTypes>> Eq for ImplItemNode<R> {} | ||
1219 | impl<R: TreeRoot<RaTypes>> Hash for ImplItemNode<R> { | ||
1220 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
1221 | } | ||
1222 | |||
997 | impl<'a> AstNode<'a> for ImplItem<'a> { | 1223 | impl<'a> AstNode<'a> for ImplItem<'a> { |
998 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1224 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
999 | match syntax.kind() { | 1225 | match syntax.kind() { |
@@ -1017,12 +1243,20 @@ impl<R: TreeRoot<RaTypes>> ImplItemNode<R> { | |||
1017 | impl<'a> ImplItem<'a> {} | 1243 | impl<'a> ImplItem<'a> {} |
1018 | 1244 | ||
1019 | // ImplTraitType | 1245 | // ImplTraitType |
1020 | #[derive(Debug, Clone, Copy)] | 1246 | #[derive(Debug, Clone, Copy,)] |
1021 | pub struct ImplTraitTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 1247 | pub struct ImplTraitTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1022 | syntax: SyntaxNode<R>, | 1248 | pub(crate) syntax: SyntaxNode<R>, |
1023 | } | 1249 | } |
1024 | pub type ImplTraitType<'a> = ImplTraitTypeNode<RefRoot<'a>>; | 1250 | pub type ImplTraitType<'a> = ImplTraitTypeNode<RefRoot<'a>>; |
1025 | 1251 | ||
1252 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ImplTraitTypeNode<R1>> for ImplTraitTypeNode<R2> { | ||
1253 | fn eq(&self, other: &ImplTraitTypeNode<R1>) -> bool { self.syntax == other.syntax } | ||
1254 | } | ||
1255 | impl<R: TreeRoot<RaTypes>> Eq for ImplTraitTypeNode<R> {} | ||
1256 | impl<R: TreeRoot<RaTypes>> Hash for ImplTraitTypeNode<R> { | ||
1257 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
1258 | } | ||
1259 | |||
1026 | impl<'a> AstNode<'a> for ImplTraitType<'a> { | 1260 | impl<'a> AstNode<'a> for ImplTraitType<'a> { |
1027 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1261 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1028 | match syntax.kind() { | 1262 | match syntax.kind() { |
@@ -1046,12 +1280,20 @@ impl<R: TreeRoot<RaTypes>> ImplTraitTypeNode<R> { | |||
1046 | impl<'a> ImplTraitType<'a> {} | 1280 | impl<'a> ImplTraitType<'a> {} |
1047 | 1281 | ||
1048 | // IndexExpr | 1282 | // IndexExpr |
1049 | #[derive(Debug, Clone, Copy)] | 1283 | #[derive(Debug, Clone, Copy,)] |
1050 | pub struct IndexExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 1284 | pub struct IndexExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1051 | syntax: SyntaxNode<R>, | 1285 | pub(crate) syntax: SyntaxNode<R>, |
1052 | } | 1286 | } |
1053 | pub type IndexExpr<'a> = IndexExprNode<RefRoot<'a>>; | 1287 | pub type IndexExpr<'a> = IndexExprNode<RefRoot<'a>>; |
1054 | 1288 | ||
1289 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<IndexExprNode<R1>> for IndexExprNode<R2> { | ||
1290 | fn eq(&self, other: &IndexExprNode<R1>) -> bool { self.syntax == other.syntax } | ||
1291 | } | ||
1292 | impl<R: TreeRoot<RaTypes>> Eq for IndexExprNode<R> {} | ||
1293 | impl<R: TreeRoot<RaTypes>> Hash for IndexExprNode<R> { | ||
1294 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
1295 | } | ||
1296 | |||
1055 | impl<'a> AstNode<'a> for IndexExpr<'a> { | 1297 | impl<'a> AstNode<'a> for IndexExpr<'a> { |
1056 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1298 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1057 | match syntax.kind() { | 1299 | match syntax.kind() { |
@@ -1075,12 +1317,20 @@ impl<R: TreeRoot<RaTypes>> IndexExprNode<R> { | |||
1075 | impl<'a> IndexExpr<'a> {} | 1317 | impl<'a> IndexExpr<'a> {} |
1076 | 1318 | ||
1077 | // ItemList | 1319 | // ItemList |
1078 | #[derive(Debug, Clone, Copy)] | 1320 | #[derive(Debug, Clone, Copy,)] |
1079 | pub struct ItemListNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 1321 | pub struct ItemListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1080 | syntax: SyntaxNode<R>, | 1322 | pub(crate) syntax: SyntaxNode<R>, |
1081 | } | 1323 | } |
1082 | pub type ItemList<'a> = ItemListNode<RefRoot<'a>>; | 1324 | pub type ItemList<'a> = ItemListNode<RefRoot<'a>>; |
1083 | 1325 | ||
1326 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ItemListNode<R1>> for ItemListNode<R2> { | ||
1327 | fn eq(&self, other: &ItemListNode<R1>) -> bool { self.syntax == other.syntax } | ||
1328 | } | ||
1329 | impl<R: TreeRoot<RaTypes>> Eq for ItemListNode<R> {} | ||
1330 | impl<R: TreeRoot<RaTypes>> Hash for ItemListNode<R> { | ||
1331 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
1332 | } | ||
1333 | |||
1084 | impl<'a> AstNode<'a> for ItemList<'a> { | 1334 | impl<'a> AstNode<'a> for ItemList<'a> { |
1085 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1335 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1086 | match syntax.kind() { | 1336 | match syntax.kind() { |
@@ -1106,12 +1356,20 @@ impl<'a> ast::ModuleItemOwner<'a> for ItemList<'a> {} | |||
1106 | impl<'a> ItemList<'a> {} | 1356 | impl<'a> ItemList<'a> {} |
1107 | 1357 | ||
1108 | // Label | 1358 | // Label |
1109 | #[derive(Debug, Clone, Copy)] | 1359 | #[derive(Debug, Clone, Copy,)] |
1110 | pub struct LabelNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 1360 | pub struct LabelNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1111 | syntax: SyntaxNode<R>, | 1361 | pub(crate) syntax: SyntaxNode<R>, |
1112 | } | 1362 | } |
1113 | pub type Label<'a> = LabelNode<RefRoot<'a>>; | 1363 | pub type Label<'a> = LabelNode<RefRoot<'a>>; |
1114 | 1364 | ||
1365 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<LabelNode<R1>> for LabelNode<R2> { | ||
1366 | fn eq(&self, other: &LabelNode<R1>) -> bool { self.syntax == other.syntax } | ||
1367 | } | ||
1368 | impl<R: TreeRoot<RaTypes>> Eq for LabelNode<R> {} | ||
1369 | impl<R: TreeRoot<RaTypes>> Hash for LabelNode<R> { | ||
1370 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
1371 | } | ||
1372 | |||
1115 | impl<'a> AstNode<'a> for Label<'a> { | 1373 | impl<'a> AstNode<'a> for Label<'a> { |
1116 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1374 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1117 | match syntax.kind() { | 1375 | match syntax.kind() { |
@@ -1135,12 +1393,20 @@ impl<R: TreeRoot<RaTypes>> LabelNode<R> { | |||
1135 | impl<'a> Label<'a> {} | 1393 | impl<'a> Label<'a> {} |
1136 | 1394 | ||
1137 | // LambdaExpr | 1395 | // LambdaExpr |
1138 | #[derive(Debug, Clone, Copy)] | 1396 | #[derive(Debug, Clone, Copy,)] |
1139 | pub struct LambdaExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 1397 | pub struct LambdaExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1140 | syntax: SyntaxNode<R>, | 1398 | pub(crate) syntax: SyntaxNode<R>, |
1141 | } | 1399 | } |
1142 | pub type LambdaExpr<'a> = LambdaExprNode<RefRoot<'a>>; | 1400 | pub type LambdaExpr<'a> = LambdaExprNode<RefRoot<'a>>; |
1143 | 1401 | ||
1402 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<LambdaExprNode<R1>> for LambdaExprNode<R2> { | ||
1403 | fn eq(&self, other: &LambdaExprNode<R1>) -> bool { self.syntax == other.syntax } | ||
1404 | } | ||
1405 | impl<R: TreeRoot<RaTypes>> Eq for LambdaExprNode<R> {} | ||
1406 | impl<R: TreeRoot<RaTypes>> Hash for LambdaExprNode<R> { | ||
1407 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
1408 | } | ||
1409 | |||
1144 | impl<'a> AstNode<'a> for LambdaExpr<'a> { | 1410 | impl<'a> AstNode<'a> for LambdaExpr<'a> { |
1145 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1411 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1146 | match syntax.kind() { | 1412 | match syntax.kind() { |
@@ -1172,12 +1438,20 @@ impl<'a> LambdaExpr<'a> { | |||
1172 | } | 1438 | } |
1173 | 1439 | ||
1174 | // LetStmt | 1440 | // LetStmt |
1175 | #[derive(Debug, Clone, Copy)] | 1441 | #[derive(Debug, Clone, Copy,)] |
1176 | pub struct LetStmtNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 1442 | pub struct LetStmtNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1177 | syntax: SyntaxNode<R>, | 1443 | pub(crate) syntax: SyntaxNode<R>, |
1178 | } | 1444 | } |
1179 | pub type LetStmt<'a> = LetStmtNode<RefRoot<'a>>; | 1445 | pub type LetStmt<'a> = LetStmtNode<RefRoot<'a>>; |
1180 | 1446 | ||
1447 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<LetStmtNode<R1>> for LetStmtNode<R2> { | ||
1448 | fn eq(&self, other: &LetStmtNode<R1>) -> bool { self.syntax == other.syntax } | ||
1449 | } | ||
1450 | impl<R: TreeRoot<RaTypes>> Eq for LetStmtNode<R> {} | ||
1451 | impl<R: TreeRoot<RaTypes>> Hash for LetStmtNode<R> { | ||
1452 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
1453 | } | ||
1454 | |||
1181 | impl<'a> AstNode<'a> for LetStmt<'a> { | 1455 | impl<'a> AstNode<'a> for LetStmt<'a> { |
1182 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1456 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1183 | match syntax.kind() { | 1457 | match syntax.kind() { |
@@ -1209,12 +1483,20 @@ impl<'a> LetStmt<'a> { | |||
1209 | } | 1483 | } |
1210 | 1484 | ||
1211 | // Lifetime | 1485 | // Lifetime |
1212 | #[derive(Debug, Clone, Copy)] | 1486 | #[derive(Debug, Clone, Copy,)] |
1213 | pub struct LifetimeNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 1487 | pub struct LifetimeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1214 | syntax: SyntaxNode<R>, | 1488 | pub(crate) syntax: SyntaxNode<R>, |
1215 | } | 1489 | } |
1216 | pub type Lifetime<'a> = LifetimeNode<RefRoot<'a>>; | 1490 | pub type Lifetime<'a> = LifetimeNode<RefRoot<'a>>; |
1217 | 1491 | ||
1492 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<LifetimeNode<R1>> for LifetimeNode<R2> { | ||
1493 | fn eq(&self, other: &LifetimeNode<R1>) -> bool { self.syntax == other.syntax } | ||
1494 | } | ||
1495 | impl<R: TreeRoot<RaTypes>> Eq for LifetimeNode<R> {} | ||
1496 | impl<R: TreeRoot<RaTypes>> Hash for LifetimeNode<R> { | ||
1497 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
1498 | } | ||
1499 | |||
1218 | impl<'a> AstNode<'a> for Lifetime<'a> { | 1500 | impl<'a> AstNode<'a> for Lifetime<'a> { |
1219 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1501 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1220 | match syntax.kind() { | 1502 | match syntax.kind() { |
@@ -1238,12 +1520,20 @@ impl<R: TreeRoot<RaTypes>> LifetimeNode<R> { | |||
1238 | impl<'a> Lifetime<'a> {} | 1520 | impl<'a> Lifetime<'a> {} |
1239 | 1521 | ||
1240 | // LifetimeParam | 1522 | // LifetimeParam |
1241 | #[derive(Debug, Clone, Copy)] | 1523 | #[derive(Debug, Clone, Copy,)] |
1242 | pub struct LifetimeParamNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 1524 | pub struct LifetimeParamNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1243 | syntax: SyntaxNode<R>, | 1525 | pub(crate) syntax: SyntaxNode<R>, |
1244 | } | 1526 | } |
1245 | pub type LifetimeParam<'a> = LifetimeParamNode<RefRoot<'a>>; | 1527 | pub type LifetimeParam<'a> = LifetimeParamNode<RefRoot<'a>>; |
1246 | 1528 | ||
1529 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<LifetimeParamNode<R1>> for LifetimeParamNode<R2> { | ||
1530 | fn eq(&self, other: &LifetimeParamNode<R1>) -> bool { self.syntax == other.syntax } | ||
1531 | } | ||
1532 | impl<R: TreeRoot<RaTypes>> Eq for LifetimeParamNode<R> {} | ||
1533 | impl<R: TreeRoot<RaTypes>> Hash for LifetimeParamNode<R> { | ||
1534 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
1535 | } | ||
1536 | |||
1247 | impl<'a> AstNode<'a> for LifetimeParam<'a> { | 1537 | impl<'a> AstNode<'a> for LifetimeParam<'a> { |
1248 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1538 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1249 | match syntax.kind() { | 1539 | match syntax.kind() { |
@@ -1271,12 +1561,20 @@ impl<'a> LifetimeParam<'a> { | |||
1271 | } | 1561 | } |
1272 | 1562 | ||
1273 | // Literal | 1563 | // Literal |
1274 | #[derive(Debug, Clone, Copy)] | 1564 | #[derive(Debug, Clone, Copy,)] |
1275 | pub struct LiteralNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 1565 | pub struct LiteralNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1276 | syntax: SyntaxNode<R>, | 1566 | pub(crate) syntax: SyntaxNode<R>, |
1277 | } | 1567 | } |
1278 | pub type Literal<'a> = LiteralNode<RefRoot<'a>>; | 1568 | pub type Literal<'a> = LiteralNode<RefRoot<'a>>; |
1279 | 1569 | ||
1570 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<LiteralNode<R1>> for LiteralNode<R2> { | ||
1571 | fn eq(&self, other: &LiteralNode<R1>) -> bool { self.syntax == other.syntax } | ||
1572 | } | ||
1573 | impl<R: TreeRoot<RaTypes>> Eq for LiteralNode<R> {} | ||
1574 | impl<R: TreeRoot<RaTypes>> Hash for LiteralNode<R> { | ||
1575 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
1576 | } | ||
1577 | |||
1280 | impl<'a> AstNode<'a> for Literal<'a> { | 1578 | impl<'a> AstNode<'a> for Literal<'a> { |
1281 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1579 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1282 | match syntax.kind() { | 1580 | match syntax.kind() { |
@@ -1300,12 +1598,20 @@ impl<R: TreeRoot<RaTypes>> LiteralNode<R> { | |||
1300 | impl<'a> Literal<'a> {} | 1598 | impl<'a> Literal<'a> {} |
1301 | 1599 | ||
1302 | // LoopExpr | 1600 | // LoopExpr |
1303 | #[derive(Debug, Clone, Copy)] | 1601 | #[derive(Debug, Clone, Copy,)] |
1304 | pub struct LoopExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 1602 | pub struct LoopExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1305 | syntax: SyntaxNode<R>, | 1603 | pub(crate) syntax: SyntaxNode<R>, |
1306 | } | 1604 | } |
1307 | pub type LoopExpr<'a> = LoopExprNode<RefRoot<'a>>; | 1605 | pub type LoopExpr<'a> = LoopExprNode<RefRoot<'a>>; |
1308 | 1606 | ||
1607 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<LoopExprNode<R1>> for LoopExprNode<R2> { | ||
1608 | fn eq(&self, other: &LoopExprNode<R1>) -> bool { self.syntax == other.syntax } | ||
1609 | } | ||
1610 | impl<R: TreeRoot<RaTypes>> Eq for LoopExprNode<R> {} | ||
1611 | impl<R: TreeRoot<RaTypes>> Hash for LoopExprNode<R> { | ||
1612 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
1613 | } | ||
1614 | |||
1309 | impl<'a> AstNode<'a> for LoopExpr<'a> { | 1615 | impl<'a> AstNode<'a> for LoopExpr<'a> { |
1310 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1616 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1311 | match syntax.kind() { | 1617 | match syntax.kind() { |
@@ -1330,12 +1636,20 @@ impl<'a> ast::LoopBodyOwner<'a> for LoopExpr<'a> {} | |||
1330 | impl<'a> LoopExpr<'a> {} | 1636 | impl<'a> LoopExpr<'a> {} |
1331 | 1637 | ||
1332 | // MatchArm | 1638 | // MatchArm |
1333 | #[derive(Debug, Clone, Copy)] | 1639 | #[derive(Debug, Clone, Copy,)] |
1334 | pub struct MatchArmNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 1640 | pub struct MatchArmNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1335 | syntax: SyntaxNode<R>, | 1641 | pub(crate) syntax: SyntaxNode<R>, |
1336 | } | 1642 | } |
1337 | pub type MatchArm<'a> = MatchArmNode<RefRoot<'a>>; | 1643 | pub type MatchArm<'a> = MatchArmNode<RefRoot<'a>>; |
1338 | 1644 | ||
1645 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<MatchArmNode<R1>> for MatchArmNode<R2> { | ||
1646 | fn eq(&self, other: &MatchArmNode<R1>) -> bool { self.syntax == other.syntax } | ||
1647 | } | ||
1648 | impl<R: TreeRoot<RaTypes>> Eq for MatchArmNode<R> {} | ||
1649 | impl<R: TreeRoot<RaTypes>> Hash for MatchArmNode<R> { | ||
1650 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
1651 | } | ||
1652 | |||
1339 | impl<'a> AstNode<'a> for MatchArm<'a> { | 1653 | impl<'a> AstNode<'a> for MatchArm<'a> { |
1340 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1654 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1341 | match syntax.kind() { | 1655 | match syntax.kind() { |
@@ -1371,12 +1685,20 @@ impl<'a> MatchArm<'a> { | |||
1371 | } | 1685 | } |
1372 | 1686 | ||
1373 | // MatchArmList | 1687 | // MatchArmList |
1374 | #[derive(Debug, Clone, Copy)] | 1688 | #[derive(Debug, Clone, Copy,)] |
1375 | pub struct MatchArmListNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 1689 | pub struct MatchArmListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1376 | syntax: SyntaxNode<R>, | 1690 | pub(crate) syntax: SyntaxNode<R>, |
1377 | } | 1691 | } |
1378 | pub type MatchArmList<'a> = MatchArmListNode<RefRoot<'a>>; | 1692 | pub type MatchArmList<'a> = MatchArmListNode<RefRoot<'a>>; |
1379 | 1693 | ||
1694 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<MatchArmListNode<R1>> for MatchArmListNode<R2> { | ||
1695 | fn eq(&self, other: &MatchArmListNode<R1>) -> bool { self.syntax == other.syntax } | ||
1696 | } | ||
1697 | impl<R: TreeRoot<RaTypes>> Eq for MatchArmListNode<R> {} | ||
1698 | impl<R: TreeRoot<RaTypes>> Hash for MatchArmListNode<R> { | ||
1699 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
1700 | } | ||
1701 | |||
1380 | impl<'a> AstNode<'a> for MatchArmList<'a> { | 1702 | impl<'a> AstNode<'a> for MatchArmList<'a> { |
1381 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1703 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1382 | match syntax.kind() { | 1704 | match syntax.kind() { |
@@ -1404,12 +1726,20 @@ impl<'a> MatchArmList<'a> { | |||
1404 | } | 1726 | } |
1405 | 1727 | ||
1406 | // MatchExpr | 1728 | // MatchExpr |
1407 | #[derive(Debug, Clone, Copy)] | 1729 | #[derive(Debug, Clone, Copy,)] |
1408 | pub struct MatchExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 1730 | pub struct MatchExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1409 | syntax: SyntaxNode<R>, | 1731 | pub(crate) syntax: SyntaxNode<R>, |
1410 | } | 1732 | } |
1411 | pub type MatchExpr<'a> = MatchExprNode<RefRoot<'a>>; | 1733 | pub type MatchExpr<'a> = MatchExprNode<RefRoot<'a>>; |
1412 | 1734 | ||
1735 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<MatchExprNode<R1>> for MatchExprNode<R2> { | ||
1736 | fn eq(&self, other: &MatchExprNode<R1>) -> bool { self.syntax == other.syntax } | ||
1737 | } | ||
1738 | impl<R: TreeRoot<RaTypes>> Eq for MatchExprNode<R> {} | ||
1739 | impl<R: TreeRoot<RaTypes>> Hash for MatchExprNode<R> { | ||
1740 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
1741 | } | ||
1742 | |||
1413 | impl<'a> AstNode<'a> for MatchExpr<'a> { | 1743 | impl<'a> AstNode<'a> for MatchExpr<'a> { |
1414 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1744 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1415 | match syntax.kind() { | 1745 | match syntax.kind() { |
@@ -1441,12 +1771,20 @@ impl<'a> MatchExpr<'a> { | |||
1441 | } | 1771 | } |
1442 | 1772 | ||
1443 | // MatchGuard | 1773 | // MatchGuard |
1444 | #[derive(Debug, Clone, Copy)] | 1774 | #[derive(Debug, Clone, Copy,)] |
1445 | pub struct MatchGuardNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 1775 | pub struct MatchGuardNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1446 | syntax: SyntaxNode<R>, | 1776 | pub(crate) syntax: SyntaxNode<R>, |
1447 | } | 1777 | } |
1448 | pub type MatchGuard<'a> = MatchGuardNode<RefRoot<'a>>; | 1778 | pub type MatchGuard<'a> = MatchGuardNode<RefRoot<'a>>; |
1449 | 1779 | ||
1780 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<MatchGuardNode<R1>> for MatchGuardNode<R2> { | ||
1781 | fn eq(&self, other: &MatchGuardNode<R1>) -> bool { self.syntax == other.syntax } | ||
1782 | } | ||
1783 | impl<R: TreeRoot<RaTypes>> Eq for MatchGuardNode<R> {} | ||
1784 | impl<R: TreeRoot<RaTypes>> Hash for MatchGuardNode<R> { | ||
1785 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
1786 | } | ||
1787 | |||
1450 | impl<'a> AstNode<'a> for MatchGuard<'a> { | 1788 | impl<'a> AstNode<'a> for MatchGuard<'a> { |
1451 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1789 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1452 | match syntax.kind() { | 1790 | match syntax.kind() { |
@@ -1470,12 +1808,20 @@ impl<R: TreeRoot<RaTypes>> MatchGuardNode<R> { | |||
1470 | impl<'a> MatchGuard<'a> {} | 1808 | impl<'a> MatchGuard<'a> {} |
1471 | 1809 | ||
1472 | // MethodCallExpr | 1810 | // MethodCallExpr |
1473 | #[derive(Debug, Clone, Copy)] | 1811 | #[derive(Debug, Clone, Copy,)] |
1474 | pub struct MethodCallExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 1812 | pub struct MethodCallExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1475 | syntax: SyntaxNode<R>, | 1813 | pub(crate) syntax: SyntaxNode<R>, |
1476 | } | 1814 | } |
1477 | pub type MethodCallExpr<'a> = MethodCallExprNode<RefRoot<'a>>; | 1815 | pub type MethodCallExpr<'a> = MethodCallExprNode<RefRoot<'a>>; |
1478 | 1816 | ||
1817 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<MethodCallExprNode<R1>> for MethodCallExprNode<R2> { | ||
1818 | fn eq(&self, other: &MethodCallExprNode<R1>) -> bool { self.syntax == other.syntax } | ||
1819 | } | ||
1820 | impl<R: TreeRoot<RaTypes>> Eq for MethodCallExprNode<R> {} | ||
1821 | impl<R: TreeRoot<RaTypes>> Hash for MethodCallExprNode<R> { | ||
1822 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
1823 | } | ||
1824 | |||
1479 | impl<'a> AstNode<'a> for MethodCallExpr<'a> { | 1825 | impl<'a> AstNode<'a> for MethodCallExpr<'a> { |
1480 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1826 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1481 | match syntax.kind() { | 1827 | match syntax.kind() { |
@@ -1504,12 +1850,20 @@ impl<'a> MethodCallExpr<'a> { | |||
1504 | } | 1850 | } |
1505 | 1851 | ||
1506 | // Module | 1852 | // Module |
1507 | #[derive(Debug, Clone, Copy)] | 1853 | #[derive(Debug, Clone, Copy,)] |
1508 | pub struct ModuleNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 1854 | pub struct ModuleNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1509 | syntax: SyntaxNode<R>, | 1855 | pub(crate) syntax: SyntaxNode<R>, |
1510 | } | 1856 | } |
1511 | pub type Module<'a> = ModuleNode<RefRoot<'a>>; | 1857 | pub type Module<'a> = ModuleNode<RefRoot<'a>>; |
1512 | 1858 | ||
1859 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ModuleNode<R1>> for ModuleNode<R2> { | ||
1860 | fn eq(&self, other: &ModuleNode<R1>) -> bool { self.syntax == other.syntax } | ||
1861 | } | ||
1862 | impl<R: TreeRoot<RaTypes>> Eq for ModuleNode<R> {} | ||
1863 | impl<R: TreeRoot<RaTypes>> Hash for ModuleNode<R> { | ||
1864 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
1865 | } | ||
1866 | |||
1513 | impl<'a> AstNode<'a> for Module<'a> { | 1867 | impl<'a> AstNode<'a> for Module<'a> { |
1514 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1868 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1515 | match syntax.kind() { | 1869 | match syntax.kind() { |
@@ -1539,7 +1893,7 @@ impl<'a> Module<'a> { | |||
1539 | } | 1893 | } |
1540 | 1894 | ||
1541 | // ModuleItem | 1895 | // ModuleItem |
1542 | #[derive(Debug, Clone, Copy)] | 1896 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
1543 | pub enum ModuleItem<'a> { | 1897 | pub enum ModuleItem<'a> { |
1544 | StructDef(StructDef<'a>), | 1898 | StructDef(StructDef<'a>), |
1545 | EnumDef(EnumDef<'a>), | 1899 | EnumDef(EnumDef<'a>), |
@@ -1591,12 +1945,20 @@ impl<'a> AstNode<'a> for ModuleItem<'a> { | |||
1591 | impl<'a> ModuleItem<'a> {} | 1945 | impl<'a> ModuleItem<'a> {} |
1592 | 1946 | ||
1593 | // Name | 1947 | // Name |
1594 | #[derive(Debug, Clone, Copy)] | 1948 | #[derive(Debug, Clone, Copy,)] |
1595 | pub struct NameNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 1949 | pub struct NameNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1596 | syntax: SyntaxNode<R>, | 1950 | pub(crate) syntax: SyntaxNode<R>, |
1597 | } | 1951 | } |
1598 | pub type Name<'a> = NameNode<RefRoot<'a>>; | 1952 | pub type Name<'a> = NameNode<RefRoot<'a>>; |
1599 | 1953 | ||
1954 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<NameNode<R1>> for NameNode<R2> { | ||
1955 | fn eq(&self, other: &NameNode<R1>) -> bool { self.syntax == other.syntax } | ||
1956 | } | ||
1957 | impl<R: TreeRoot<RaTypes>> Eq for NameNode<R> {} | ||
1958 | impl<R: TreeRoot<RaTypes>> Hash for NameNode<R> { | ||
1959 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
1960 | } | ||
1961 | |||
1600 | impl<'a> AstNode<'a> for Name<'a> { | 1962 | impl<'a> AstNode<'a> for Name<'a> { |
1601 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1963 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1602 | match syntax.kind() { | 1964 | match syntax.kind() { |
@@ -1620,12 +1982,20 @@ impl<R: TreeRoot<RaTypes>> NameNode<R> { | |||
1620 | impl<'a> Name<'a> {} | 1982 | impl<'a> Name<'a> {} |
1621 | 1983 | ||
1622 | // NameRef | 1984 | // NameRef |
1623 | #[derive(Debug, Clone, Copy)] | 1985 | #[derive(Debug, Clone, Copy,)] |
1624 | pub struct NameRefNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 1986 | pub struct NameRefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1625 | syntax: SyntaxNode<R>, | 1987 | pub(crate) syntax: SyntaxNode<R>, |
1626 | } | 1988 | } |
1627 | pub type NameRef<'a> = NameRefNode<RefRoot<'a>>; | 1989 | pub type NameRef<'a> = NameRefNode<RefRoot<'a>>; |
1628 | 1990 | ||
1991 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<NameRefNode<R1>> for NameRefNode<R2> { | ||
1992 | fn eq(&self, other: &NameRefNode<R1>) -> bool { self.syntax == other.syntax } | ||
1993 | } | ||
1994 | impl<R: TreeRoot<RaTypes>> Eq for NameRefNode<R> {} | ||
1995 | impl<R: TreeRoot<RaTypes>> Hash for NameRefNode<R> { | ||
1996 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
1997 | } | ||
1998 | |||
1629 | impl<'a> AstNode<'a> for NameRef<'a> { | 1999 | impl<'a> AstNode<'a> for NameRef<'a> { |
1630 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2000 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1631 | match syntax.kind() { | 2001 | match syntax.kind() { |
@@ -1649,12 +2019,20 @@ impl<R: TreeRoot<RaTypes>> NameRefNode<R> { | |||
1649 | impl<'a> NameRef<'a> {} | 2019 | impl<'a> NameRef<'a> {} |
1650 | 2020 | ||
1651 | // NamedField | 2021 | // NamedField |
1652 | #[derive(Debug, Clone, Copy)] | 2022 | #[derive(Debug, Clone, Copy,)] |
1653 | pub struct NamedFieldNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 2023 | pub struct NamedFieldNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1654 | syntax: SyntaxNode<R>, | 2024 | pub(crate) syntax: SyntaxNode<R>, |
1655 | } | 2025 | } |
1656 | pub type NamedField<'a> = NamedFieldNode<RefRoot<'a>>; | 2026 | pub type NamedField<'a> = NamedFieldNode<RefRoot<'a>>; |
1657 | 2027 | ||
2028 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<NamedFieldNode<R1>> for NamedFieldNode<R2> { | ||
2029 | fn eq(&self, other: &NamedFieldNode<R1>) -> bool { self.syntax == other.syntax } | ||
2030 | } | ||
2031 | impl<R: TreeRoot<RaTypes>> Eq for NamedFieldNode<R> {} | ||
2032 | impl<R: TreeRoot<RaTypes>> Hash for NamedFieldNode<R> { | ||
2033 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
2034 | } | ||
2035 | |||
1658 | impl<'a> AstNode<'a> for NamedField<'a> { | 2036 | impl<'a> AstNode<'a> for NamedField<'a> { |
1659 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2037 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1660 | match syntax.kind() { | 2038 | match syntax.kind() { |
@@ -1678,12 +2056,20 @@ impl<R: TreeRoot<RaTypes>> NamedFieldNode<R> { | |||
1678 | impl<'a> NamedField<'a> {} | 2056 | impl<'a> NamedField<'a> {} |
1679 | 2057 | ||
1680 | // NamedFieldDef | 2058 | // NamedFieldDef |
1681 | #[derive(Debug, Clone, Copy)] | 2059 | #[derive(Debug, Clone, Copy,)] |
1682 | pub struct NamedFieldDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 2060 | pub struct NamedFieldDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1683 | syntax: SyntaxNode<R>, | 2061 | pub(crate) syntax: SyntaxNode<R>, |
1684 | } | 2062 | } |
1685 | pub type NamedFieldDef<'a> = NamedFieldDefNode<RefRoot<'a>>; | 2063 | pub type NamedFieldDef<'a> = NamedFieldDefNode<RefRoot<'a>>; |
1686 | 2064 | ||
2065 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<NamedFieldDefNode<R1>> for NamedFieldDefNode<R2> { | ||
2066 | fn eq(&self, other: &NamedFieldDefNode<R1>) -> bool { self.syntax == other.syntax } | ||
2067 | } | ||
2068 | impl<R: TreeRoot<RaTypes>> Eq for NamedFieldDefNode<R> {} | ||
2069 | impl<R: TreeRoot<RaTypes>> Hash for NamedFieldDefNode<R> { | ||
2070 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
2071 | } | ||
2072 | |||
1687 | impl<'a> AstNode<'a> for NamedFieldDef<'a> { | 2073 | impl<'a> AstNode<'a> for NamedFieldDef<'a> { |
1688 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2074 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1689 | match syntax.kind() { | 2075 | match syntax.kind() { |
@@ -1709,12 +2095,20 @@ impl<'a> ast::AttrsOwner<'a> for NamedFieldDef<'a> {} | |||
1709 | impl<'a> NamedFieldDef<'a> {} | 2095 | impl<'a> NamedFieldDef<'a> {} |
1710 | 2096 | ||
1711 | // NamedFieldList | 2097 | // NamedFieldList |
1712 | #[derive(Debug, Clone, Copy)] | 2098 | #[derive(Debug, Clone, Copy,)] |
1713 | pub struct NamedFieldListNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 2099 | pub struct NamedFieldListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1714 | syntax: SyntaxNode<R>, | 2100 | pub(crate) syntax: SyntaxNode<R>, |
1715 | } | 2101 | } |
1716 | pub type NamedFieldList<'a> = NamedFieldListNode<RefRoot<'a>>; | 2102 | pub type NamedFieldList<'a> = NamedFieldListNode<RefRoot<'a>>; |
1717 | 2103 | ||
2104 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<NamedFieldListNode<R1>> for NamedFieldListNode<R2> { | ||
2105 | fn eq(&self, other: &NamedFieldListNode<R1>) -> bool { self.syntax == other.syntax } | ||
2106 | } | ||
2107 | impl<R: TreeRoot<RaTypes>> Eq for NamedFieldListNode<R> {} | ||
2108 | impl<R: TreeRoot<RaTypes>> Hash for NamedFieldListNode<R> { | ||
2109 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
2110 | } | ||
2111 | |||
1718 | impl<'a> AstNode<'a> for NamedFieldList<'a> { | 2112 | impl<'a> AstNode<'a> for NamedFieldList<'a> { |
1719 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2113 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1720 | match syntax.kind() { | 2114 | match syntax.kind() { |
@@ -1738,12 +2132,20 @@ impl<R: TreeRoot<RaTypes>> NamedFieldListNode<R> { | |||
1738 | impl<'a> NamedFieldList<'a> {} | 2132 | impl<'a> NamedFieldList<'a> {} |
1739 | 2133 | ||
1740 | // NeverType | 2134 | // NeverType |
1741 | #[derive(Debug, Clone, Copy)] | 2135 | #[derive(Debug, Clone, Copy,)] |
1742 | pub struct NeverTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 2136 | pub struct NeverTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1743 | syntax: SyntaxNode<R>, | 2137 | pub(crate) syntax: SyntaxNode<R>, |
1744 | } | 2138 | } |
1745 | pub type NeverType<'a> = NeverTypeNode<RefRoot<'a>>; | 2139 | pub type NeverType<'a> = NeverTypeNode<RefRoot<'a>>; |
1746 | 2140 | ||
2141 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<NeverTypeNode<R1>> for NeverTypeNode<R2> { | ||
2142 | fn eq(&self, other: &NeverTypeNode<R1>) -> bool { self.syntax == other.syntax } | ||
2143 | } | ||
2144 | impl<R: TreeRoot<RaTypes>> Eq for NeverTypeNode<R> {} | ||
2145 | impl<R: TreeRoot<RaTypes>> Hash for NeverTypeNode<R> { | ||
2146 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
2147 | } | ||
2148 | |||
1747 | impl<'a> AstNode<'a> for NeverType<'a> { | 2149 | impl<'a> AstNode<'a> for NeverType<'a> { |
1748 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2150 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1749 | match syntax.kind() { | 2151 | match syntax.kind() { |
@@ -1767,7 +2169,7 @@ impl<R: TreeRoot<RaTypes>> NeverTypeNode<R> { | |||
1767 | impl<'a> NeverType<'a> {} | 2169 | impl<'a> NeverType<'a> {} |
1768 | 2170 | ||
1769 | // NominalDef | 2171 | // NominalDef |
1770 | #[derive(Debug, Clone, Copy)] | 2172 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
1771 | pub enum NominalDef<'a> { | 2173 | pub enum NominalDef<'a> { |
1772 | StructDef(StructDef<'a>), | 2174 | StructDef(StructDef<'a>), |
1773 | EnumDef(EnumDef<'a>), | 2175 | EnumDef(EnumDef<'a>), |
@@ -1795,12 +2197,20 @@ impl<'a> ast::AttrsOwner<'a> for NominalDef<'a> {} | |||
1795 | impl<'a> NominalDef<'a> {} | 2197 | impl<'a> NominalDef<'a> {} |
1796 | 2198 | ||
1797 | // Param | 2199 | // Param |
1798 | #[derive(Debug, Clone, Copy)] | 2200 | #[derive(Debug, Clone, Copy,)] |
1799 | pub struct ParamNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 2201 | pub struct ParamNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1800 | syntax: SyntaxNode<R>, | 2202 | pub(crate) syntax: SyntaxNode<R>, |
1801 | } | 2203 | } |
1802 | pub type Param<'a> = ParamNode<RefRoot<'a>>; | 2204 | pub type Param<'a> = ParamNode<RefRoot<'a>>; |
1803 | 2205 | ||
2206 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ParamNode<R1>> for ParamNode<R2> { | ||
2207 | fn eq(&self, other: &ParamNode<R1>) -> bool { self.syntax == other.syntax } | ||
2208 | } | ||
2209 | impl<R: TreeRoot<RaTypes>> Eq for ParamNode<R> {} | ||
2210 | impl<R: TreeRoot<RaTypes>> Hash for ParamNode<R> { | ||
2211 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
2212 | } | ||
2213 | |||
1804 | impl<'a> AstNode<'a> for Param<'a> { | 2214 | impl<'a> AstNode<'a> for Param<'a> { |
1805 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2215 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1806 | match syntax.kind() { | 2216 | match syntax.kind() { |
@@ -1828,12 +2238,20 @@ impl<'a> Param<'a> { | |||
1828 | } | 2238 | } |
1829 | 2239 | ||
1830 | // ParamList | 2240 | // ParamList |
1831 | #[derive(Debug, Clone, Copy)] | 2241 | #[derive(Debug, Clone, Copy,)] |
1832 | pub struct ParamListNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 2242 | pub struct ParamListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1833 | syntax: SyntaxNode<R>, | 2243 | pub(crate) syntax: SyntaxNode<R>, |
1834 | } | 2244 | } |
1835 | pub type ParamList<'a> = ParamListNode<RefRoot<'a>>; | 2245 | pub type ParamList<'a> = ParamListNode<RefRoot<'a>>; |
1836 | 2246 | ||
2247 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ParamListNode<R1>> for ParamListNode<R2> { | ||
2248 | fn eq(&self, other: &ParamListNode<R1>) -> bool { self.syntax == other.syntax } | ||
2249 | } | ||
2250 | impl<R: TreeRoot<RaTypes>> Eq for ParamListNode<R> {} | ||
2251 | impl<R: TreeRoot<RaTypes>> Hash for ParamListNode<R> { | ||
2252 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
2253 | } | ||
2254 | |||
1837 | impl<'a> AstNode<'a> for ParamList<'a> { | 2255 | impl<'a> AstNode<'a> for ParamList<'a> { |
1838 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2256 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1839 | match syntax.kind() { | 2257 | match syntax.kind() { |
@@ -1865,12 +2283,20 @@ impl<'a> ParamList<'a> { | |||
1865 | } | 2283 | } |
1866 | 2284 | ||
1867 | // ParenExpr | 2285 | // ParenExpr |
1868 | #[derive(Debug, Clone, Copy)] | 2286 | #[derive(Debug, Clone, Copy,)] |
1869 | pub struct ParenExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 2287 | pub struct ParenExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1870 | syntax: SyntaxNode<R>, | 2288 | pub(crate) syntax: SyntaxNode<R>, |
1871 | } | 2289 | } |
1872 | pub type ParenExpr<'a> = ParenExprNode<RefRoot<'a>>; | 2290 | pub type ParenExpr<'a> = ParenExprNode<RefRoot<'a>>; |
1873 | 2291 | ||
2292 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ParenExprNode<R1>> for ParenExprNode<R2> { | ||
2293 | fn eq(&self, other: &ParenExprNode<R1>) -> bool { self.syntax == other.syntax } | ||
2294 | } | ||
2295 | impl<R: TreeRoot<RaTypes>> Eq for ParenExprNode<R> {} | ||
2296 | impl<R: TreeRoot<RaTypes>> Hash for ParenExprNode<R> { | ||
2297 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
2298 | } | ||
2299 | |||
1874 | impl<'a> AstNode<'a> for ParenExpr<'a> { | 2300 | impl<'a> AstNode<'a> for ParenExpr<'a> { |
1875 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2301 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1876 | match syntax.kind() { | 2302 | match syntax.kind() { |
@@ -1894,12 +2320,20 @@ impl<R: TreeRoot<RaTypes>> ParenExprNode<R> { | |||
1894 | impl<'a> ParenExpr<'a> {} | 2320 | impl<'a> ParenExpr<'a> {} |
1895 | 2321 | ||
1896 | // ParenType | 2322 | // ParenType |
1897 | #[derive(Debug, Clone, Copy)] | 2323 | #[derive(Debug, Clone, Copy,)] |
1898 | pub struct ParenTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 2324 | pub struct ParenTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1899 | syntax: SyntaxNode<R>, | 2325 | pub(crate) syntax: SyntaxNode<R>, |
1900 | } | 2326 | } |
1901 | pub type ParenType<'a> = ParenTypeNode<RefRoot<'a>>; | 2327 | pub type ParenType<'a> = ParenTypeNode<RefRoot<'a>>; |
1902 | 2328 | ||
2329 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ParenTypeNode<R1>> for ParenTypeNode<R2> { | ||
2330 | fn eq(&self, other: &ParenTypeNode<R1>) -> bool { self.syntax == other.syntax } | ||
2331 | } | ||
2332 | impl<R: TreeRoot<RaTypes>> Eq for ParenTypeNode<R> {} | ||
2333 | impl<R: TreeRoot<RaTypes>> Hash for ParenTypeNode<R> { | ||
2334 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
2335 | } | ||
2336 | |||
1903 | impl<'a> AstNode<'a> for ParenType<'a> { | 2337 | impl<'a> AstNode<'a> for ParenType<'a> { |
1904 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2338 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1905 | match syntax.kind() { | 2339 | match syntax.kind() { |
@@ -1923,7 +2357,7 @@ impl<R: TreeRoot<RaTypes>> ParenTypeNode<R> { | |||
1923 | impl<'a> ParenType<'a> {} | 2357 | impl<'a> ParenType<'a> {} |
1924 | 2358 | ||
1925 | // Pat | 2359 | // Pat |
1926 | #[derive(Debug, Clone, Copy)] | 2360 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
1927 | pub enum Pat<'a> { | 2361 | pub enum Pat<'a> { |
1928 | RefPat(RefPat<'a>), | 2362 | RefPat(RefPat<'a>), |
1929 | BindPat(BindPat<'a>), | 2363 | BindPat(BindPat<'a>), |
@@ -1972,12 +2406,20 @@ impl<'a> AstNode<'a> for Pat<'a> { | |||
1972 | impl<'a> Pat<'a> {} | 2406 | impl<'a> Pat<'a> {} |
1973 | 2407 | ||
1974 | // Path | 2408 | // Path |
1975 | #[derive(Debug, Clone, Copy)] | 2409 | #[derive(Debug, Clone, Copy,)] |
1976 | pub struct PathNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 2410 | pub struct PathNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1977 | syntax: SyntaxNode<R>, | 2411 | pub(crate) syntax: SyntaxNode<R>, |
1978 | } | 2412 | } |
1979 | pub type Path<'a> = PathNode<RefRoot<'a>>; | 2413 | pub type Path<'a> = PathNode<RefRoot<'a>>; |
1980 | 2414 | ||
2415 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PathNode<R1>> for PathNode<R2> { | ||
2416 | fn eq(&self, other: &PathNode<R1>) -> bool { self.syntax == other.syntax } | ||
2417 | } | ||
2418 | impl<R: TreeRoot<RaTypes>> Eq for PathNode<R> {} | ||
2419 | impl<R: TreeRoot<RaTypes>> Hash for PathNode<R> { | ||
2420 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
2421 | } | ||
2422 | |||
1981 | impl<'a> AstNode<'a> for Path<'a> { | 2423 | impl<'a> AstNode<'a> for Path<'a> { |
1982 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2424 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1983 | match syntax.kind() { | 2425 | match syntax.kind() { |
@@ -2009,12 +2451,20 @@ impl<'a> Path<'a> { | |||
2009 | } | 2451 | } |
2010 | 2452 | ||
2011 | // PathExpr | 2453 | // PathExpr |
2012 | #[derive(Debug, Clone, Copy)] | 2454 | #[derive(Debug, Clone, Copy,)] |
2013 | pub struct PathExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 2455 | pub struct PathExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2014 | syntax: SyntaxNode<R>, | 2456 | pub(crate) syntax: SyntaxNode<R>, |
2015 | } | 2457 | } |
2016 | pub type PathExpr<'a> = PathExprNode<RefRoot<'a>>; | 2458 | pub type PathExpr<'a> = PathExprNode<RefRoot<'a>>; |
2017 | 2459 | ||
2460 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PathExprNode<R1>> for PathExprNode<R2> { | ||
2461 | fn eq(&self, other: &PathExprNode<R1>) -> bool { self.syntax == other.syntax } | ||
2462 | } | ||
2463 | impl<R: TreeRoot<RaTypes>> Eq for PathExprNode<R> {} | ||
2464 | impl<R: TreeRoot<RaTypes>> Hash for PathExprNode<R> { | ||
2465 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
2466 | } | ||
2467 | |||
2018 | impl<'a> AstNode<'a> for PathExpr<'a> { | 2468 | impl<'a> AstNode<'a> for PathExpr<'a> { |
2019 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2469 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2020 | match syntax.kind() { | 2470 | match syntax.kind() { |
@@ -2042,12 +2492,20 @@ impl<'a> PathExpr<'a> { | |||
2042 | } | 2492 | } |
2043 | 2493 | ||
2044 | // PathPat | 2494 | // PathPat |
2045 | #[derive(Debug, Clone, Copy)] | 2495 | #[derive(Debug, Clone, Copy,)] |
2046 | pub struct PathPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 2496 | pub struct PathPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2047 | syntax: SyntaxNode<R>, | 2497 | pub(crate) syntax: SyntaxNode<R>, |
2048 | } | 2498 | } |
2049 | pub type PathPat<'a> = PathPatNode<RefRoot<'a>>; | 2499 | pub type PathPat<'a> = PathPatNode<RefRoot<'a>>; |
2050 | 2500 | ||
2501 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PathPatNode<R1>> for PathPatNode<R2> { | ||
2502 | fn eq(&self, other: &PathPatNode<R1>) -> bool { self.syntax == other.syntax } | ||
2503 | } | ||
2504 | impl<R: TreeRoot<RaTypes>> Eq for PathPatNode<R> {} | ||
2505 | impl<R: TreeRoot<RaTypes>> Hash for PathPatNode<R> { | ||
2506 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
2507 | } | ||
2508 | |||
2051 | impl<'a> AstNode<'a> for PathPat<'a> { | 2509 | impl<'a> AstNode<'a> for PathPat<'a> { |
2052 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2510 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2053 | match syntax.kind() { | 2511 | match syntax.kind() { |
@@ -2071,12 +2529,20 @@ impl<R: TreeRoot<RaTypes>> PathPatNode<R> { | |||
2071 | impl<'a> PathPat<'a> {} | 2529 | impl<'a> PathPat<'a> {} |
2072 | 2530 | ||
2073 | // PathSegment | 2531 | // PathSegment |
2074 | #[derive(Debug, Clone, Copy)] | 2532 | #[derive(Debug, Clone, Copy,)] |
2075 | pub struct PathSegmentNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 2533 | pub struct PathSegmentNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2076 | syntax: SyntaxNode<R>, | 2534 | pub(crate) syntax: SyntaxNode<R>, |
2077 | } | 2535 | } |
2078 | pub type PathSegment<'a> = PathSegmentNode<RefRoot<'a>>; | 2536 | pub type PathSegment<'a> = PathSegmentNode<RefRoot<'a>>; |
2079 | 2537 | ||
2538 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PathSegmentNode<R1>> for PathSegmentNode<R2> { | ||
2539 | fn eq(&self, other: &PathSegmentNode<R1>) -> bool { self.syntax == other.syntax } | ||
2540 | } | ||
2541 | impl<R: TreeRoot<RaTypes>> Eq for PathSegmentNode<R> {} | ||
2542 | impl<R: TreeRoot<RaTypes>> Hash for PathSegmentNode<R> { | ||
2543 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
2544 | } | ||
2545 | |||
2080 | impl<'a> AstNode<'a> for PathSegment<'a> { | 2546 | impl<'a> AstNode<'a> for PathSegment<'a> { |
2081 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2547 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2082 | match syntax.kind() { | 2548 | match syntax.kind() { |
@@ -2104,12 +2570,20 @@ impl<'a> PathSegment<'a> { | |||
2104 | } | 2570 | } |
2105 | 2571 | ||
2106 | // PathType | 2572 | // PathType |
2107 | #[derive(Debug, Clone, Copy)] | 2573 | #[derive(Debug, Clone, Copy,)] |
2108 | pub struct PathTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 2574 | pub struct PathTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2109 | syntax: SyntaxNode<R>, | 2575 | pub(crate) syntax: SyntaxNode<R>, |
2110 | } | 2576 | } |
2111 | pub type PathType<'a> = PathTypeNode<RefRoot<'a>>; | 2577 | pub type PathType<'a> = PathTypeNode<RefRoot<'a>>; |
2112 | 2578 | ||
2579 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PathTypeNode<R1>> for PathTypeNode<R2> { | ||
2580 | fn eq(&self, other: &PathTypeNode<R1>) -> bool { self.syntax == other.syntax } | ||
2581 | } | ||
2582 | impl<R: TreeRoot<RaTypes>> Eq for PathTypeNode<R> {} | ||
2583 | impl<R: TreeRoot<RaTypes>> Hash for PathTypeNode<R> { | ||
2584 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
2585 | } | ||
2586 | |||
2113 | impl<'a> AstNode<'a> for PathType<'a> { | 2587 | impl<'a> AstNode<'a> for PathType<'a> { |
2114 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2588 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2115 | match syntax.kind() { | 2589 | match syntax.kind() { |
@@ -2133,12 +2607,20 @@ impl<R: TreeRoot<RaTypes>> PathTypeNode<R> { | |||
2133 | impl<'a> PathType<'a> {} | 2607 | impl<'a> PathType<'a> {} |
2134 | 2608 | ||
2135 | // PlaceholderPat | 2609 | // PlaceholderPat |
2136 | #[derive(Debug, Clone, Copy)] | 2610 | #[derive(Debug, Clone, Copy,)] |
2137 | pub struct PlaceholderPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 2611 | pub struct PlaceholderPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2138 | syntax: SyntaxNode<R>, | 2612 | pub(crate) syntax: SyntaxNode<R>, |
2139 | } | 2613 | } |
2140 | pub type PlaceholderPat<'a> = PlaceholderPatNode<RefRoot<'a>>; | 2614 | pub type PlaceholderPat<'a> = PlaceholderPatNode<RefRoot<'a>>; |
2141 | 2615 | ||
2616 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PlaceholderPatNode<R1>> for PlaceholderPatNode<R2> { | ||
2617 | fn eq(&self, other: &PlaceholderPatNode<R1>) -> bool { self.syntax == other.syntax } | ||
2618 | } | ||
2619 | impl<R: TreeRoot<RaTypes>> Eq for PlaceholderPatNode<R> {} | ||
2620 | impl<R: TreeRoot<RaTypes>> Hash for PlaceholderPatNode<R> { | ||
2621 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
2622 | } | ||
2623 | |||
2142 | impl<'a> AstNode<'a> for PlaceholderPat<'a> { | 2624 | impl<'a> AstNode<'a> for PlaceholderPat<'a> { |
2143 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2625 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2144 | match syntax.kind() { | 2626 | match syntax.kind() { |
@@ -2162,12 +2644,20 @@ impl<R: TreeRoot<RaTypes>> PlaceholderPatNode<R> { | |||
2162 | impl<'a> PlaceholderPat<'a> {} | 2644 | impl<'a> PlaceholderPat<'a> {} |
2163 | 2645 | ||
2164 | // PlaceholderType | 2646 | // PlaceholderType |
2165 | #[derive(Debug, Clone, Copy)] | 2647 | #[derive(Debug, Clone, Copy,)] |
2166 | pub struct PlaceholderTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 2648 | pub struct PlaceholderTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2167 | syntax: SyntaxNode<R>, | 2649 | pub(crate) syntax: SyntaxNode<R>, |
2168 | } | 2650 | } |
2169 | pub type PlaceholderType<'a> = PlaceholderTypeNode<RefRoot<'a>>; | 2651 | pub type PlaceholderType<'a> = PlaceholderTypeNode<RefRoot<'a>>; |
2170 | 2652 | ||
2653 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PlaceholderTypeNode<R1>> for PlaceholderTypeNode<R2> { | ||
2654 | fn eq(&self, other: &PlaceholderTypeNode<R1>) -> bool { self.syntax == other.syntax } | ||
2655 | } | ||
2656 | impl<R: TreeRoot<RaTypes>> Eq for PlaceholderTypeNode<R> {} | ||
2657 | impl<R: TreeRoot<RaTypes>> Hash for PlaceholderTypeNode<R> { | ||
2658 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
2659 | } | ||
2660 | |||
2171 | impl<'a> AstNode<'a> for PlaceholderType<'a> { | 2661 | impl<'a> AstNode<'a> for PlaceholderType<'a> { |
2172 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2662 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2173 | match syntax.kind() { | 2663 | match syntax.kind() { |
@@ -2191,12 +2681,20 @@ impl<R: TreeRoot<RaTypes>> PlaceholderTypeNode<R> { | |||
2191 | impl<'a> PlaceholderType<'a> {} | 2681 | impl<'a> PlaceholderType<'a> {} |
2192 | 2682 | ||
2193 | // PointerType | 2683 | // PointerType |
2194 | #[derive(Debug, Clone, Copy)] | 2684 | #[derive(Debug, Clone, Copy,)] |
2195 | pub struct PointerTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 2685 | pub struct PointerTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2196 | syntax: SyntaxNode<R>, | 2686 | pub(crate) syntax: SyntaxNode<R>, |
2197 | } | 2687 | } |
2198 | pub type PointerType<'a> = PointerTypeNode<RefRoot<'a>>; | 2688 | pub type PointerType<'a> = PointerTypeNode<RefRoot<'a>>; |
2199 | 2689 | ||
2690 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PointerTypeNode<R1>> for PointerTypeNode<R2> { | ||
2691 | fn eq(&self, other: &PointerTypeNode<R1>) -> bool { self.syntax == other.syntax } | ||
2692 | } | ||
2693 | impl<R: TreeRoot<RaTypes>> Eq for PointerTypeNode<R> {} | ||
2694 | impl<R: TreeRoot<RaTypes>> Hash for PointerTypeNode<R> { | ||
2695 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
2696 | } | ||
2697 | |||
2200 | impl<'a> AstNode<'a> for PointerType<'a> { | 2698 | impl<'a> AstNode<'a> for PointerType<'a> { |
2201 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2699 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2202 | match syntax.kind() { | 2700 | match syntax.kind() { |
@@ -2220,12 +2718,20 @@ impl<R: TreeRoot<RaTypes>> PointerTypeNode<R> { | |||
2220 | impl<'a> PointerType<'a> {} | 2718 | impl<'a> PointerType<'a> {} |
2221 | 2719 | ||
2222 | // PrefixExpr | 2720 | // PrefixExpr |
2223 | #[derive(Debug, Clone, Copy)] | 2721 | #[derive(Debug, Clone, Copy,)] |
2224 | pub struct PrefixExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 2722 | pub struct PrefixExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2225 | syntax: SyntaxNode<R>, | 2723 | pub(crate) syntax: SyntaxNode<R>, |
2226 | } | 2724 | } |
2227 | pub type PrefixExpr<'a> = PrefixExprNode<RefRoot<'a>>; | 2725 | pub type PrefixExpr<'a> = PrefixExprNode<RefRoot<'a>>; |
2228 | 2726 | ||
2727 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PrefixExprNode<R1>> for PrefixExprNode<R2> { | ||
2728 | fn eq(&self, other: &PrefixExprNode<R1>) -> bool { self.syntax == other.syntax } | ||
2729 | } | ||
2730 | impl<R: TreeRoot<RaTypes>> Eq for PrefixExprNode<R> {} | ||
2731 | impl<R: TreeRoot<RaTypes>> Hash for PrefixExprNode<R> { | ||
2732 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
2733 | } | ||
2734 | |||
2229 | impl<'a> AstNode<'a> for PrefixExpr<'a> { | 2735 | impl<'a> AstNode<'a> for PrefixExpr<'a> { |
2230 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2736 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2231 | match syntax.kind() { | 2737 | match syntax.kind() { |
@@ -2249,12 +2755,20 @@ impl<R: TreeRoot<RaTypes>> PrefixExprNode<R> { | |||
2249 | impl<'a> PrefixExpr<'a> {} | 2755 | impl<'a> PrefixExpr<'a> {} |
2250 | 2756 | ||
2251 | // RangeExpr | 2757 | // RangeExpr |
2252 | #[derive(Debug, Clone, Copy)] | 2758 | #[derive(Debug, Clone, Copy,)] |
2253 | pub struct RangeExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 2759 | pub struct RangeExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2254 | syntax: SyntaxNode<R>, | 2760 | pub(crate) syntax: SyntaxNode<R>, |
2255 | } | 2761 | } |
2256 | pub type RangeExpr<'a> = RangeExprNode<RefRoot<'a>>; | 2762 | pub type RangeExpr<'a> = RangeExprNode<RefRoot<'a>>; |
2257 | 2763 | ||
2764 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<RangeExprNode<R1>> for RangeExprNode<R2> { | ||
2765 | fn eq(&self, other: &RangeExprNode<R1>) -> bool { self.syntax == other.syntax } | ||
2766 | } | ||
2767 | impl<R: TreeRoot<RaTypes>> Eq for RangeExprNode<R> {} | ||
2768 | impl<R: TreeRoot<RaTypes>> Hash for RangeExprNode<R> { | ||
2769 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
2770 | } | ||
2771 | |||
2258 | impl<'a> AstNode<'a> for RangeExpr<'a> { | 2772 | impl<'a> AstNode<'a> for RangeExpr<'a> { |
2259 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2773 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2260 | match syntax.kind() { | 2774 | match syntax.kind() { |
@@ -2278,12 +2792,20 @@ impl<R: TreeRoot<RaTypes>> RangeExprNode<R> { | |||
2278 | impl<'a> RangeExpr<'a> {} | 2792 | impl<'a> RangeExpr<'a> {} |
2279 | 2793 | ||
2280 | // RangePat | 2794 | // RangePat |
2281 | #[derive(Debug, Clone, Copy)] | 2795 | #[derive(Debug, Clone, Copy,)] |
2282 | pub struct RangePatNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 2796 | pub struct RangePatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2283 | syntax: SyntaxNode<R>, | 2797 | pub(crate) syntax: SyntaxNode<R>, |
2284 | } | 2798 | } |
2285 | pub type RangePat<'a> = RangePatNode<RefRoot<'a>>; | 2799 | pub type RangePat<'a> = RangePatNode<RefRoot<'a>>; |
2286 | 2800 | ||
2801 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<RangePatNode<R1>> for RangePatNode<R2> { | ||
2802 | fn eq(&self, other: &RangePatNode<R1>) -> bool { self.syntax == other.syntax } | ||
2803 | } | ||
2804 | impl<R: TreeRoot<RaTypes>> Eq for RangePatNode<R> {} | ||
2805 | impl<R: TreeRoot<RaTypes>> Hash for RangePatNode<R> { | ||
2806 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
2807 | } | ||
2808 | |||
2287 | impl<'a> AstNode<'a> for RangePat<'a> { | 2809 | impl<'a> AstNode<'a> for RangePat<'a> { |
2288 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2810 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2289 | match syntax.kind() { | 2811 | match syntax.kind() { |
@@ -2307,12 +2829,20 @@ impl<R: TreeRoot<RaTypes>> RangePatNode<R> { | |||
2307 | impl<'a> RangePat<'a> {} | 2829 | impl<'a> RangePat<'a> {} |
2308 | 2830 | ||
2309 | // RefExpr | 2831 | // RefExpr |
2310 | #[derive(Debug, Clone, Copy)] | 2832 | #[derive(Debug, Clone, Copy,)] |
2311 | pub struct RefExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 2833 | pub struct RefExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2312 | syntax: SyntaxNode<R>, | 2834 | pub(crate) syntax: SyntaxNode<R>, |
2313 | } | 2835 | } |
2314 | pub type RefExpr<'a> = RefExprNode<RefRoot<'a>>; | 2836 | pub type RefExpr<'a> = RefExprNode<RefRoot<'a>>; |
2315 | 2837 | ||
2838 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<RefExprNode<R1>> for RefExprNode<R2> { | ||
2839 | fn eq(&self, other: &RefExprNode<R1>) -> bool { self.syntax == other.syntax } | ||
2840 | } | ||
2841 | impl<R: TreeRoot<RaTypes>> Eq for RefExprNode<R> {} | ||
2842 | impl<R: TreeRoot<RaTypes>> Hash for RefExprNode<R> { | ||
2843 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
2844 | } | ||
2845 | |||
2316 | impl<'a> AstNode<'a> for RefExpr<'a> { | 2846 | impl<'a> AstNode<'a> for RefExpr<'a> { |
2317 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2847 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2318 | match syntax.kind() { | 2848 | match syntax.kind() { |
@@ -2336,12 +2866,20 @@ impl<R: TreeRoot<RaTypes>> RefExprNode<R> { | |||
2336 | impl<'a> RefExpr<'a> {} | 2866 | impl<'a> RefExpr<'a> {} |
2337 | 2867 | ||
2338 | // RefPat | 2868 | // RefPat |
2339 | #[derive(Debug, Clone, Copy)] | 2869 | #[derive(Debug, Clone, Copy,)] |
2340 | pub struct RefPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 2870 | pub struct RefPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2341 | syntax: SyntaxNode<R>, | 2871 | pub(crate) syntax: SyntaxNode<R>, |
2342 | } | 2872 | } |
2343 | pub type RefPat<'a> = RefPatNode<RefRoot<'a>>; | 2873 | pub type RefPat<'a> = RefPatNode<RefRoot<'a>>; |
2344 | 2874 | ||
2875 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<RefPatNode<R1>> for RefPatNode<R2> { | ||
2876 | fn eq(&self, other: &RefPatNode<R1>) -> bool { self.syntax == other.syntax } | ||
2877 | } | ||
2878 | impl<R: TreeRoot<RaTypes>> Eq for RefPatNode<R> {} | ||
2879 | impl<R: TreeRoot<RaTypes>> Hash for RefPatNode<R> { | ||
2880 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
2881 | } | ||
2882 | |||
2345 | impl<'a> AstNode<'a> for RefPat<'a> { | 2883 | impl<'a> AstNode<'a> for RefPat<'a> { |
2346 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2884 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2347 | match syntax.kind() { | 2885 | match syntax.kind() { |
@@ -2365,12 +2903,20 @@ impl<R: TreeRoot<RaTypes>> RefPatNode<R> { | |||
2365 | impl<'a> RefPat<'a> {} | 2903 | impl<'a> RefPat<'a> {} |
2366 | 2904 | ||
2367 | // ReferenceType | 2905 | // ReferenceType |
2368 | #[derive(Debug, Clone, Copy)] | 2906 | #[derive(Debug, Clone, Copy,)] |
2369 | pub struct ReferenceTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 2907 | pub struct ReferenceTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2370 | syntax: SyntaxNode<R>, | 2908 | pub(crate) syntax: SyntaxNode<R>, |
2371 | } | 2909 | } |
2372 | pub type ReferenceType<'a> = ReferenceTypeNode<RefRoot<'a>>; | 2910 | pub type ReferenceType<'a> = ReferenceTypeNode<RefRoot<'a>>; |
2373 | 2911 | ||
2912 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ReferenceTypeNode<R1>> for ReferenceTypeNode<R2> { | ||
2913 | fn eq(&self, other: &ReferenceTypeNode<R1>) -> bool { self.syntax == other.syntax } | ||
2914 | } | ||
2915 | impl<R: TreeRoot<RaTypes>> Eq for ReferenceTypeNode<R> {} | ||
2916 | impl<R: TreeRoot<RaTypes>> Hash for ReferenceTypeNode<R> { | ||
2917 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
2918 | } | ||
2919 | |||
2374 | impl<'a> AstNode<'a> for ReferenceType<'a> { | 2920 | impl<'a> AstNode<'a> for ReferenceType<'a> { |
2375 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2921 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2376 | match syntax.kind() { | 2922 | match syntax.kind() { |
@@ -2394,12 +2940,20 @@ impl<R: TreeRoot<RaTypes>> ReferenceTypeNode<R> { | |||
2394 | impl<'a> ReferenceType<'a> {} | 2940 | impl<'a> ReferenceType<'a> {} |
2395 | 2941 | ||
2396 | // RetType | 2942 | // RetType |
2397 | #[derive(Debug, Clone, Copy)] | 2943 | #[derive(Debug, Clone, Copy,)] |
2398 | pub struct RetTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 2944 | pub struct RetTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2399 | syntax: SyntaxNode<R>, | 2945 | pub(crate) syntax: SyntaxNode<R>, |
2400 | } | 2946 | } |
2401 | pub type RetType<'a> = RetTypeNode<RefRoot<'a>>; | 2947 | pub type RetType<'a> = RetTypeNode<RefRoot<'a>>; |
2402 | 2948 | ||
2949 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<RetTypeNode<R1>> for RetTypeNode<R2> { | ||
2950 | fn eq(&self, other: &RetTypeNode<R1>) -> bool { self.syntax == other.syntax } | ||
2951 | } | ||
2952 | impl<R: TreeRoot<RaTypes>> Eq for RetTypeNode<R> {} | ||
2953 | impl<R: TreeRoot<RaTypes>> Hash for RetTypeNode<R> { | ||
2954 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
2955 | } | ||
2956 | |||
2403 | impl<'a> AstNode<'a> for RetType<'a> { | 2957 | impl<'a> AstNode<'a> for RetType<'a> { |
2404 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2958 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2405 | match syntax.kind() { | 2959 | match syntax.kind() { |
@@ -2423,12 +2977,20 @@ impl<R: TreeRoot<RaTypes>> RetTypeNode<R> { | |||
2423 | impl<'a> RetType<'a> {} | 2977 | impl<'a> RetType<'a> {} |
2424 | 2978 | ||
2425 | // ReturnExpr | 2979 | // ReturnExpr |
2426 | #[derive(Debug, Clone, Copy)] | 2980 | #[derive(Debug, Clone, Copy,)] |
2427 | pub struct ReturnExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 2981 | pub struct ReturnExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2428 | syntax: SyntaxNode<R>, | 2982 | pub(crate) syntax: SyntaxNode<R>, |
2429 | } | 2983 | } |
2430 | pub type ReturnExpr<'a> = ReturnExprNode<RefRoot<'a>>; | 2984 | pub type ReturnExpr<'a> = ReturnExprNode<RefRoot<'a>>; |
2431 | 2985 | ||
2986 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ReturnExprNode<R1>> for ReturnExprNode<R2> { | ||
2987 | fn eq(&self, other: &ReturnExprNode<R1>) -> bool { self.syntax == other.syntax } | ||
2988 | } | ||
2989 | impl<R: TreeRoot<RaTypes>> Eq for ReturnExprNode<R> {} | ||
2990 | impl<R: TreeRoot<RaTypes>> Hash for ReturnExprNode<R> { | ||
2991 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
2992 | } | ||
2993 | |||
2432 | impl<'a> AstNode<'a> for ReturnExpr<'a> { | 2994 | impl<'a> AstNode<'a> for ReturnExpr<'a> { |
2433 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2995 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2434 | match syntax.kind() { | 2996 | match syntax.kind() { |
@@ -2452,12 +3014,20 @@ impl<R: TreeRoot<RaTypes>> ReturnExprNode<R> { | |||
2452 | impl<'a> ReturnExpr<'a> {} | 3014 | impl<'a> ReturnExpr<'a> {} |
2453 | 3015 | ||
2454 | // Root | 3016 | // Root |
2455 | #[derive(Debug, Clone, Copy)] | 3017 | #[derive(Debug, Clone, Copy,)] |
2456 | pub struct RootNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 3018 | pub struct RootNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2457 | syntax: SyntaxNode<R>, | 3019 | pub(crate) syntax: SyntaxNode<R>, |
2458 | } | 3020 | } |
2459 | pub type Root<'a> = RootNode<RefRoot<'a>>; | 3021 | pub type Root<'a> = RootNode<RefRoot<'a>>; |
2460 | 3022 | ||
3023 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<RootNode<R1>> for RootNode<R2> { | ||
3024 | fn eq(&self, other: &RootNode<R1>) -> bool { self.syntax == other.syntax } | ||
3025 | } | ||
3026 | impl<R: TreeRoot<RaTypes>> Eq for RootNode<R> {} | ||
3027 | impl<R: TreeRoot<RaTypes>> Hash for RootNode<R> { | ||
3028 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
3029 | } | ||
3030 | |||
2461 | impl<'a> AstNode<'a> for Root<'a> { | 3031 | impl<'a> AstNode<'a> for Root<'a> { |
2462 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3032 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2463 | match syntax.kind() { | 3033 | match syntax.kind() { |
@@ -2487,12 +3057,20 @@ impl<'a> Root<'a> { | |||
2487 | } | 3057 | } |
2488 | 3058 | ||
2489 | // SelfParam | 3059 | // SelfParam |
2490 | #[derive(Debug, Clone, Copy)] | 3060 | #[derive(Debug, Clone, Copy,)] |
2491 | pub struct SelfParamNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 3061 | pub struct SelfParamNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2492 | syntax: SyntaxNode<R>, | 3062 | pub(crate) syntax: SyntaxNode<R>, |
2493 | } | 3063 | } |
2494 | pub type SelfParam<'a> = SelfParamNode<RefRoot<'a>>; | 3064 | pub type SelfParam<'a> = SelfParamNode<RefRoot<'a>>; |
2495 | 3065 | ||
3066 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<SelfParamNode<R1>> for SelfParamNode<R2> { | ||
3067 | fn eq(&self, other: &SelfParamNode<R1>) -> bool { self.syntax == other.syntax } | ||
3068 | } | ||
3069 | impl<R: TreeRoot<RaTypes>> Eq for SelfParamNode<R> {} | ||
3070 | impl<R: TreeRoot<RaTypes>> Hash for SelfParamNode<R> { | ||
3071 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
3072 | } | ||
3073 | |||
2496 | impl<'a> AstNode<'a> for SelfParam<'a> { | 3074 | impl<'a> AstNode<'a> for SelfParam<'a> { |
2497 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3075 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2498 | match syntax.kind() { | 3076 | match syntax.kind() { |
@@ -2516,12 +3094,20 @@ impl<R: TreeRoot<RaTypes>> SelfParamNode<R> { | |||
2516 | impl<'a> SelfParam<'a> {} | 3094 | impl<'a> SelfParam<'a> {} |
2517 | 3095 | ||
2518 | // SlicePat | 3096 | // SlicePat |
2519 | #[derive(Debug, Clone, Copy)] | 3097 | #[derive(Debug, Clone, Copy,)] |
2520 | pub struct SlicePatNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 3098 | pub struct SlicePatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2521 | syntax: SyntaxNode<R>, | 3099 | pub(crate) syntax: SyntaxNode<R>, |
2522 | } | 3100 | } |
2523 | pub type SlicePat<'a> = SlicePatNode<RefRoot<'a>>; | 3101 | pub type SlicePat<'a> = SlicePatNode<RefRoot<'a>>; |
2524 | 3102 | ||
3103 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<SlicePatNode<R1>> for SlicePatNode<R2> { | ||
3104 | fn eq(&self, other: &SlicePatNode<R1>) -> bool { self.syntax == other.syntax } | ||
3105 | } | ||
3106 | impl<R: TreeRoot<RaTypes>> Eq for SlicePatNode<R> {} | ||
3107 | impl<R: TreeRoot<RaTypes>> Hash for SlicePatNode<R> { | ||
3108 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
3109 | } | ||
3110 | |||
2525 | impl<'a> AstNode<'a> for SlicePat<'a> { | 3111 | impl<'a> AstNode<'a> for SlicePat<'a> { |
2526 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3112 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2527 | match syntax.kind() { | 3113 | match syntax.kind() { |
@@ -2545,12 +3131,20 @@ impl<R: TreeRoot<RaTypes>> SlicePatNode<R> { | |||
2545 | impl<'a> SlicePat<'a> {} | 3131 | impl<'a> SlicePat<'a> {} |
2546 | 3132 | ||
2547 | // SliceType | 3133 | // SliceType |
2548 | #[derive(Debug, Clone, Copy)] | 3134 | #[derive(Debug, Clone, Copy,)] |
2549 | pub struct SliceTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 3135 | pub struct SliceTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2550 | syntax: SyntaxNode<R>, | 3136 | pub(crate) syntax: SyntaxNode<R>, |
2551 | } | 3137 | } |
2552 | pub type SliceType<'a> = SliceTypeNode<RefRoot<'a>>; | 3138 | pub type SliceType<'a> = SliceTypeNode<RefRoot<'a>>; |
2553 | 3139 | ||
3140 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<SliceTypeNode<R1>> for SliceTypeNode<R2> { | ||
3141 | fn eq(&self, other: &SliceTypeNode<R1>) -> bool { self.syntax == other.syntax } | ||
3142 | } | ||
3143 | impl<R: TreeRoot<RaTypes>> Eq for SliceTypeNode<R> {} | ||
3144 | impl<R: TreeRoot<RaTypes>> Hash for SliceTypeNode<R> { | ||
3145 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
3146 | } | ||
3147 | |||
2554 | impl<'a> AstNode<'a> for SliceType<'a> { | 3148 | impl<'a> AstNode<'a> for SliceType<'a> { |
2555 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3149 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2556 | match syntax.kind() { | 3150 | match syntax.kind() { |
@@ -2574,12 +3168,20 @@ impl<R: TreeRoot<RaTypes>> SliceTypeNode<R> { | |||
2574 | impl<'a> SliceType<'a> {} | 3168 | impl<'a> SliceType<'a> {} |
2575 | 3169 | ||
2576 | // StaticDef | 3170 | // StaticDef |
2577 | #[derive(Debug, Clone, Copy)] | 3171 | #[derive(Debug, Clone, Copy,)] |
2578 | pub struct StaticDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 3172 | pub struct StaticDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2579 | syntax: SyntaxNode<R>, | 3173 | pub(crate) syntax: SyntaxNode<R>, |
2580 | } | 3174 | } |
2581 | pub type StaticDef<'a> = StaticDefNode<RefRoot<'a>>; | 3175 | pub type StaticDef<'a> = StaticDefNode<RefRoot<'a>>; |
2582 | 3176 | ||
3177 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<StaticDefNode<R1>> for StaticDefNode<R2> { | ||
3178 | fn eq(&self, other: &StaticDefNode<R1>) -> bool { self.syntax == other.syntax } | ||
3179 | } | ||
3180 | impl<R: TreeRoot<RaTypes>> Eq for StaticDefNode<R> {} | ||
3181 | impl<R: TreeRoot<RaTypes>> Hash for StaticDefNode<R> { | ||
3182 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
3183 | } | ||
3184 | |||
2583 | impl<'a> AstNode<'a> for StaticDef<'a> { | 3185 | impl<'a> AstNode<'a> for StaticDef<'a> { |
2584 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3186 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2585 | match syntax.kind() { | 3187 | match syntax.kind() { |
@@ -2606,7 +3208,7 @@ impl<'a> ast::AttrsOwner<'a> for StaticDef<'a> {} | |||
2606 | impl<'a> StaticDef<'a> {} | 3208 | impl<'a> StaticDef<'a> {} |
2607 | 3209 | ||
2608 | // Stmt | 3210 | // Stmt |
2609 | #[derive(Debug, Clone, Copy)] | 3211 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
2610 | pub enum Stmt<'a> { | 3212 | pub enum Stmt<'a> { |
2611 | ExprStmt(ExprStmt<'a>), | 3213 | ExprStmt(ExprStmt<'a>), |
2612 | LetStmt(LetStmt<'a>), | 3214 | LetStmt(LetStmt<'a>), |
@@ -2631,12 +3233,20 @@ impl<'a> AstNode<'a> for Stmt<'a> { | |||
2631 | impl<'a> Stmt<'a> {} | 3233 | impl<'a> Stmt<'a> {} |
2632 | 3234 | ||
2633 | // StructDef | 3235 | // StructDef |
2634 | #[derive(Debug, Clone, Copy)] | 3236 | #[derive(Debug, Clone, Copy,)] |
2635 | pub struct StructDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 3237 | pub struct StructDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2636 | syntax: SyntaxNode<R>, | 3238 | pub(crate) syntax: SyntaxNode<R>, |
2637 | } | 3239 | } |
2638 | pub type StructDef<'a> = StructDefNode<RefRoot<'a>>; | 3240 | pub type StructDef<'a> = StructDefNode<RefRoot<'a>>; |
2639 | 3241 | ||
3242 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<StructDefNode<R1>> for StructDefNode<R2> { | ||
3243 | fn eq(&self, other: &StructDefNode<R1>) -> bool { self.syntax == other.syntax } | ||
3244 | } | ||
3245 | impl<R: TreeRoot<RaTypes>> Eq for StructDefNode<R> {} | ||
3246 | impl<R: TreeRoot<RaTypes>> Hash for StructDefNode<R> { | ||
3247 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
3248 | } | ||
3249 | |||
2640 | impl<'a> AstNode<'a> for StructDef<'a> { | 3250 | impl<'a> AstNode<'a> for StructDef<'a> { |
2641 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3251 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2642 | match syntax.kind() { | 3252 | match syntax.kind() { |
@@ -2667,12 +3277,20 @@ impl<'a> StructDef<'a> { | |||
2667 | } | 3277 | } |
2668 | 3278 | ||
2669 | // StructLit | 3279 | // StructLit |
2670 | #[derive(Debug, Clone, Copy)] | 3280 | #[derive(Debug, Clone, Copy,)] |
2671 | pub struct StructLitNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 3281 | pub struct StructLitNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2672 | syntax: SyntaxNode<R>, | 3282 | pub(crate) syntax: SyntaxNode<R>, |
2673 | } | 3283 | } |
2674 | pub type StructLit<'a> = StructLitNode<RefRoot<'a>>; | 3284 | pub type StructLit<'a> = StructLitNode<RefRoot<'a>>; |
2675 | 3285 | ||
3286 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<StructLitNode<R1>> for StructLitNode<R2> { | ||
3287 | fn eq(&self, other: &StructLitNode<R1>) -> bool { self.syntax == other.syntax } | ||
3288 | } | ||
3289 | impl<R: TreeRoot<RaTypes>> Eq for StructLitNode<R> {} | ||
3290 | impl<R: TreeRoot<RaTypes>> Hash for StructLitNode<R> { | ||
3291 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
3292 | } | ||
3293 | |||
2676 | impl<'a> AstNode<'a> for StructLit<'a> { | 3294 | impl<'a> AstNode<'a> for StructLit<'a> { |
2677 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3295 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2678 | match syntax.kind() { | 3296 | match syntax.kind() { |
@@ -2696,12 +3314,20 @@ impl<R: TreeRoot<RaTypes>> StructLitNode<R> { | |||
2696 | impl<'a> StructLit<'a> {} | 3314 | impl<'a> StructLit<'a> {} |
2697 | 3315 | ||
2698 | // StructPat | 3316 | // StructPat |
2699 | #[derive(Debug, Clone, Copy)] | 3317 | #[derive(Debug, Clone, Copy,)] |
2700 | pub struct StructPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 3318 | pub struct StructPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2701 | syntax: SyntaxNode<R>, | 3319 | pub(crate) syntax: SyntaxNode<R>, |
2702 | } | 3320 | } |
2703 | pub type StructPat<'a> = StructPatNode<RefRoot<'a>>; | 3321 | pub type StructPat<'a> = StructPatNode<RefRoot<'a>>; |
2704 | 3322 | ||
3323 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<StructPatNode<R1>> for StructPatNode<R2> { | ||
3324 | fn eq(&self, other: &StructPatNode<R1>) -> bool { self.syntax == other.syntax } | ||
3325 | } | ||
3326 | impl<R: TreeRoot<RaTypes>> Eq for StructPatNode<R> {} | ||
3327 | impl<R: TreeRoot<RaTypes>> Hash for StructPatNode<R> { | ||
3328 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
3329 | } | ||
3330 | |||
2705 | impl<'a> AstNode<'a> for StructPat<'a> { | 3331 | impl<'a> AstNode<'a> for StructPat<'a> { |
2706 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3332 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2707 | match syntax.kind() { | 3333 | match syntax.kind() { |
@@ -2725,12 +3351,20 @@ impl<R: TreeRoot<RaTypes>> StructPatNode<R> { | |||
2725 | impl<'a> StructPat<'a> {} | 3351 | impl<'a> StructPat<'a> {} |
2726 | 3352 | ||
2727 | // TokenTree | 3353 | // TokenTree |
2728 | #[derive(Debug, Clone, Copy)] | 3354 | #[derive(Debug, Clone, Copy,)] |
2729 | pub struct TokenTreeNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 3355 | pub struct TokenTreeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2730 | syntax: SyntaxNode<R>, | 3356 | pub(crate) syntax: SyntaxNode<R>, |
2731 | } | 3357 | } |
2732 | pub type TokenTree<'a> = TokenTreeNode<RefRoot<'a>>; | 3358 | pub type TokenTree<'a> = TokenTreeNode<RefRoot<'a>>; |
2733 | 3359 | ||
3360 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TokenTreeNode<R1>> for TokenTreeNode<R2> { | ||
3361 | fn eq(&self, other: &TokenTreeNode<R1>) -> bool { self.syntax == other.syntax } | ||
3362 | } | ||
3363 | impl<R: TreeRoot<RaTypes>> Eq for TokenTreeNode<R> {} | ||
3364 | impl<R: TreeRoot<RaTypes>> Hash for TokenTreeNode<R> { | ||
3365 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
3366 | } | ||
3367 | |||
2734 | impl<'a> AstNode<'a> for TokenTree<'a> { | 3368 | impl<'a> AstNode<'a> for TokenTree<'a> { |
2735 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3369 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2736 | match syntax.kind() { | 3370 | match syntax.kind() { |
@@ -2754,12 +3388,20 @@ impl<R: TreeRoot<RaTypes>> TokenTreeNode<R> { | |||
2754 | impl<'a> TokenTree<'a> {} | 3388 | impl<'a> TokenTree<'a> {} |
2755 | 3389 | ||
2756 | // TraitDef | 3390 | // TraitDef |
2757 | #[derive(Debug, Clone, Copy)] | 3391 | #[derive(Debug, Clone, Copy,)] |
2758 | pub struct TraitDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 3392 | pub struct TraitDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2759 | syntax: SyntaxNode<R>, | 3393 | pub(crate) syntax: SyntaxNode<R>, |
2760 | } | 3394 | } |
2761 | pub type TraitDef<'a> = TraitDefNode<RefRoot<'a>>; | 3395 | pub type TraitDef<'a> = TraitDefNode<RefRoot<'a>>; |
2762 | 3396 | ||
3397 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TraitDefNode<R1>> for TraitDefNode<R2> { | ||
3398 | fn eq(&self, other: &TraitDefNode<R1>) -> bool { self.syntax == other.syntax } | ||
3399 | } | ||
3400 | impl<R: TreeRoot<RaTypes>> Eq for TraitDefNode<R> {} | ||
3401 | impl<R: TreeRoot<RaTypes>> Hash for TraitDefNode<R> { | ||
3402 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
3403 | } | ||
3404 | |||
2763 | impl<'a> AstNode<'a> for TraitDef<'a> { | 3405 | impl<'a> AstNode<'a> for TraitDef<'a> { |
2764 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3406 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2765 | match syntax.kind() { | 3407 | match syntax.kind() { |
@@ -2785,12 +3427,20 @@ impl<'a> ast::AttrsOwner<'a> for TraitDef<'a> {} | |||
2785 | impl<'a> TraitDef<'a> {} | 3427 | impl<'a> TraitDef<'a> {} |
2786 | 3428 | ||
2787 | // TryExpr | 3429 | // TryExpr |
2788 | #[derive(Debug, Clone, Copy)] | 3430 | #[derive(Debug, Clone, Copy,)] |
2789 | pub struct TryExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 3431 | pub struct TryExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2790 | syntax: SyntaxNode<R>, | 3432 | pub(crate) syntax: SyntaxNode<R>, |
2791 | } | 3433 | } |
2792 | pub type TryExpr<'a> = TryExprNode<RefRoot<'a>>; | 3434 | pub type TryExpr<'a> = TryExprNode<RefRoot<'a>>; |
2793 | 3435 | ||
3436 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TryExprNode<R1>> for TryExprNode<R2> { | ||
3437 | fn eq(&self, other: &TryExprNode<R1>) -> bool { self.syntax == other.syntax } | ||
3438 | } | ||
3439 | impl<R: TreeRoot<RaTypes>> Eq for TryExprNode<R> {} | ||
3440 | impl<R: TreeRoot<RaTypes>> Hash for TryExprNode<R> { | ||
3441 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
3442 | } | ||
3443 | |||
2794 | impl<'a> AstNode<'a> for TryExpr<'a> { | 3444 | impl<'a> AstNode<'a> for TryExpr<'a> { |
2795 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3445 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2796 | match syntax.kind() { | 3446 | match syntax.kind() { |
@@ -2814,12 +3464,20 @@ impl<R: TreeRoot<RaTypes>> TryExprNode<R> { | |||
2814 | impl<'a> TryExpr<'a> {} | 3464 | impl<'a> TryExpr<'a> {} |
2815 | 3465 | ||
2816 | // TupleExpr | 3466 | // TupleExpr |
2817 | #[derive(Debug, Clone, Copy)] | 3467 | #[derive(Debug, Clone, Copy,)] |
2818 | pub struct TupleExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 3468 | pub struct TupleExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2819 | syntax: SyntaxNode<R>, | 3469 | pub(crate) syntax: SyntaxNode<R>, |
2820 | } | 3470 | } |
2821 | pub type TupleExpr<'a> = TupleExprNode<RefRoot<'a>>; | 3471 | pub type TupleExpr<'a> = TupleExprNode<RefRoot<'a>>; |
2822 | 3472 | ||
3473 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TupleExprNode<R1>> for TupleExprNode<R2> { | ||
3474 | fn eq(&self, other: &TupleExprNode<R1>) -> bool { self.syntax == other.syntax } | ||
3475 | } | ||
3476 | impl<R: TreeRoot<RaTypes>> Eq for TupleExprNode<R> {} | ||
3477 | impl<R: TreeRoot<RaTypes>> Hash for TupleExprNode<R> { | ||
3478 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
3479 | } | ||
3480 | |||
2823 | impl<'a> AstNode<'a> for TupleExpr<'a> { | 3481 | impl<'a> AstNode<'a> for TupleExpr<'a> { |
2824 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3482 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2825 | match syntax.kind() { | 3483 | match syntax.kind() { |
@@ -2843,12 +3501,20 @@ impl<R: TreeRoot<RaTypes>> TupleExprNode<R> { | |||
2843 | impl<'a> TupleExpr<'a> {} | 3501 | impl<'a> TupleExpr<'a> {} |
2844 | 3502 | ||
2845 | // TuplePat | 3503 | // TuplePat |
2846 | #[derive(Debug, Clone, Copy)] | 3504 | #[derive(Debug, Clone, Copy,)] |
2847 | pub struct TuplePatNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 3505 | pub struct TuplePatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2848 | syntax: SyntaxNode<R>, | 3506 | pub(crate) syntax: SyntaxNode<R>, |
2849 | } | 3507 | } |
2850 | pub type TuplePat<'a> = TuplePatNode<RefRoot<'a>>; | 3508 | pub type TuplePat<'a> = TuplePatNode<RefRoot<'a>>; |
2851 | 3509 | ||
3510 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TuplePatNode<R1>> for TuplePatNode<R2> { | ||
3511 | fn eq(&self, other: &TuplePatNode<R1>) -> bool { self.syntax == other.syntax } | ||
3512 | } | ||
3513 | impl<R: TreeRoot<RaTypes>> Eq for TuplePatNode<R> {} | ||
3514 | impl<R: TreeRoot<RaTypes>> Hash for TuplePatNode<R> { | ||
3515 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
3516 | } | ||
3517 | |||
2852 | impl<'a> AstNode<'a> for TuplePat<'a> { | 3518 | impl<'a> AstNode<'a> for TuplePat<'a> { |
2853 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3519 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2854 | match syntax.kind() { | 3520 | match syntax.kind() { |
@@ -2872,12 +3538,20 @@ impl<R: TreeRoot<RaTypes>> TuplePatNode<R> { | |||
2872 | impl<'a> TuplePat<'a> {} | 3538 | impl<'a> TuplePat<'a> {} |
2873 | 3539 | ||
2874 | // TupleStructPat | 3540 | // TupleStructPat |
2875 | #[derive(Debug, Clone, Copy)] | 3541 | #[derive(Debug, Clone, Copy,)] |
2876 | pub struct TupleStructPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 3542 | pub struct TupleStructPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2877 | syntax: SyntaxNode<R>, | 3543 | pub(crate) syntax: SyntaxNode<R>, |
2878 | } | 3544 | } |
2879 | pub type TupleStructPat<'a> = TupleStructPatNode<RefRoot<'a>>; | 3545 | pub type TupleStructPat<'a> = TupleStructPatNode<RefRoot<'a>>; |
2880 | 3546 | ||
3547 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TupleStructPatNode<R1>> for TupleStructPatNode<R2> { | ||
3548 | fn eq(&self, other: &TupleStructPatNode<R1>) -> bool { self.syntax == other.syntax } | ||
3549 | } | ||
3550 | impl<R: TreeRoot<RaTypes>> Eq for TupleStructPatNode<R> {} | ||
3551 | impl<R: TreeRoot<RaTypes>> Hash for TupleStructPatNode<R> { | ||
3552 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
3553 | } | ||
3554 | |||
2881 | impl<'a> AstNode<'a> for TupleStructPat<'a> { | 3555 | impl<'a> AstNode<'a> for TupleStructPat<'a> { |
2882 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3556 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2883 | match syntax.kind() { | 3557 | match syntax.kind() { |
@@ -2901,12 +3575,20 @@ impl<R: TreeRoot<RaTypes>> TupleStructPatNode<R> { | |||
2901 | impl<'a> TupleStructPat<'a> {} | 3575 | impl<'a> TupleStructPat<'a> {} |
2902 | 3576 | ||
2903 | // TupleType | 3577 | // TupleType |
2904 | #[derive(Debug, Clone, Copy)] | 3578 | #[derive(Debug, Clone, Copy,)] |
2905 | pub struct TupleTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 3579 | pub struct TupleTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2906 | syntax: SyntaxNode<R>, | 3580 | pub(crate) syntax: SyntaxNode<R>, |
2907 | } | 3581 | } |
2908 | pub type TupleType<'a> = TupleTypeNode<RefRoot<'a>>; | 3582 | pub type TupleType<'a> = TupleTypeNode<RefRoot<'a>>; |
2909 | 3583 | ||
3584 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TupleTypeNode<R1>> for TupleTypeNode<R2> { | ||
3585 | fn eq(&self, other: &TupleTypeNode<R1>) -> bool { self.syntax == other.syntax } | ||
3586 | } | ||
3587 | impl<R: TreeRoot<RaTypes>> Eq for TupleTypeNode<R> {} | ||
3588 | impl<R: TreeRoot<RaTypes>> Hash for TupleTypeNode<R> { | ||
3589 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
3590 | } | ||
3591 | |||
2910 | impl<'a> AstNode<'a> for TupleType<'a> { | 3592 | impl<'a> AstNode<'a> for TupleType<'a> { |
2911 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3593 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2912 | match syntax.kind() { | 3594 | match syntax.kind() { |
@@ -2930,12 +3612,20 @@ impl<R: TreeRoot<RaTypes>> TupleTypeNode<R> { | |||
2930 | impl<'a> TupleType<'a> {} | 3612 | impl<'a> TupleType<'a> {} |
2931 | 3613 | ||
2932 | // TypeDef | 3614 | // TypeDef |
2933 | #[derive(Debug, Clone, Copy)] | 3615 | #[derive(Debug, Clone, Copy,)] |
2934 | pub struct TypeDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 3616 | pub struct TypeDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2935 | syntax: SyntaxNode<R>, | 3617 | pub(crate) syntax: SyntaxNode<R>, |
2936 | } | 3618 | } |
2937 | pub type TypeDef<'a> = TypeDefNode<RefRoot<'a>>; | 3619 | pub type TypeDef<'a> = TypeDefNode<RefRoot<'a>>; |
2938 | 3620 | ||
3621 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TypeDefNode<R1>> for TypeDefNode<R2> { | ||
3622 | fn eq(&self, other: &TypeDefNode<R1>) -> bool { self.syntax == other.syntax } | ||
3623 | } | ||
3624 | impl<R: TreeRoot<RaTypes>> Eq for TypeDefNode<R> {} | ||
3625 | impl<R: TreeRoot<RaTypes>> Hash for TypeDefNode<R> { | ||
3626 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
3627 | } | ||
3628 | |||
2939 | impl<'a> AstNode<'a> for TypeDef<'a> { | 3629 | impl<'a> AstNode<'a> for TypeDef<'a> { |
2940 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3630 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2941 | match syntax.kind() { | 3631 | match syntax.kind() { |
@@ -2962,12 +3652,20 @@ impl<'a> ast::AttrsOwner<'a> for TypeDef<'a> {} | |||
2962 | impl<'a> TypeDef<'a> {} | 3652 | impl<'a> TypeDef<'a> {} |
2963 | 3653 | ||
2964 | // TypeParam | 3654 | // TypeParam |
2965 | #[derive(Debug, Clone, Copy)] | 3655 | #[derive(Debug, Clone, Copy,)] |
2966 | pub struct TypeParamNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 3656 | pub struct TypeParamNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2967 | syntax: SyntaxNode<R>, | 3657 | pub(crate) syntax: SyntaxNode<R>, |
2968 | } | 3658 | } |
2969 | pub type TypeParam<'a> = TypeParamNode<RefRoot<'a>>; | 3659 | pub type TypeParam<'a> = TypeParamNode<RefRoot<'a>>; |
2970 | 3660 | ||
3661 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TypeParamNode<R1>> for TypeParamNode<R2> { | ||
3662 | fn eq(&self, other: &TypeParamNode<R1>) -> bool { self.syntax == other.syntax } | ||
3663 | } | ||
3664 | impl<R: TreeRoot<RaTypes>> Eq for TypeParamNode<R> {} | ||
3665 | impl<R: TreeRoot<RaTypes>> Hash for TypeParamNode<R> { | ||
3666 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
3667 | } | ||
3668 | |||
2971 | impl<'a> AstNode<'a> for TypeParam<'a> { | 3669 | impl<'a> AstNode<'a> for TypeParam<'a> { |
2972 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3670 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
2973 | match syntax.kind() { | 3671 | match syntax.kind() { |
@@ -2992,12 +3690,20 @@ impl<'a> ast::NameOwner<'a> for TypeParam<'a> {} | |||
2992 | impl<'a> TypeParam<'a> {} | 3690 | impl<'a> TypeParam<'a> {} |
2993 | 3691 | ||
2994 | // TypeParamList | 3692 | // TypeParamList |
2995 | #[derive(Debug, Clone, Copy)] | 3693 | #[derive(Debug, Clone, Copy,)] |
2996 | pub struct TypeParamListNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 3694 | pub struct TypeParamListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2997 | syntax: SyntaxNode<R>, | 3695 | pub(crate) syntax: SyntaxNode<R>, |
2998 | } | 3696 | } |
2999 | pub type TypeParamList<'a> = TypeParamListNode<RefRoot<'a>>; | 3697 | pub type TypeParamList<'a> = TypeParamListNode<RefRoot<'a>>; |
3000 | 3698 | ||
3699 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TypeParamListNode<R1>> for TypeParamListNode<R2> { | ||
3700 | fn eq(&self, other: &TypeParamListNode<R1>) -> bool { self.syntax == other.syntax } | ||
3701 | } | ||
3702 | impl<R: TreeRoot<RaTypes>> Eq for TypeParamListNode<R> {} | ||
3703 | impl<R: TreeRoot<RaTypes>> Hash for TypeParamListNode<R> { | ||
3704 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
3705 | } | ||
3706 | |||
3001 | impl<'a> AstNode<'a> for TypeParamList<'a> { | 3707 | impl<'a> AstNode<'a> for TypeParamList<'a> { |
3002 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3708 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
3003 | match syntax.kind() { | 3709 | match syntax.kind() { |
@@ -3029,7 +3735,7 @@ impl<'a> TypeParamList<'a> { | |||
3029 | } | 3735 | } |
3030 | 3736 | ||
3031 | // TypeRef | 3737 | // TypeRef |
3032 | #[derive(Debug, Clone, Copy)] | 3738 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
3033 | pub enum TypeRef<'a> { | 3739 | pub enum TypeRef<'a> { |
3034 | ParenType(ParenType<'a>), | 3740 | ParenType(ParenType<'a>), |
3035 | TupleType(TupleType<'a>), | 3741 | TupleType(TupleType<'a>), |
@@ -3087,12 +3793,20 @@ impl<'a> AstNode<'a> for TypeRef<'a> { | |||
3087 | impl<'a> TypeRef<'a> {} | 3793 | impl<'a> TypeRef<'a> {} |
3088 | 3794 | ||
3089 | // UseItem | 3795 | // UseItem |
3090 | #[derive(Debug, Clone, Copy)] | 3796 | #[derive(Debug, Clone, Copy,)] |
3091 | pub struct UseItemNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 3797 | pub struct UseItemNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3092 | syntax: SyntaxNode<R>, | 3798 | pub(crate) syntax: SyntaxNode<R>, |
3093 | } | 3799 | } |
3094 | pub type UseItem<'a> = UseItemNode<RefRoot<'a>>; | 3800 | pub type UseItem<'a> = UseItemNode<RefRoot<'a>>; |
3095 | 3801 | ||
3802 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<UseItemNode<R1>> for UseItemNode<R2> { | ||
3803 | fn eq(&self, other: &UseItemNode<R1>) -> bool { self.syntax == other.syntax } | ||
3804 | } | ||
3805 | impl<R: TreeRoot<RaTypes>> Eq for UseItemNode<R> {} | ||
3806 | impl<R: TreeRoot<RaTypes>> Hash for UseItemNode<R> { | ||
3807 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
3808 | } | ||
3809 | |||
3096 | impl<'a> AstNode<'a> for UseItem<'a> { | 3810 | impl<'a> AstNode<'a> for UseItem<'a> { |
3097 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3811 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
3098 | match syntax.kind() { | 3812 | match syntax.kind() { |
@@ -3120,12 +3834,20 @@ impl<'a> UseItem<'a> { | |||
3120 | } | 3834 | } |
3121 | 3835 | ||
3122 | // UseTree | 3836 | // UseTree |
3123 | #[derive(Debug, Clone, Copy)] | 3837 | #[derive(Debug, Clone, Copy,)] |
3124 | pub struct UseTreeNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 3838 | pub struct UseTreeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3125 | syntax: SyntaxNode<R>, | 3839 | pub(crate) syntax: SyntaxNode<R>, |
3126 | } | 3840 | } |
3127 | pub type UseTree<'a> = UseTreeNode<RefRoot<'a>>; | 3841 | pub type UseTree<'a> = UseTreeNode<RefRoot<'a>>; |
3128 | 3842 | ||
3843 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<UseTreeNode<R1>> for UseTreeNode<R2> { | ||
3844 | fn eq(&self, other: &UseTreeNode<R1>) -> bool { self.syntax == other.syntax } | ||
3845 | } | ||
3846 | impl<R: TreeRoot<RaTypes>> Eq for UseTreeNode<R> {} | ||
3847 | impl<R: TreeRoot<RaTypes>> Hash for UseTreeNode<R> { | ||
3848 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
3849 | } | ||
3850 | |||
3129 | impl<'a> AstNode<'a> for UseTree<'a> { | 3851 | impl<'a> AstNode<'a> for UseTree<'a> { |
3130 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3852 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
3131 | match syntax.kind() { | 3853 | match syntax.kind() { |
@@ -3157,12 +3879,20 @@ impl<'a> UseTree<'a> { | |||
3157 | } | 3879 | } |
3158 | 3880 | ||
3159 | // UseTreeList | 3881 | // UseTreeList |
3160 | #[derive(Debug, Clone, Copy)] | 3882 | #[derive(Debug, Clone, Copy,)] |
3161 | pub struct UseTreeListNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 3883 | pub struct UseTreeListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3162 | syntax: SyntaxNode<R>, | 3884 | pub(crate) syntax: SyntaxNode<R>, |
3163 | } | 3885 | } |
3164 | pub type UseTreeList<'a> = UseTreeListNode<RefRoot<'a>>; | 3886 | pub type UseTreeList<'a> = UseTreeListNode<RefRoot<'a>>; |
3165 | 3887 | ||
3888 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<UseTreeListNode<R1>> for UseTreeListNode<R2> { | ||
3889 | fn eq(&self, other: &UseTreeListNode<R1>) -> bool { self.syntax == other.syntax } | ||
3890 | } | ||
3891 | impl<R: TreeRoot<RaTypes>> Eq for UseTreeListNode<R> {} | ||
3892 | impl<R: TreeRoot<RaTypes>> Hash for UseTreeListNode<R> { | ||
3893 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
3894 | } | ||
3895 | |||
3166 | impl<'a> AstNode<'a> for UseTreeList<'a> { | 3896 | impl<'a> AstNode<'a> for UseTreeList<'a> { |
3167 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3897 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
3168 | match syntax.kind() { | 3898 | match syntax.kind() { |
@@ -3190,12 +3920,20 @@ impl<'a> UseTreeList<'a> { | |||
3190 | } | 3920 | } |
3191 | 3921 | ||
3192 | // WhereClause | 3922 | // WhereClause |
3193 | #[derive(Debug, Clone, Copy)] | 3923 | #[derive(Debug, Clone, Copy,)] |
3194 | pub struct WhereClauseNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 3924 | pub struct WhereClauseNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3195 | syntax: SyntaxNode<R>, | 3925 | pub(crate) syntax: SyntaxNode<R>, |
3196 | } | 3926 | } |
3197 | pub type WhereClause<'a> = WhereClauseNode<RefRoot<'a>>; | 3927 | pub type WhereClause<'a> = WhereClauseNode<RefRoot<'a>>; |
3198 | 3928 | ||
3929 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<WhereClauseNode<R1>> for WhereClauseNode<R2> { | ||
3930 | fn eq(&self, other: &WhereClauseNode<R1>) -> bool { self.syntax == other.syntax } | ||
3931 | } | ||
3932 | impl<R: TreeRoot<RaTypes>> Eq for WhereClauseNode<R> {} | ||
3933 | impl<R: TreeRoot<RaTypes>> Hash for WhereClauseNode<R> { | ||
3934 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
3935 | } | ||
3936 | |||
3199 | impl<'a> AstNode<'a> for WhereClause<'a> { | 3937 | impl<'a> AstNode<'a> for WhereClause<'a> { |
3200 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3938 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
3201 | match syntax.kind() { | 3939 | match syntax.kind() { |
@@ -3219,12 +3957,20 @@ impl<R: TreeRoot<RaTypes>> WhereClauseNode<R> { | |||
3219 | impl<'a> WhereClause<'a> {} | 3957 | impl<'a> WhereClause<'a> {} |
3220 | 3958 | ||
3221 | // WhileExpr | 3959 | // WhileExpr |
3222 | #[derive(Debug, Clone, Copy)] | 3960 | #[derive(Debug, Clone, Copy,)] |
3223 | pub struct WhileExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 3961 | pub struct WhileExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3224 | syntax: SyntaxNode<R>, | 3962 | pub(crate) syntax: SyntaxNode<R>, |
3225 | } | 3963 | } |
3226 | pub type WhileExpr<'a> = WhileExprNode<RefRoot<'a>>; | 3964 | pub type WhileExpr<'a> = WhileExprNode<RefRoot<'a>>; |
3227 | 3965 | ||
3966 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<WhileExprNode<R1>> for WhileExprNode<R2> { | ||
3967 | fn eq(&self, other: &WhileExprNode<R1>) -> bool { self.syntax == other.syntax } | ||
3968 | } | ||
3969 | impl<R: TreeRoot<RaTypes>> Eq for WhileExprNode<R> {} | ||
3970 | impl<R: TreeRoot<RaTypes>> Hash for WhileExprNode<R> { | ||
3971 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
3972 | } | ||
3973 | |||
3228 | impl<'a> AstNode<'a> for WhileExpr<'a> { | 3974 | impl<'a> AstNode<'a> for WhileExpr<'a> { |
3229 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3975 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
3230 | match syntax.kind() { | 3976 | match syntax.kind() { |
@@ -3253,12 +3999,20 @@ impl<'a> WhileExpr<'a> { | |||
3253 | } | 3999 | } |
3254 | 4000 | ||
3255 | // Whitespace | 4001 | // Whitespace |
3256 | #[derive(Debug, Clone, Copy)] | 4002 | #[derive(Debug, Clone, Copy,)] |
3257 | pub struct WhitespaceNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 4003 | pub struct WhitespaceNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3258 | syntax: SyntaxNode<R>, | 4004 | pub(crate) syntax: SyntaxNode<R>, |
3259 | } | 4005 | } |
3260 | pub type Whitespace<'a> = WhitespaceNode<RefRoot<'a>>; | 4006 | pub type Whitespace<'a> = WhitespaceNode<RefRoot<'a>>; |
3261 | 4007 | ||
4008 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<WhitespaceNode<R1>> for WhitespaceNode<R2> { | ||
4009 | fn eq(&self, other: &WhitespaceNode<R1>) -> bool { self.syntax == other.syntax } | ||
4010 | } | ||
4011 | impl<R: TreeRoot<RaTypes>> Eq for WhitespaceNode<R> {} | ||
4012 | impl<R: TreeRoot<RaTypes>> Hash for WhitespaceNode<R> { | ||
4013 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
4014 | } | ||
4015 | |||
3262 | impl<'a> AstNode<'a> for Whitespace<'a> { | 4016 | impl<'a> AstNode<'a> for Whitespace<'a> { |
3263 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 4017 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
3264 | match syntax.kind() { | 4018 | match syntax.kind() { |
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() { |
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs index 123002825..aa172ba42 100644 --- a/crates/ra_syntax/src/lib.rs +++ b/crates/ra_syntax/src/lib.rs | |||
@@ -60,11 +60,9 @@ pub use crate::{ | |||
60 | 60 | ||
61 | use crate::yellow::GreenNode; | 61 | use crate::yellow::GreenNode; |
62 | 62 | ||
63 | // TODO: pick a single name for everything. SourceFile maybe? | ||
63 | /// File represents a parse tree for a single Rust file. | 64 | /// File represents a parse tree for a single Rust file. |
64 | #[derive(Clone, Debug, Hash, PartialEq, Eq)] | 65 | pub type File = ast::RootNode; |
65 | pub struct File { | ||
66 | root: SyntaxNode, | ||
67 | } | ||
68 | 66 | ||
69 | impl File { | 67 | impl File { |
70 | fn new(green: GreenNode, errors: Vec<SyntaxError>) -> File { | 68 | fn new(green: GreenNode, errors: Vec<SyntaxError>) -> File { |
@@ -72,7 +70,8 @@ impl File { | |||
72 | if cfg!(debug_assertions) { | 70 | if cfg!(debug_assertions) { |
73 | utils::validate_block_structure(root.borrowed()); | 71 | utils::validate_block_structure(root.borrowed()); |
74 | } | 72 | } |
75 | File { root } | 73 | assert_eq!(root.kind(), SyntaxKind::ROOT); |
74 | ast::RootNode { syntax: root } | ||
76 | } | 75 | } |
77 | pub fn parse(text: &str) -> File { | 76 | pub fn parse(text: &str) -> File { |
78 | let tokens = tokenize(&text); | 77 | let tokens = tokenize(&text); |
@@ -95,14 +94,14 @@ impl File { | |||
95 | } | 94 | } |
96 | /// Typed AST representation of the parse tree. | 95 | /// Typed AST representation of the parse tree. |
97 | pub fn ast(&self) -> ast::Root { | 96 | pub fn ast(&self) -> ast::Root { |
98 | ast::Root::cast(self.syntax()).unwrap() | 97 | self.borrowed() |
99 | } | 98 | } |
100 | /// Untyped homogeneous representation of the parse tree. | 99 | /// Untyped homogeneous representation of the parse tree. |
101 | pub fn syntax(&self) -> SyntaxNodeRef { | 100 | pub fn syntax(&self) -> SyntaxNodeRef { |
102 | self.root.borrowed() | 101 | self.syntax.borrowed() |
103 | } | 102 | } |
104 | pub fn errors(&self) -> Vec<SyntaxError> { | 103 | pub fn errors(&self) -> Vec<SyntaxError> { |
105 | let mut errors = self.root.root_data().clone(); | 104 | let mut errors = self.syntax.root_data().clone(); |
106 | errors.extend(validation::validate(self)); | 105 | errors.extend(validation::validate(self)); |
107 | errors | 106 | errors |
108 | } | 107 | } |
diff --git a/crates/ra_syntax/src/validation.rs b/crates/ra_syntax/src/validation.rs index 009f5052f..2b26e388d 100644 --- a/crates/ra_syntax/src/validation.rs +++ b/crates/ra_syntax/src/validation.rs | |||
@@ -11,7 +11,7 @@ use crate::{ | |||
11 | 11 | ||
12 | pub(crate) fn validate(file: &File) -> Vec<SyntaxError> { | 12 | pub(crate) fn validate(file: &File) -> Vec<SyntaxError> { |
13 | let mut errors = Vec::new(); | 13 | let mut errors = Vec::new(); |
14 | for node in file.root.borrowed().descendants() { | 14 | for node in file.syntax().descendants() { |
15 | let _ = visitor_ctx(&mut errors) | 15 | let _ = visitor_ctx(&mut errors) |
16 | .visit::<ast::Char, _>(validate_char) | 16 | .visit::<ast::Char, _>(validate_char) |
17 | .accept(node); | 17 | .accept(node); |