]> git.lizzy.rs Git - rust.git/blob - crates/ra_syntax/src/ast/generated.rs
migrate ra_syntax to the new rowan API
[rust.git] / crates / ra_syntax / src / ast / generated.rs
1 // This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-syntax` is run
2 // Do not edit manually
3
4 //! This module contains auto-generated Rust AST. Like `SyntaxNode`s, AST nodes
5 //! are generic over ownership: `X<'a>` things are `Copy` references, `XNode`
6 //! are Arc-based. You can switch between the two variants using `.owned` and
7 //! `.borrowed` functions. Most of the code works with borowed mode, and only
8 //! this mode has all AST accessors.
9
10 #![cfg_attr(rustfmt, rustfmt_skip)]
11
12 use crate::{
13     SyntaxNode, SyntaxKind::*,
14     ast::{self, AstNode},
15 };
16
17 // Alias
18 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
19 pub struct Alias {
20     pub(crate) syntax: SyntaxNode,
21 }
22
23 impl AstNode for Alias {
24     fn cast(syntax: SyntaxNode) -> Option<Self> {
25         match syntax.kind() {
26             ALIAS => Some(Alias { syntax }),
27             _ => None,
28         }
29     }
30     fn syntax(&self) -> &SyntaxNode { &self.syntax }
31 }
32
33
34 impl ast::NameOwner for Alias {}
35 impl Alias {}
36
37 // ArgList
38 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
39 pub struct ArgList {
40     pub(crate) syntax: SyntaxNode,
41 }
42
43 impl AstNode for ArgList {
44     fn cast(syntax: SyntaxNode) -> Option<Self> {
45         match syntax.kind() {
46             ARG_LIST => Some(ArgList { syntax }),
47             _ => None,
48         }
49     }
50     fn syntax(&self) -> &SyntaxNode { &self.syntax }
51 }
52
53
54 impl ArgList {
55     pub fn args(&self) -> impl Iterator<Item = Expr> {
56         super::children(self)
57     }
58 }
59
60 // ArrayExpr
61 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
62 pub struct ArrayExpr {
63     pub(crate) syntax: SyntaxNode,
64 }
65
66 impl AstNode for ArrayExpr {
67     fn cast(syntax: SyntaxNode) -> Option<Self> {
68         match syntax.kind() {
69             ARRAY_EXPR => Some(ArrayExpr { syntax }),
70             _ => None,
71         }
72     }
73     fn syntax(&self) -> &SyntaxNode { &self.syntax }
74 }
75
76
77 impl ArrayExpr {
78     pub fn exprs(&self) -> impl Iterator<Item = Expr> {
79         super::children(self)
80     }
81 }
82
83 // ArrayType
84 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
85 pub struct ArrayType {
86     pub(crate) syntax: SyntaxNode,
87 }
88
89 impl AstNode for ArrayType {
90     fn cast(syntax: SyntaxNode) -> Option<Self> {
91         match syntax.kind() {
92             ARRAY_TYPE => Some(ArrayType { syntax }),
93             _ => None,
94         }
95     }
96     fn syntax(&self) -> &SyntaxNode { &self.syntax }
97 }
98
99
100 impl ArrayType {
101     pub fn type_ref(&self) -> Option<TypeRef> {
102         super::child_opt(self)
103     }
104
105     pub fn expr(&self) -> Option<Expr> {
106         super::child_opt(self)
107     }
108 }
109
110 // AssocTypeArg
111 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
112 pub struct AssocTypeArg {
113     pub(crate) syntax: SyntaxNode,
114 }
115
116 impl AstNode for AssocTypeArg {
117     fn cast(syntax: SyntaxNode) -> Option<Self> {
118         match syntax.kind() {
119             ASSOC_TYPE_ARG => Some(AssocTypeArg { syntax }),
120             _ => None,
121         }
122     }
123     fn syntax(&self) -> &SyntaxNode { &self.syntax }
124 }
125
126
127 impl AssocTypeArg {
128     pub fn name_ref(&self) -> Option<NameRef> {
129         super::child_opt(self)
130     }
131
132     pub fn type_ref(&self) -> Option<TypeRef> {
133         super::child_opt(self)
134     }
135 }
136
137 // Attr
138 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
139 pub struct Attr {
140     pub(crate) syntax: SyntaxNode,
141 }
142
143 impl AstNode for Attr {
144     fn cast(syntax: SyntaxNode) -> Option<Self> {
145         match syntax.kind() {
146             ATTR => Some(Attr { syntax }),
147             _ => None,
148         }
149     }
150     fn syntax(&self) -> &SyntaxNode { &self.syntax }
151 }
152
153
154 impl Attr {
155     pub fn value(&self) -> Option<TokenTree> {
156         super::child_opt(self)
157     }
158 }
159
160 // BinExpr
161 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
162 pub struct BinExpr {
163     pub(crate) syntax: SyntaxNode,
164 }
165
166 impl AstNode for BinExpr {
167     fn cast(syntax: SyntaxNode) -> Option<Self> {
168         match syntax.kind() {
169             BIN_EXPR => Some(BinExpr { syntax }),
170             _ => None,
171         }
172     }
173     fn syntax(&self) -> &SyntaxNode { &self.syntax }
174 }
175
176
177 impl BinExpr {}
178
179 // BindPat
180 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
181 pub struct BindPat {
182     pub(crate) syntax: SyntaxNode,
183 }
184
185 impl AstNode for BindPat {
186     fn cast(syntax: SyntaxNode) -> Option<Self> {
187         match syntax.kind() {
188             BIND_PAT => Some(BindPat { syntax }),
189             _ => None,
190         }
191     }
192     fn syntax(&self) -> &SyntaxNode { &self.syntax }
193 }
194
195
196 impl ast::NameOwner for BindPat {}
197 impl BindPat {
198     pub fn pat(&self) -> Option<Pat> {
199         super::child_opt(self)
200     }
201 }
202
203 // Block
204 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
205 pub struct Block {
206     pub(crate) syntax: SyntaxNode,
207 }
208
209 impl AstNode for Block {
210     fn cast(syntax: SyntaxNode) -> Option<Self> {
211         match syntax.kind() {
212             BLOCK => Some(Block { syntax }),
213             _ => None,
214         }
215     }
216     fn syntax(&self) -> &SyntaxNode { &self.syntax }
217 }
218
219
220 impl ast::AttrsOwner for Block {}
221 impl Block {
222     pub fn statements(&self) -> impl Iterator<Item = Stmt> {
223         super::children(self)
224     }
225
226     pub fn expr(&self) -> Option<Expr> {
227         super::child_opt(self)
228     }
229 }
230
231 // BlockExpr
232 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
233 pub struct BlockExpr {
234     pub(crate) syntax: SyntaxNode,
235 }
236
237 impl AstNode for BlockExpr {
238     fn cast(syntax: SyntaxNode) -> Option<Self> {
239         match syntax.kind() {
240             BLOCK_EXPR => Some(BlockExpr { syntax }),
241             _ => None,
242         }
243     }
244     fn syntax(&self) -> &SyntaxNode { &self.syntax }
245 }
246
247
248 impl BlockExpr {
249     pub fn block(&self) -> Option<Block> {
250         super::child_opt(self)
251     }
252 }
253
254 // BreakExpr
255 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
256 pub struct BreakExpr {
257     pub(crate) syntax: SyntaxNode,
258 }
259
260 impl AstNode for BreakExpr {
261     fn cast(syntax: SyntaxNode) -> Option<Self> {
262         match syntax.kind() {
263             BREAK_EXPR => Some(BreakExpr { syntax }),
264             _ => None,
265         }
266     }
267     fn syntax(&self) -> &SyntaxNode { &self.syntax }
268 }
269
270
271 impl BreakExpr {
272     pub fn expr(&self) -> Option<Expr> {
273         super::child_opt(self)
274     }
275 }
276
277 // CallExpr
278 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
279 pub struct CallExpr {
280     pub(crate) syntax: SyntaxNode,
281 }
282
283 impl AstNode for CallExpr {
284     fn cast(syntax: SyntaxNode) -> Option<Self> {
285         match syntax.kind() {
286             CALL_EXPR => Some(CallExpr { syntax }),
287             _ => None,
288         }
289     }
290     fn syntax(&self) -> &SyntaxNode { &self.syntax }
291 }
292
293
294 impl ast::ArgListOwner for CallExpr {}
295 impl CallExpr {
296     pub fn expr(&self) -> Option<Expr> {
297         super::child_opt(self)
298     }
299 }
300
301 // CastExpr
302 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
303 pub struct CastExpr {
304     pub(crate) syntax: SyntaxNode,
305 }
306
307 impl AstNode for CastExpr {
308     fn cast(syntax: SyntaxNode) -> Option<Self> {
309         match syntax.kind() {
310             CAST_EXPR => Some(CastExpr { syntax }),
311             _ => None,
312         }
313     }
314     fn syntax(&self) -> &SyntaxNode { &self.syntax }
315 }
316
317
318 impl CastExpr {
319     pub fn expr(&self) -> Option<Expr> {
320         super::child_opt(self)
321     }
322
323     pub fn type_ref(&self) -> Option<TypeRef> {
324         super::child_opt(self)
325     }
326 }
327
328 // Condition
329 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
330 pub struct Condition {
331     pub(crate) syntax: SyntaxNode,
332 }
333
334 impl AstNode for Condition {
335     fn cast(syntax: SyntaxNode) -> Option<Self> {
336         match syntax.kind() {
337             CONDITION => Some(Condition { syntax }),
338             _ => None,
339         }
340     }
341     fn syntax(&self) -> &SyntaxNode { &self.syntax }
342 }
343
344
345 impl Condition {
346     pub fn pat(&self) -> Option<Pat> {
347         super::child_opt(self)
348     }
349
350     pub fn expr(&self) -> Option<Expr> {
351         super::child_opt(self)
352     }
353 }
354
355 // ConstDef
356 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
357 pub struct ConstDef {
358     pub(crate) syntax: SyntaxNode,
359 }
360
361 impl AstNode for ConstDef {
362     fn cast(syntax: SyntaxNode) -> Option<Self> {
363         match syntax.kind() {
364             CONST_DEF => Some(ConstDef { syntax }),
365             _ => None,
366         }
367     }
368     fn syntax(&self) -> &SyntaxNode { &self.syntax }
369 }
370
371
372 impl ast::VisibilityOwner for ConstDef {}
373 impl ast::NameOwner for ConstDef {}
374 impl ast::TypeParamsOwner for ConstDef {}
375 impl ast::AttrsOwner for ConstDef {}
376 impl ast::DocCommentsOwner for ConstDef {}
377 impl ast::TypeAscriptionOwner for ConstDef {}
378 impl ConstDef {
379     pub fn body(&self) -> Option<Expr> {
380         super::child_opt(self)
381     }
382 }
383
384 // ContinueExpr
385 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
386 pub struct ContinueExpr {
387     pub(crate) syntax: SyntaxNode,
388 }
389
390 impl AstNode for ContinueExpr {
391     fn cast(syntax: SyntaxNode) -> Option<Self> {
392         match syntax.kind() {
393             CONTINUE_EXPR => Some(ContinueExpr { syntax }),
394             _ => None,
395         }
396     }
397     fn syntax(&self) -> &SyntaxNode { &self.syntax }
398 }
399
400
401 impl ContinueExpr {}
402
403 // DynTraitType
404 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
405 pub struct DynTraitType {
406     pub(crate) syntax: SyntaxNode,
407 }
408
409 impl AstNode for DynTraitType {
410     fn cast(syntax: SyntaxNode) -> Option<Self> {
411         match syntax.kind() {
412             DYN_TRAIT_TYPE => Some(DynTraitType { syntax }),
413             _ => None,
414         }
415     }
416     fn syntax(&self) -> &SyntaxNode { &self.syntax }
417 }
418
419
420 impl ast::TypeBoundsOwner for DynTraitType {}
421 impl DynTraitType {}
422
423 // EnumDef
424 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
425 pub struct EnumDef {
426     pub(crate) syntax: SyntaxNode,
427 }
428
429 impl AstNode for EnumDef {
430     fn cast(syntax: SyntaxNode) -> Option<Self> {
431         match syntax.kind() {
432             ENUM_DEF => Some(EnumDef { syntax }),
433             _ => None,
434         }
435     }
436     fn syntax(&self) -> &SyntaxNode { &self.syntax }
437 }
438
439
440 impl ast::VisibilityOwner for EnumDef {}
441 impl ast::NameOwner for EnumDef {}
442 impl ast::TypeParamsOwner for EnumDef {}
443 impl ast::AttrsOwner for EnumDef {}
444 impl ast::DocCommentsOwner for EnumDef {}
445 impl EnumDef {
446     pub fn variant_list(&self) -> Option<EnumVariantList> {
447         super::child_opt(self)
448     }
449 }
450
451 // EnumVariant
452 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
453 pub struct EnumVariant {
454     pub(crate) syntax: SyntaxNode,
455 }
456
457 impl AstNode for EnumVariant {
458     fn cast(syntax: SyntaxNode) -> Option<Self> {
459         match syntax.kind() {
460             ENUM_VARIANT => Some(EnumVariant { syntax }),
461             _ => None,
462         }
463     }
464     fn syntax(&self) -> &SyntaxNode { &self.syntax }
465 }
466
467
468 impl ast::NameOwner for EnumVariant {}
469 impl ast::DocCommentsOwner for EnumVariant {}
470 impl ast::AttrsOwner for EnumVariant {}
471 impl EnumVariant {
472     pub fn expr(&self) -> Option<Expr> {
473         super::child_opt(self)
474     }
475 }
476
477 // EnumVariantList
478 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
479 pub struct EnumVariantList {
480     pub(crate) syntax: SyntaxNode,
481 }
482
483 impl AstNode for EnumVariantList {
484     fn cast(syntax: SyntaxNode) -> Option<Self> {
485         match syntax.kind() {
486             ENUM_VARIANT_LIST => Some(EnumVariantList { syntax }),
487             _ => None,
488         }
489     }
490     fn syntax(&self) -> &SyntaxNode { &self.syntax }
491 }
492
493
494 impl EnumVariantList {
495     pub fn variants(&self) -> impl Iterator<Item = EnumVariant> {
496         super::children(self)
497     }
498 }
499
500 // Expr
501 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
502 pub struct Expr {
503     pub(crate) syntax: SyntaxNode,
504 }
505
506 #[derive(Debug, Clone, PartialEq, Eq)]
507 pub enum ExprKind {
508     TupleExpr(TupleExpr),
509     ArrayExpr(ArrayExpr),
510     ParenExpr(ParenExpr),
511     PathExpr(PathExpr),
512     LambdaExpr(LambdaExpr),
513     IfExpr(IfExpr),
514     LoopExpr(LoopExpr),
515     ForExpr(ForExpr),
516     WhileExpr(WhileExpr),
517     ContinueExpr(ContinueExpr),
518     BreakExpr(BreakExpr),
519     Label(Label),
520     BlockExpr(BlockExpr),
521     ReturnExpr(ReturnExpr),
522     MatchExpr(MatchExpr),
523     StructLit(StructLit),
524     CallExpr(CallExpr),
525     IndexExpr(IndexExpr),
526     MethodCallExpr(MethodCallExpr),
527     FieldExpr(FieldExpr),
528     TryExpr(TryExpr),
529     TryBlockExpr(TryBlockExpr),
530     CastExpr(CastExpr),
531     RefExpr(RefExpr),
532     PrefixExpr(PrefixExpr),
533     RangeExpr(RangeExpr),
534     BinExpr(BinExpr),
535     Literal(Literal),
536     MacroCall(MacroCall),
537 }
538 impl From<TupleExpr> for Expr {
539     fn from(n: TupleExpr) -> Expr {
540         Expr::cast(n.syntax).unwrap()
541     }
542 }
543 impl From<ArrayExpr> for Expr {
544     fn from(n: ArrayExpr) -> Expr {
545         Expr::cast(n.syntax).unwrap()
546     }
547 }
548 impl From<ParenExpr> for Expr {
549     fn from(n: ParenExpr) -> Expr {
550         Expr::cast(n.syntax).unwrap()
551     }
552 }
553 impl From<PathExpr> for Expr {
554     fn from(n: PathExpr) -> Expr {
555         Expr::cast(n.syntax).unwrap()
556     }
557 }
558 impl From<LambdaExpr> for Expr {
559     fn from(n: LambdaExpr) -> Expr {
560         Expr::cast(n.syntax).unwrap()
561     }
562 }
563 impl From<IfExpr> for Expr {
564     fn from(n: IfExpr) -> Expr {
565         Expr::cast(n.syntax).unwrap()
566     }
567 }
568 impl From<LoopExpr> for Expr {
569     fn from(n: LoopExpr) -> Expr {
570         Expr::cast(n.syntax).unwrap()
571     }
572 }
573 impl From<ForExpr> for Expr {
574     fn from(n: ForExpr) -> Expr {
575         Expr::cast(n.syntax).unwrap()
576     }
577 }
578 impl From<WhileExpr> for Expr {
579     fn from(n: WhileExpr) -> Expr {
580         Expr::cast(n.syntax).unwrap()
581     }
582 }
583 impl From<ContinueExpr> for Expr {
584     fn from(n: ContinueExpr) -> Expr {
585         Expr::cast(n.syntax).unwrap()
586     }
587 }
588 impl From<BreakExpr> for Expr {
589     fn from(n: BreakExpr) -> Expr {
590         Expr::cast(n.syntax).unwrap()
591     }
592 }
593 impl From<Label> for Expr {
594     fn from(n: Label) -> Expr {
595         Expr::cast(n.syntax).unwrap()
596     }
597 }
598 impl From<BlockExpr> for Expr {
599     fn from(n: BlockExpr) -> Expr {
600         Expr::cast(n.syntax).unwrap()
601     }
602 }
603 impl From<ReturnExpr> for Expr {
604     fn from(n: ReturnExpr) -> Expr {
605         Expr::cast(n.syntax).unwrap()
606     }
607 }
608 impl From<MatchExpr> for Expr {
609     fn from(n: MatchExpr) -> Expr {
610         Expr::cast(n.syntax).unwrap()
611     }
612 }
613 impl From<StructLit> for Expr {
614     fn from(n: StructLit) -> Expr {
615         Expr::cast(n.syntax).unwrap()
616     }
617 }
618 impl From<CallExpr> for Expr {
619     fn from(n: CallExpr) -> Expr {
620         Expr::cast(n.syntax).unwrap()
621     }
622 }
623 impl From<IndexExpr> for Expr {
624     fn from(n: IndexExpr) -> Expr {
625         Expr::cast(n.syntax).unwrap()
626     }
627 }
628 impl From<MethodCallExpr> for Expr {
629     fn from(n: MethodCallExpr) -> Expr {
630         Expr::cast(n.syntax).unwrap()
631     }
632 }
633 impl From<FieldExpr> for Expr {
634     fn from(n: FieldExpr) -> Expr {
635         Expr::cast(n.syntax).unwrap()
636     }
637 }
638 impl From<TryExpr> for Expr {
639     fn from(n: TryExpr) -> Expr {
640         Expr::cast(n.syntax).unwrap()
641     }
642 }
643 impl From<TryBlockExpr> for Expr {
644     fn from(n: TryBlockExpr) -> Expr {
645         Expr::cast(n.syntax).unwrap()
646     }
647 }
648 impl From<CastExpr> for Expr {
649     fn from(n: CastExpr) -> Expr {
650         Expr::cast(n.syntax).unwrap()
651     }
652 }
653 impl From<RefExpr> for Expr {
654     fn from(n: RefExpr) -> Expr {
655         Expr::cast(n.syntax).unwrap()
656     }
657 }
658 impl From<PrefixExpr> for Expr {
659     fn from(n: PrefixExpr) -> Expr {
660         Expr::cast(n.syntax).unwrap()
661     }
662 }
663 impl From<RangeExpr> for Expr {
664     fn from(n: RangeExpr) -> Expr {
665         Expr::cast(n.syntax).unwrap()
666     }
667 }
668 impl From<BinExpr> for Expr {
669     fn from(n: BinExpr) -> Expr {
670         Expr::cast(n.syntax).unwrap()
671     }
672 }
673 impl From<Literal> for Expr {
674     fn from(n: Literal) -> Expr {
675         Expr::cast(n.syntax).unwrap()
676     }
677 }
678 impl From<MacroCall> for Expr {
679     fn from(n: MacroCall) -> Expr {
680         Expr::cast(n.syntax).unwrap()
681     }
682 }
683
684
685 impl AstNode for Expr {
686     fn cast(syntax: SyntaxNode) -> Option<Self> {
687         match syntax.kind() {
688             | TUPLE_EXPR
689             | ARRAY_EXPR
690             | PAREN_EXPR
691             | PATH_EXPR
692             | LAMBDA_EXPR
693             | IF_EXPR
694             | LOOP_EXPR
695             | FOR_EXPR
696             | WHILE_EXPR
697             | CONTINUE_EXPR
698             | BREAK_EXPR
699             | LABEL
700             | BLOCK_EXPR
701             | RETURN_EXPR
702             | MATCH_EXPR
703             | STRUCT_LIT
704             | CALL_EXPR
705             | INDEX_EXPR
706             | METHOD_CALL_EXPR
707             | FIELD_EXPR
708             | TRY_EXPR
709             | TRY_BLOCK_EXPR
710             | CAST_EXPR
711             | REF_EXPR
712             | PREFIX_EXPR
713             | RANGE_EXPR
714             | BIN_EXPR
715             | LITERAL
716             | MACRO_CALL => Some(Expr { syntax }),
717             _ => None,
718         }
719     }
720     fn syntax(&self) -> &SyntaxNode { &self.syntax }
721 }
722
723 impl Expr {
724     pub fn kind(&self) -> ExprKind {
725         match self.syntax.kind() {
726             TUPLE_EXPR => ExprKind::TupleExpr(TupleExpr::cast(self.syntax.clone()).unwrap()),
727             ARRAY_EXPR => ExprKind::ArrayExpr(ArrayExpr::cast(self.syntax.clone()).unwrap()),
728             PAREN_EXPR => ExprKind::ParenExpr(ParenExpr::cast(self.syntax.clone()).unwrap()),
729             PATH_EXPR => ExprKind::PathExpr(PathExpr::cast(self.syntax.clone()).unwrap()),
730             LAMBDA_EXPR => ExprKind::LambdaExpr(LambdaExpr::cast(self.syntax.clone()).unwrap()),
731             IF_EXPR => ExprKind::IfExpr(IfExpr::cast(self.syntax.clone()).unwrap()),
732             LOOP_EXPR => ExprKind::LoopExpr(LoopExpr::cast(self.syntax.clone()).unwrap()),
733             FOR_EXPR => ExprKind::ForExpr(ForExpr::cast(self.syntax.clone()).unwrap()),
734             WHILE_EXPR => ExprKind::WhileExpr(WhileExpr::cast(self.syntax.clone()).unwrap()),
735             CONTINUE_EXPR => ExprKind::ContinueExpr(ContinueExpr::cast(self.syntax.clone()).unwrap()),
736             BREAK_EXPR => ExprKind::BreakExpr(BreakExpr::cast(self.syntax.clone()).unwrap()),
737             LABEL => ExprKind::Label(Label::cast(self.syntax.clone()).unwrap()),
738             BLOCK_EXPR => ExprKind::BlockExpr(BlockExpr::cast(self.syntax.clone()).unwrap()),
739             RETURN_EXPR => ExprKind::ReturnExpr(ReturnExpr::cast(self.syntax.clone()).unwrap()),
740             MATCH_EXPR => ExprKind::MatchExpr(MatchExpr::cast(self.syntax.clone()).unwrap()),
741             STRUCT_LIT => ExprKind::StructLit(StructLit::cast(self.syntax.clone()).unwrap()),
742             CALL_EXPR => ExprKind::CallExpr(CallExpr::cast(self.syntax.clone()).unwrap()),
743             INDEX_EXPR => ExprKind::IndexExpr(IndexExpr::cast(self.syntax.clone()).unwrap()),
744             METHOD_CALL_EXPR => ExprKind::MethodCallExpr(MethodCallExpr::cast(self.syntax.clone()).unwrap()),
745             FIELD_EXPR => ExprKind::FieldExpr(FieldExpr::cast(self.syntax.clone()).unwrap()),
746             TRY_EXPR => ExprKind::TryExpr(TryExpr::cast(self.syntax.clone()).unwrap()),
747             TRY_BLOCK_EXPR => ExprKind::TryBlockExpr(TryBlockExpr::cast(self.syntax.clone()).unwrap()),
748             CAST_EXPR => ExprKind::CastExpr(CastExpr::cast(self.syntax.clone()).unwrap()),
749             REF_EXPR => ExprKind::RefExpr(RefExpr::cast(self.syntax.clone()).unwrap()),
750             PREFIX_EXPR => ExprKind::PrefixExpr(PrefixExpr::cast(self.syntax.clone()).unwrap()),
751             RANGE_EXPR => ExprKind::RangeExpr(RangeExpr::cast(self.syntax.clone()).unwrap()),
752             BIN_EXPR => ExprKind::BinExpr(BinExpr::cast(self.syntax.clone()).unwrap()),
753             LITERAL => ExprKind::Literal(Literal::cast(self.syntax.clone()).unwrap()),
754             MACRO_CALL => ExprKind::MacroCall(MacroCall::cast(self.syntax.clone()).unwrap()),
755             _ => unreachable!(),
756         }
757     }
758 }
759
760 impl Expr {}
761
762 // ExprStmt
763 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
764 pub struct ExprStmt {
765     pub(crate) syntax: SyntaxNode,
766 }
767
768 impl AstNode for ExprStmt {
769     fn cast(syntax: SyntaxNode) -> Option<Self> {
770         match syntax.kind() {
771             EXPR_STMT => Some(ExprStmt { syntax }),
772             _ => None,
773         }
774     }
775     fn syntax(&self) -> &SyntaxNode { &self.syntax }
776 }
777
778
779 impl ExprStmt {
780     pub fn expr(&self) -> Option<Expr> {
781         super::child_opt(self)
782     }
783 }
784
785 // ExternCrateItem
786 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
787 pub struct ExternCrateItem {
788     pub(crate) syntax: SyntaxNode,
789 }
790
791 impl AstNode for ExternCrateItem {
792     fn cast(syntax: SyntaxNode) -> Option<Self> {
793         match syntax.kind() {
794             EXTERN_CRATE_ITEM => Some(ExternCrateItem { syntax }),
795             _ => None,
796         }
797     }
798     fn syntax(&self) -> &SyntaxNode { &self.syntax }
799 }
800
801
802 impl ExternCrateItem {
803     pub fn name_ref(&self) -> Option<NameRef> {
804         super::child_opt(self)
805     }
806
807     pub fn alias(&self) -> Option<Alias> {
808         super::child_opt(self)
809     }
810 }
811
812 // FieldExpr
813 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
814 pub struct FieldExpr {
815     pub(crate) syntax: SyntaxNode,
816 }
817
818 impl AstNode for FieldExpr {
819     fn cast(syntax: SyntaxNode) -> Option<Self> {
820         match syntax.kind() {
821             FIELD_EXPR => Some(FieldExpr { syntax }),
822             _ => None,
823         }
824     }
825     fn syntax(&self) -> &SyntaxNode { &self.syntax }
826 }
827
828
829 impl FieldExpr {
830     pub fn expr(&self) -> Option<Expr> {
831         super::child_opt(self)
832     }
833
834     pub fn name_ref(&self) -> Option<NameRef> {
835         super::child_opt(self)
836     }
837 }
838
839 // FieldPat
840 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
841 pub struct FieldPat {
842     pub(crate) syntax: SyntaxNode,
843 }
844
845 impl AstNode for FieldPat {
846     fn cast(syntax: SyntaxNode) -> Option<Self> {
847         match syntax.kind() {
848             FIELD_PAT => Some(FieldPat { syntax }),
849             _ => None,
850         }
851     }
852     fn syntax(&self) -> &SyntaxNode { &self.syntax }
853 }
854
855
856 impl ast::NameOwner for FieldPat {}
857 impl FieldPat {
858     pub fn pat(&self) -> Option<Pat> {
859         super::child_opt(self)
860     }
861 }
862
863 // FieldPatList
864 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
865 pub struct FieldPatList {
866     pub(crate) syntax: SyntaxNode,
867 }
868
869 impl AstNode for FieldPatList {
870     fn cast(syntax: SyntaxNode) -> Option<Self> {
871         match syntax.kind() {
872             FIELD_PAT_LIST => Some(FieldPatList { syntax }),
873             _ => None,
874         }
875     }
876     fn syntax(&self) -> &SyntaxNode { &self.syntax }
877 }
878
879
880 impl FieldPatList {
881     pub fn field_pats(&self) -> impl Iterator<Item = FieldPat> {
882         super::children(self)
883     }
884
885     pub fn bind_pats(&self) -> impl Iterator<Item = BindPat> {
886         super::children(self)
887     }
888 }
889
890 // FnDef
891 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
892 pub struct FnDef {
893     pub(crate) syntax: SyntaxNode,
894 }
895
896 impl AstNode for FnDef {
897     fn cast(syntax: SyntaxNode) -> Option<Self> {
898         match syntax.kind() {
899             FN_DEF => Some(FnDef { syntax }),
900             _ => None,
901         }
902     }
903     fn syntax(&self) -> &SyntaxNode { &self.syntax }
904 }
905
906
907 impl ast::VisibilityOwner for FnDef {}
908 impl ast::NameOwner for FnDef {}
909 impl ast::TypeParamsOwner for FnDef {}
910 impl ast::AttrsOwner for FnDef {}
911 impl ast::DocCommentsOwner for FnDef {}
912 impl FnDef {
913     pub fn param_list(&self) -> Option<ParamList> {
914         super::child_opt(self)
915     }
916
917     pub fn body(&self) -> Option<Block> {
918         super::child_opt(self)
919     }
920
921     pub fn ret_type(&self) -> Option<RetType> {
922         super::child_opt(self)
923     }
924 }
925
926 // FnPointerType
927 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
928 pub struct FnPointerType {
929     pub(crate) syntax: SyntaxNode,
930 }
931
932 impl AstNode for FnPointerType {
933     fn cast(syntax: SyntaxNode) -> Option<Self> {
934         match syntax.kind() {
935             FN_POINTER_TYPE => Some(FnPointerType { syntax }),
936             _ => None,
937         }
938     }
939     fn syntax(&self) -> &SyntaxNode { &self.syntax }
940 }
941
942
943 impl FnPointerType {
944     pub fn param_list(&self) -> Option<ParamList> {
945         super::child_opt(self)
946     }
947
948     pub fn ret_type(&self) -> Option<RetType> {
949         super::child_opt(self)
950     }
951 }
952
953 // ForExpr
954 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
955 pub struct ForExpr {
956     pub(crate) syntax: SyntaxNode,
957 }
958
959 impl AstNode for ForExpr {
960     fn cast(syntax: SyntaxNode) -> Option<Self> {
961         match syntax.kind() {
962             FOR_EXPR => Some(ForExpr { syntax }),
963             _ => None,
964         }
965     }
966     fn syntax(&self) -> &SyntaxNode { &self.syntax }
967 }
968
969
970 impl ast::LoopBodyOwner for ForExpr {}
971 impl ForExpr {
972     pub fn pat(&self) -> Option<Pat> {
973         super::child_opt(self)
974     }
975
976     pub fn iterable(&self) -> Option<Expr> {
977         super::child_opt(self)
978     }
979 }
980
981 // ForType
982 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
983 pub struct ForType {
984     pub(crate) syntax: SyntaxNode,
985 }
986
987 impl AstNode for ForType {
988     fn cast(syntax: SyntaxNode) -> Option<Self> {
989         match syntax.kind() {
990             FOR_TYPE => Some(ForType { syntax }),
991             _ => None,
992         }
993     }
994     fn syntax(&self) -> &SyntaxNode { &self.syntax }
995 }
996
997
998 impl ForType {
999     pub fn type_ref(&self) -> Option<TypeRef> {
1000         super::child_opt(self)
1001     }
1002 }
1003
1004 // IfExpr
1005 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1006 pub struct IfExpr {
1007     pub(crate) syntax: SyntaxNode,
1008 }
1009
1010 impl AstNode for IfExpr {
1011     fn cast(syntax: SyntaxNode) -> Option<Self> {
1012         match syntax.kind() {
1013             IF_EXPR => Some(IfExpr { syntax }),
1014             _ => None,
1015         }
1016     }
1017     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1018 }
1019
1020
1021 impl IfExpr {
1022     pub fn condition(&self) -> Option<Condition> {
1023         super::child_opt(self)
1024     }
1025 }
1026
1027 // ImplBlock
1028 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1029 pub struct ImplBlock {
1030     pub(crate) syntax: SyntaxNode,
1031 }
1032
1033 impl AstNode for ImplBlock {
1034     fn cast(syntax: SyntaxNode) -> Option<Self> {
1035         match syntax.kind() {
1036             IMPL_BLOCK => Some(ImplBlock { syntax }),
1037             _ => None,
1038         }
1039     }
1040     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1041 }
1042
1043
1044 impl ast::TypeParamsOwner for ImplBlock {}
1045 impl ast::AttrsOwner for ImplBlock {}
1046 impl ImplBlock {
1047     pub fn item_list(&self) -> Option<ItemList> {
1048         super::child_opt(self)
1049     }
1050 }
1051
1052 // ImplItem
1053 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1054 pub struct ImplItem {
1055     pub(crate) syntax: SyntaxNode,
1056 }
1057
1058 #[derive(Debug, Clone, PartialEq, Eq)]
1059 pub enum ImplItemKind {
1060     FnDef(FnDef),
1061     TypeAliasDef(TypeAliasDef),
1062     ConstDef(ConstDef),
1063 }
1064 impl From<FnDef> for ImplItem {
1065     fn from(n: FnDef) -> ImplItem {
1066         ImplItem::cast(n.syntax).unwrap()
1067     }
1068 }
1069 impl From<TypeAliasDef> for ImplItem {
1070     fn from(n: TypeAliasDef) -> ImplItem {
1071         ImplItem::cast(n.syntax).unwrap()
1072     }
1073 }
1074 impl From<ConstDef> for ImplItem {
1075     fn from(n: ConstDef) -> ImplItem {
1076         ImplItem::cast(n.syntax).unwrap()
1077     }
1078 }
1079
1080
1081 impl AstNode for ImplItem {
1082     fn cast(syntax: SyntaxNode) -> Option<Self> {
1083         match syntax.kind() {
1084             | FN_DEF
1085             | TYPE_ALIAS_DEF
1086             | CONST_DEF => Some(ImplItem { syntax }),
1087             _ => None,
1088         }
1089     }
1090     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1091 }
1092
1093 impl ImplItem {
1094     pub fn kind(&self) -> ImplItemKind {
1095         match self.syntax.kind() {
1096             FN_DEF => ImplItemKind::FnDef(FnDef::cast(self.syntax.clone()).unwrap()),
1097             TYPE_ALIAS_DEF => ImplItemKind::TypeAliasDef(TypeAliasDef::cast(self.syntax.clone()).unwrap()),
1098             CONST_DEF => ImplItemKind::ConstDef(ConstDef::cast(self.syntax.clone()).unwrap()),
1099             _ => unreachable!(),
1100         }
1101     }
1102 }
1103
1104 impl ImplItem {}
1105
1106 // ImplTraitType
1107 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1108 pub struct ImplTraitType {
1109     pub(crate) syntax: SyntaxNode,
1110 }
1111
1112 impl AstNode for ImplTraitType {
1113     fn cast(syntax: SyntaxNode) -> Option<Self> {
1114         match syntax.kind() {
1115             IMPL_TRAIT_TYPE => Some(ImplTraitType { syntax }),
1116             _ => None,
1117         }
1118     }
1119     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1120 }
1121
1122
1123 impl ast::TypeBoundsOwner for ImplTraitType {}
1124 impl ImplTraitType {}
1125
1126 // IndexExpr
1127 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1128 pub struct IndexExpr {
1129     pub(crate) syntax: SyntaxNode,
1130 }
1131
1132 impl AstNode for IndexExpr {
1133     fn cast(syntax: SyntaxNode) -> Option<Self> {
1134         match syntax.kind() {
1135             INDEX_EXPR => Some(IndexExpr { syntax }),
1136             _ => None,
1137         }
1138     }
1139     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1140 }
1141
1142
1143 impl IndexExpr {}
1144
1145 // ItemList
1146 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1147 pub struct ItemList {
1148     pub(crate) syntax: SyntaxNode,
1149 }
1150
1151 impl AstNode for ItemList {
1152     fn cast(syntax: SyntaxNode) -> Option<Self> {
1153         match syntax.kind() {
1154             ITEM_LIST => Some(ItemList { syntax }),
1155             _ => None,
1156         }
1157     }
1158     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1159 }
1160
1161
1162 impl ast::FnDefOwner for ItemList {}
1163 impl ast::ModuleItemOwner for ItemList {}
1164 impl ItemList {
1165     pub fn impl_items(&self) -> impl Iterator<Item = ImplItem> {
1166         super::children(self)
1167     }
1168 }
1169
1170 // Label
1171 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1172 pub struct Label {
1173     pub(crate) syntax: SyntaxNode,
1174 }
1175
1176 impl AstNode for Label {
1177     fn cast(syntax: SyntaxNode) -> Option<Self> {
1178         match syntax.kind() {
1179             LABEL => Some(Label { syntax }),
1180             _ => None,
1181         }
1182     }
1183     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1184 }
1185
1186
1187 impl Label {}
1188
1189 // LambdaExpr
1190 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1191 pub struct LambdaExpr {
1192     pub(crate) syntax: SyntaxNode,
1193 }
1194
1195 impl AstNode for LambdaExpr {
1196     fn cast(syntax: SyntaxNode) -> Option<Self> {
1197         match syntax.kind() {
1198             LAMBDA_EXPR => Some(LambdaExpr { syntax }),
1199             _ => None,
1200         }
1201     }
1202     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1203 }
1204
1205
1206 impl LambdaExpr {
1207     pub fn param_list(&self) -> Option<ParamList> {
1208         super::child_opt(self)
1209     }
1210
1211     pub fn body(&self) -> Option<Expr> {
1212         super::child_opt(self)
1213     }
1214 }
1215
1216 // LetStmt
1217 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1218 pub struct LetStmt {
1219     pub(crate) syntax: SyntaxNode,
1220 }
1221
1222 impl AstNode for LetStmt {
1223     fn cast(syntax: SyntaxNode) -> Option<Self> {
1224         match syntax.kind() {
1225             LET_STMT => Some(LetStmt { syntax }),
1226             _ => None,
1227         }
1228     }
1229     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1230 }
1231
1232
1233 impl ast::TypeAscriptionOwner for LetStmt {}
1234 impl LetStmt {
1235     pub fn pat(&self) -> Option<Pat> {
1236         super::child_opt(self)
1237     }
1238
1239     pub fn initializer(&self) -> Option<Expr> {
1240         super::child_opt(self)
1241     }
1242 }
1243
1244 // LifetimeArg
1245 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1246 pub struct LifetimeArg {
1247     pub(crate) syntax: SyntaxNode,
1248 }
1249
1250 impl AstNode for LifetimeArg {
1251     fn cast(syntax: SyntaxNode) -> Option<Self> {
1252         match syntax.kind() {
1253             LIFETIME_ARG => Some(LifetimeArg { syntax }),
1254             _ => None,
1255         }
1256     }
1257     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1258 }
1259
1260
1261 impl LifetimeArg {}
1262
1263 // LifetimeParam
1264 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1265 pub struct LifetimeParam {
1266     pub(crate) syntax: SyntaxNode,
1267 }
1268
1269 impl AstNode for LifetimeParam {
1270     fn cast(syntax: SyntaxNode) -> Option<Self> {
1271         match syntax.kind() {
1272             LIFETIME_PARAM => Some(LifetimeParam { syntax }),
1273             _ => None,
1274         }
1275     }
1276     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1277 }
1278
1279
1280 impl ast::AttrsOwner for LifetimeParam {}
1281 impl LifetimeParam {}
1282
1283 // Literal
1284 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1285 pub struct Literal {
1286     pub(crate) syntax: SyntaxNode,
1287 }
1288
1289 impl AstNode for Literal {
1290     fn cast(syntax: SyntaxNode) -> Option<Self> {
1291         match syntax.kind() {
1292             LITERAL => Some(Literal { syntax }),
1293             _ => None,
1294         }
1295     }
1296     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1297 }
1298
1299
1300 impl Literal {}
1301
1302 // LiteralPat
1303 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1304 pub struct LiteralPat {
1305     pub(crate) syntax: SyntaxNode,
1306 }
1307
1308 impl AstNode for LiteralPat {
1309     fn cast(syntax: SyntaxNode) -> Option<Self> {
1310         match syntax.kind() {
1311             LITERAL_PAT => Some(LiteralPat { syntax }),
1312             _ => None,
1313         }
1314     }
1315     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1316 }
1317
1318
1319 impl LiteralPat {
1320     pub fn literal(&self) -> Option<Literal> {
1321         super::child_opt(self)
1322     }
1323 }
1324
1325 // LoopExpr
1326 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1327 pub struct LoopExpr {
1328     pub(crate) syntax: SyntaxNode,
1329 }
1330
1331 impl AstNode for LoopExpr {
1332     fn cast(syntax: SyntaxNode) -> Option<Self> {
1333         match syntax.kind() {
1334             LOOP_EXPR => Some(LoopExpr { syntax }),
1335             _ => None,
1336         }
1337     }
1338     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1339 }
1340
1341
1342 impl ast::LoopBodyOwner for LoopExpr {}
1343 impl LoopExpr {}
1344
1345 // MacroCall
1346 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1347 pub struct MacroCall {
1348     pub(crate) syntax: SyntaxNode,
1349 }
1350
1351 impl AstNode for MacroCall {
1352     fn cast(syntax: SyntaxNode) -> Option<Self> {
1353         match syntax.kind() {
1354             MACRO_CALL => Some(MacroCall { syntax }),
1355             _ => None,
1356         }
1357     }
1358     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1359 }
1360
1361
1362 impl ast::NameOwner for MacroCall {}
1363 impl ast::AttrsOwner for MacroCall {}
1364 impl ast::DocCommentsOwner for MacroCall {}
1365 impl MacroCall {
1366     pub fn token_tree(&self) -> Option<TokenTree> {
1367         super::child_opt(self)
1368     }
1369
1370     pub fn path(&self) -> Option<Path> {
1371         super::child_opt(self)
1372     }
1373 }
1374
1375 // MacroItems
1376 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1377 pub struct MacroItems {
1378     pub(crate) syntax: SyntaxNode,
1379 }
1380
1381 impl AstNode for MacroItems {
1382     fn cast(syntax: SyntaxNode) -> Option<Self> {
1383         match syntax.kind() {
1384             MACRO_ITEMS => Some(MacroItems { syntax }),
1385             _ => None,
1386         }
1387     }
1388     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1389 }
1390
1391
1392 impl ast::ModuleItemOwner for MacroItems {}
1393 impl ast::FnDefOwner for MacroItems {}
1394 impl MacroItems {}
1395
1396 // MacroStmts
1397 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1398 pub struct MacroStmts {
1399     pub(crate) syntax: SyntaxNode,
1400 }
1401
1402 impl AstNode for MacroStmts {
1403     fn cast(syntax: SyntaxNode) -> Option<Self> {
1404         match syntax.kind() {
1405             MACRO_STMTS => Some(MacroStmts { syntax }),
1406             _ => None,
1407         }
1408     }
1409     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1410 }
1411
1412
1413 impl MacroStmts {
1414     pub fn statements(&self) -> impl Iterator<Item = Stmt> {
1415         super::children(self)
1416     }
1417
1418     pub fn expr(&self) -> Option<Expr> {
1419         super::child_opt(self)
1420     }
1421 }
1422
1423 // MatchArm
1424 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1425 pub struct MatchArm {
1426     pub(crate) syntax: SyntaxNode,
1427 }
1428
1429 impl AstNode for MatchArm {
1430     fn cast(syntax: SyntaxNode) -> Option<Self> {
1431         match syntax.kind() {
1432             MATCH_ARM => Some(MatchArm { syntax }),
1433             _ => None,
1434         }
1435     }
1436     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1437 }
1438
1439
1440 impl ast::AttrsOwner for MatchArm {}
1441 impl MatchArm {
1442     pub fn pats(&self) -> impl Iterator<Item = Pat> {
1443         super::children(self)
1444     }
1445
1446     pub fn guard(&self) -> Option<MatchGuard> {
1447         super::child_opt(self)
1448     }
1449
1450     pub fn expr(&self) -> Option<Expr> {
1451         super::child_opt(self)
1452     }
1453 }
1454
1455 // MatchArmList
1456 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1457 pub struct MatchArmList {
1458     pub(crate) syntax: SyntaxNode,
1459 }
1460
1461 impl AstNode for MatchArmList {
1462     fn cast(syntax: SyntaxNode) -> Option<Self> {
1463         match syntax.kind() {
1464             MATCH_ARM_LIST => Some(MatchArmList { syntax }),
1465             _ => None,
1466         }
1467     }
1468     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1469 }
1470
1471
1472 impl ast::AttrsOwner for MatchArmList {}
1473 impl MatchArmList {
1474     pub fn arms(&self) -> impl Iterator<Item = MatchArm> {
1475         super::children(self)
1476     }
1477 }
1478
1479 // MatchExpr
1480 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1481 pub struct MatchExpr {
1482     pub(crate) syntax: SyntaxNode,
1483 }
1484
1485 impl AstNode for MatchExpr {
1486     fn cast(syntax: SyntaxNode) -> Option<Self> {
1487         match syntax.kind() {
1488             MATCH_EXPR => Some(MatchExpr { syntax }),
1489             _ => None,
1490         }
1491     }
1492     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1493 }
1494
1495
1496 impl MatchExpr {
1497     pub fn expr(&self) -> Option<Expr> {
1498         super::child_opt(self)
1499     }
1500
1501     pub fn match_arm_list(&self) -> Option<MatchArmList> {
1502         super::child_opt(self)
1503     }
1504 }
1505
1506 // MatchGuard
1507 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1508 pub struct MatchGuard {
1509     pub(crate) syntax: SyntaxNode,
1510 }
1511
1512 impl AstNode for MatchGuard {
1513     fn cast(syntax: SyntaxNode) -> Option<Self> {
1514         match syntax.kind() {
1515             MATCH_GUARD => Some(MatchGuard { syntax }),
1516             _ => None,
1517         }
1518     }
1519     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1520 }
1521
1522
1523 impl MatchGuard {
1524     pub fn expr(&self) -> Option<Expr> {
1525         super::child_opt(self)
1526     }
1527 }
1528
1529 // MethodCallExpr
1530 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1531 pub struct MethodCallExpr {
1532     pub(crate) syntax: SyntaxNode,
1533 }
1534
1535 impl AstNode for MethodCallExpr {
1536     fn cast(syntax: SyntaxNode) -> Option<Self> {
1537         match syntax.kind() {
1538             METHOD_CALL_EXPR => Some(MethodCallExpr { syntax }),
1539             _ => None,
1540         }
1541     }
1542     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1543 }
1544
1545
1546 impl ast::ArgListOwner for MethodCallExpr {}
1547 impl MethodCallExpr {
1548     pub fn expr(&self) -> Option<Expr> {
1549         super::child_opt(self)
1550     }
1551
1552     pub fn name_ref(&self) -> Option<NameRef> {
1553         super::child_opt(self)
1554     }
1555
1556     pub fn type_arg_list(&self) -> Option<TypeArgList> {
1557         super::child_opt(self)
1558     }
1559 }
1560
1561 // Module
1562 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1563 pub struct Module {
1564     pub(crate) syntax: SyntaxNode,
1565 }
1566
1567 impl AstNode for Module {
1568     fn cast(syntax: SyntaxNode) -> Option<Self> {
1569         match syntax.kind() {
1570             MODULE => Some(Module { syntax }),
1571             _ => None,
1572         }
1573     }
1574     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1575 }
1576
1577
1578 impl ast::VisibilityOwner for Module {}
1579 impl ast::NameOwner for Module {}
1580 impl ast::AttrsOwner for Module {}
1581 impl ast::DocCommentsOwner for Module {}
1582 impl Module {
1583     pub fn item_list(&self) -> Option<ItemList> {
1584         super::child_opt(self)
1585     }
1586 }
1587
1588 // ModuleItem
1589 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1590 pub struct ModuleItem {
1591     pub(crate) syntax: SyntaxNode,
1592 }
1593
1594 #[derive(Debug, Clone, PartialEq, Eq)]
1595 pub enum ModuleItemKind {
1596     StructDef(StructDef),
1597     EnumDef(EnumDef),
1598     FnDef(FnDef),
1599     TraitDef(TraitDef),
1600     TypeAliasDef(TypeAliasDef),
1601     ImplBlock(ImplBlock),
1602     UseItem(UseItem),
1603     ExternCrateItem(ExternCrateItem),
1604     ConstDef(ConstDef),
1605     StaticDef(StaticDef),
1606     Module(Module),
1607 }
1608 impl From<StructDef> for ModuleItem {
1609     fn from(n: StructDef) -> ModuleItem {
1610         ModuleItem::cast(n.syntax).unwrap()
1611     }
1612 }
1613 impl From<EnumDef> for ModuleItem {
1614     fn from(n: EnumDef) -> ModuleItem {
1615         ModuleItem::cast(n.syntax).unwrap()
1616     }
1617 }
1618 impl From<FnDef> for ModuleItem {
1619     fn from(n: FnDef) -> ModuleItem {
1620         ModuleItem::cast(n.syntax).unwrap()
1621     }
1622 }
1623 impl From<TraitDef> for ModuleItem {
1624     fn from(n: TraitDef) -> ModuleItem {
1625         ModuleItem::cast(n.syntax).unwrap()
1626     }
1627 }
1628 impl From<TypeAliasDef> for ModuleItem {
1629     fn from(n: TypeAliasDef) -> ModuleItem {
1630         ModuleItem::cast(n.syntax).unwrap()
1631     }
1632 }
1633 impl From<ImplBlock> for ModuleItem {
1634     fn from(n: ImplBlock) -> ModuleItem {
1635         ModuleItem::cast(n.syntax).unwrap()
1636     }
1637 }
1638 impl From<UseItem> for ModuleItem {
1639     fn from(n: UseItem) -> ModuleItem {
1640         ModuleItem::cast(n.syntax).unwrap()
1641     }
1642 }
1643 impl From<ExternCrateItem> for ModuleItem {
1644     fn from(n: ExternCrateItem) -> ModuleItem {
1645         ModuleItem::cast(n.syntax).unwrap()
1646     }
1647 }
1648 impl From<ConstDef> for ModuleItem {
1649     fn from(n: ConstDef) -> ModuleItem {
1650         ModuleItem::cast(n.syntax).unwrap()
1651     }
1652 }
1653 impl From<StaticDef> for ModuleItem {
1654     fn from(n: StaticDef) -> ModuleItem {
1655         ModuleItem::cast(n.syntax).unwrap()
1656     }
1657 }
1658 impl From<Module> for ModuleItem {
1659     fn from(n: Module) -> ModuleItem {
1660         ModuleItem::cast(n.syntax).unwrap()
1661     }
1662 }
1663
1664
1665 impl AstNode for ModuleItem {
1666     fn cast(syntax: SyntaxNode) -> Option<Self> {
1667         match syntax.kind() {
1668             | STRUCT_DEF
1669             | ENUM_DEF
1670             | FN_DEF
1671             | TRAIT_DEF
1672             | TYPE_ALIAS_DEF
1673             | IMPL_BLOCK
1674             | USE_ITEM
1675             | EXTERN_CRATE_ITEM
1676             | CONST_DEF
1677             | STATIC_DEF
1678             | MODULE => Some(ModuleItem { syntax }),
1679             _ => None,
1680         }
1681     }
1682     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1683 }
1684
1685 impl ModuleItem {
1686     pub fn kind(&self) -> ModuleItemKind {
1687         match self.syntax.kind() {
1688             STRUCT_DEF => ModuleItemKind::StructDef(StructDef::cast(self.syntax.clone()).unwrap()),
1689             ENUM_DEF => ModuleItemKind::EnumDef(EnumDef::cast(self.syntax.clone()).unwrap()),
1690             FN_DEF => ModuleItemKind::FnDef(FnDef::cast(self.syntax.clone()).unwrap()),
1691             TRAIT_DEF => ModuleItemKind::TraitDef(TraitDef::cast(self.syntax.clone()).unwrap()),
1692             TYPE_ALIAS_DEF => ModuleItemKind::TypeAliasDef(TypeAliasDef::cast(self.syntax.clone()).unwrap()),
1693             IMPL_BLOCK => ModuleItemKind::ImplBlock(ImplBlock::cast(self.syntax.clone()).unwrap()),
1694             USE_ITEM => ModuleItemKind::UseItem(UseItem::cast(self.syntax.clone()).unwrap()),
1695             EXTERN_CRATE_ITEM => ModuleItemKind::ExternCrateItem(ExternCrateItem::cast(self.syntax.clone()).unwrap()),
1696             CONST_DEF => ModuleItemKind::ConstDef(ConstDef::cast(self.syntax.clone()).unwrap()),
1697             STATIC_DEF => ModuleItemKind::StaticDef(StaticDef::cast(self.syntax.clone()).unwrap()),
1698             MODULE => ModuleItemKind::Module(Module::cast(self.syntax.clone()).unwrap()),
1699             _ => unreachable!(),
1700         }
1701     }
1702 }
1703
1704 impl ModuleItem {}
1705
1706 // Name
1707 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1708 pub struct Name {
1709     pub(crate) syntax: SyntaxNode,
1710 }
1711
1712 impl AstNode for Name {
1713     fn cast(syntax: SyntaxNode) -> Option<Self> {
1714         match syntax.kind() {
1715             NAME => Some(Name { syntax }),
1716             _ => None,
1717         }
1718     }
1719     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1720 }
1721
1722
1723 impl Name {}
1724
1725 // NameRef
1726 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1727 pub struct NameRef {
1728     pub(crate) syntax: SyntaxNode,
1729 }
1730
1731 impl AstNode for NameRef {
1732     fn cast(syntax: SyntaxNode) -> Option<Self> {
1733         match syntax.kind() {
1734             NAME_REF => Some(NameRef { syntax }),
1735             _ => None,
1736         }
1737     }
1738     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1739 }
1740
1741
1742 impl NameRef {}
1743
1744 // NamedField
1745 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1746 pub struct NamedField {
1747     pub(crate) syntax: SyntaxNode,
1748 }
1749
1750 impl AstNode for NamedField {
1751     fn cast(syntax: SyntaxNode) -> Option<Self> {
1752         match syntax.kind() {
1753             NAMED_FIELD => Some(NamedField { syntax }),
1754             _ => None,
1755         }
1756     }
1757     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1758 }
1759
1760
1761 impl NamedField {
1762     pub fn name_ref(&self) -> Option<NameRef> {
1763         super::child_opt(self)
1764     }
1765
1766     pub fn expr(&self) -> Option<Expr> {
1767         super::child_opt(self)
1768     }
1769 }
1770
1771 // NamedFieldDef
1772 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1773 pub struct NamedFieldDef {
1774     pub(crate) syntax: SyntaxNode,
1775 }
1776
1777 impl AstNode for NamedFieldDef {
1778     fn cast(syntax: SyntaxNode) -> Option<Self> {
1779         match syntax.kind() {
1780             NAMED_FIELD_DEF => Some(NamedFieldDef { syntax }),
1781             _ => None,
1782         }
1783     }
1784     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1785 }
1786
1787
1788 impl ast::VisibilityOwner for NamedFieldDef {}
1789 impl ast::NameOwner for NamedFieldDef {}
1790 impl ast::AttrsOwner for NamedFieldDef {}
1791 impl ast::DocCommentsOwner for NamedFieldDef {}
1792 impl ast::TypeAscriptionOwner for NamedFieldDef {}
1793 impl NamedFieldDef {}
1794
1795 // NamedFieldDefList
1796 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1797 pub struct NamedFieldDefList {
1798     pub(crate) syntax: SyntaxNode,
1799 }
1800
1801 impl AstNode for NamedFieldDefList {
1802     fn cast(syntax: SyntaxNode) -> Option<Self> {
1803         match syntax.kind() {
1804             NAMED_FIELD_DEF_LIST => Some(NamedFieldDefList { syntax }),
1805             _ => None,
1806         }
1807     }
1808     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1809 }
1810
1811
1812 impl NamedFieldDefList {
1813     pub fn fields(&self) -> impl Iterator<Item = NamedFieldDef> {
1814         super::children(self)
1815     }
1816 }
1817
1818 // NamedFieldList
1819 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1820 pub struct NamedFieldList {
1821     pub(crate) syntax: SyntaxNode,
1822 }
1823
1824 impl AstNode for NamedFieldList {
1825     fn cast(syntax: SyntaxNode) -> Option<Self> {
1826         match syntax.kind() {
1827             NAMED_FIELD_LIST => Some(NamedFieldList { syntax }),
1828             _ => None,
1829         }
1830     }
1831     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1832 }
1833
1834
1835 impl NamedFieldList {
1836     pub fn fields(&self) -> impl Iterator<Item = NamedField> {
1837         super::children(self)
1838     }
1839
1840     pub fn spread(&self) -> Option<Expr> {
1841         super::child_opt(self)
1842     }
1843 }
1844
1845 // NeverType
1846 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1847 pub struct NeverType {
1848     pub(crate) syntax: SyntaxNode,
1849 }
1850
1851 impl AstNode for NeverType {
1852     fn cast(syntax: SyntaxNode) -> Option<Self> {
1853         match syntax.kind() {
1854             NEVER_TYPE => Some(NeverType { syntax }),
1855             _ => None,
1856         }
1857     }
1858     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1859 }
1860
1861
1862 impl NeverType {}
1863
1864 // NominalDef
1865 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1866 pub struct NominalDef {
1867     pub(crate) syntax: SyntaxNode,
1868 }
1869
1870 #[derive(Debug, Clone, PartialEq, Eq)]
1871 pub enum NominalDefKind {
1872     StructDef(StructDef),
1873     EnumDef(EnumDef),
1874 }
1875 impl From<StructDef> for NominalDef {
1876     fn from(n: StructDef) -> NominalDef {
1877         NominalDef::cast(n.syntax).unwrap()
1878     }
1879 }
1880 impl From<EnumDef> for NominalDef {
1881     fn from(n: EnumDef) -> NominalDef {
1882         NominalDef::cast(n.syntax).unwrap()
1883     }
1884 }
1885
1886
1887 impl AstNode for NominalDef {
1888     fn cast(syntax: SyntaxNode) -> Option<Self> {
1889         match syntax.kind() {
1890             | STRUCT_DEF
1891             | ENUM_DEF => Some(NominalDef { syntax }),
1892             _ => None,
1893         }
1894     }
1895     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1896 }
1897
1898 impl NominalDef {
1899     pub fn kind(&self) -> NominalDefKind {
1900         match self.syntax.kind() {
1901             STRUCT_DEF => NominalDefKind::StructDef(StructDef::cast(self.syntax.clone()).unwrap()),
1902             ENUM_DEF => NominalDefKind::EnumDef(EnumDef::cast(self.syntax.clone()).unwrap()),
1903             _ => unreachable!(),
1904         }
1905     }
1906 }
1907
1908 impl ast::NameOwner for NominalDef {}
1909 impl ast::TypeParamsOwner for NominalDef {}
1910 impl ast::AttrsOwner for NominalDef {}
1911 impl NominalDef {}
1912
1913 // Param
1914 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1915 pub struct Param {
1916     pub(crate) syntax: SyntaxNode,
1917 }
1918
1919 impl AstNode for Param {
1920     fn cast(syntax: SyntaxNode) -> Option<Self> {
1921         match syntax.kind() {
1922             PARAM => Some(Param { syntax }),
1923             _ => None,
1924         }
1925     }
1926     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1927 }
1928
1929
1930 impl ast::TypeAscriptionOwner for Param {}
1931 impl Param {
1932     pub fn pat(&self) -> Option<Pat> {
1933         super::child_opt(self)
1934     }
1935 }
1936
1937 // ParamList
1938 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1939 pub struct ParamList {
1940     pub(crate) syntax: SyntaxNode,
1941 }
1942
1943 impl AstNode for ParamList {
1944     fn cast(syntax: SyntaxNode) -> Option<Self> {
1945         match syntax.kind() {
1946             PARAM_LIST => Some(ParamList { syntax }),
1947             _ => None,
1948         }
1949     }
1950     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1951 }
1952
1953
1954 impl ParamList {
1955     pub fn params(&self) -> impl Iterator<Item = Param> {
1956         super::children(self)
1957     }
1958
1959     pub fn self_param(&self) -> Option<SelfParam> {
1960         super::child_opt(self)
1961     }
1962 }
1963
1964 // ParenExpr
1965 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1966 pub struct ParenExpr {
1967     pub(crate) syntax: SyntaxNode,
1968 }
1969
1970 impl AstNode for ParenExpr {
1971     fn cast(syntax: SyntaxNode) -> Option<Self> {
1972         match syntax.kind() {
1973             PAREN_EXPR => Some(ParenExpr { syntax }),
1974             _ => None,
1975         }
1976     }
1977     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1978 }
1979
1980
1981 impl ParenExpr {
1982     pub fn expr(&self) -> Option<Expr> {
1983         super::child_opt(self)
1984     }
1985 }
1986
1987 // ParenType
1988 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1989 pub struct ParenType {
1990     pub(crate) syntax: SyntaxNode,
1991 }
1992
1993 impl AstNode for ParenType {
1994     fn cast(syntax: SyntaxNode) -> Option<Self> {
1995         match syntax.kind() {
1996             PAREN_TYPE => Some(ParenType { syntax }),
1997             _ => None,
1998         }
1999     }
2000     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2001 }
2002
2003
2004 impl ParenType {
2005     pub fn type_ref(&self) -> Option<TypeRef> {
2006         super::child_opt(self)
2007     }
2008 }
2009
2010 // Pat
2011 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2012 pub struct Pat {
2013     pub(crate) syntax: SyntaxNode,
2014 }
2015
2016 #[derive(Debug, Clone, PartialEq, Eq)]
2017 pub enum PatKind {
2018     RefPat(RefPat),
2019     BindPat(BindPat),
2020     PlaceholderPat(PlaceholderPat),
2021     PathPat(PathPat),
2022     StructPat(StructPat),
2023     TupleStructPat(TupleStructPat),
2024     TuplePat(TuplePat),
2025     SlicePat(SlicePat),
2026     RangePat(RangePat),
2027     LiteralPat(LiteralPat),
2028 }
2029 impl From<RefPat> for Pat {
2030     fn from(n: RefPat) -> Pat {
2031         Pat::cast(n.syntax).unwrap()
2032     }
2033 }
2034 impl From<BindPat> for Pat {
2035     fn from(n: BindPat) -> Pat {
2036         Pat::cast(n.syntax).unwrap()
2037     }
2038 }
2039 impl From<PlaceholderPat> for Pat {
2040     fn from(n: PlaceholderPat) -> Pat {
2041         Pat::cast(n.syntax).unwrap()
2042     }
2043 }
2044 impl From<PathPat> for Pat {
2045     fn from(n: PathPat) -> Pat {
2046         Pat::cast(n.syntax).unwrap()
2047     }
2048 }
2049 impl From<StructPat> for Pat {
2050     fn from(n: StructPat) -> Pat {
2051         Pat::cast(n.syntax).unwrap()
2052     }
2053 }
2054 impl From<TupleStructPat> for Pat {
2055     fn from(n: TupleStructPat) -> Pat {
2056         Pat::cast(n.syntax).unwrap()
2057     }
2058 }
2059 impl From<TuplePat> for Pat {
2060     fn from(n: TuplePat) -> Pat {
2061         Pat::cast(n.syntax).unwrap()
2062     }
2063 }
2064 impl From<SlicePat> for Pat {
2065     fn from(n: SlicePat) -> Pat {
2066         Pat::cast(n.syntax).unwrap()
2067     }
2068 }
2069 impl From<RangePat> for Pat {
2070     fn from(n: RangePat) -> Pat {
2071         Pat::cast(n.syntax).unwrap()
2072     }
2073 }
2074 impl From<LiteralPat> for Pat {
2075     fn from(n: LiteralPat) -> Pat {
2076         Pat::cast(n.syntax).unwrap()
2077     }
2078 }
2079
2080
2081 impl AstNode for Pat {
2082     fn cast(syntax: SyntaxNode) -> Option<Self> {
2083         match syntax.kind() {
2084             | REF_PAT
2085             | BIND_PAT
2086             | PLACEHOLDER_PAT
2087             | PATH_PAT
2088             | STRUCT_PAT
2089             | TUPLE_STRUCT_PAT
2090             | TUPLE_PAT
2091             | SLICE_PAT
2092             | RANGE_PAT
2093             | LITERAL_PAT => Some(Pat { syntax }),
2094             _ => None,
2095         }
2096     }
2097     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2098 }
2099
2100 impl Pat {
2101     pub fn kind(&self) -> PatKind {
2102         match self.syntax.kind() {
2103             REF_PAT => PatKind::RefPat(RefPat::cast(self.syntax.clone()).unwrap()),
2104             BIND_PAT => PatKind::BindPat(BindPat::cast(self.syntax.clone()).unwrap()),
2105             PLACEHOLDER_PAT => PatKind::PlaceholderPat(PlaceholderPat::cast(self.syntax.clone()).unwrap()),
2106             PATH_PAT => PatKind::PathPat(PathPat::cast(self.syntax.clone()).unwrap()),
2107             STRUCT_PAT => PatKind::StructPat(StructPat::cast(self.syntax.clone()).unwrap()),
2108             TUPLE_STRUCT_PAT => PatKind::TupleStructPat(TupleStructPat::cast(self.syntax.clone()).unwrap()),
2109             TUPLE_PAT => PatKind::TuplePat(TuplePat::cast(self.syntax.clone()).unwrap()),
2110             SLICE_PAT => PatKind::SlicePat(SlicePat::cast(self.syntax.clone()).unwrap()),
2111             RANGE_PAT => PatKind::RangePat(RangePat::cast(self.syntax.clone()).unwrap()),
2112             LITERAL_PAT => PatKind::LiteralPat(LiteralPat::cast(self.syntax.clone()).unwrap()),
2113             _ => unreachable!(),
2114         }
2115     }
2116 }
2117
2118 impl Pat {}
2119
2120 // Path
2121 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2122 pub struct Path {
2123     pub(crate) syntax: SyntaxNode,
2124 }
2125
2126 impl AstNode for Path {
2127     fn cast(syntax: SyntaxNode) -> Option<Self> {
2128         match syntax.kind() {
2129             PATH => Some(Path { syntax }),
2130             _ => None,
2131         }
2132     }
2133     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2134 }
2135
2136
2137 impl Path {
2138     pub fn segment(&self) -> Option<PathSegment> {
2139         super::child_opt(self)
2140     }
2141
2142     pub fn qualifier(&self) -> Option<Path> {
2143         super::child_opt(self)
2144     }
2145 }
2146
2147 // PathExpr
2148 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2149 pub struct PathExpr {
2150     pub(crate) syntax: SyntaxNode,
2151 }
2152
2153 impl AstNode for PathExpr {
2154     fn cast(syntax: SyntaxNode) -> Option<Self> {
2155         match syntax.kind() {
2156             PATH_EXPR => Some(PathExpr { syntax }),
2157             _ => None,
2158         }
2159     }
2160     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2161 }
2162
2163
2164 impl PathExpr {
2165     pub fn path(&self) -> Option<Path> {
2166         super::child_opt(self)
2167     }
2168 }
2169
2170 // PathPat
2171 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2172 pub struct PathPat {
2173     pub(crate) syntax: SyntaxNode,
2174 }
2175
2176 impl AstNode for PathPat {
2177     fn cast(syntax: SyntaxNode) -> Option<Self> {
2178         match syntax.kind() {
2179             PATH_PAT => Some(PathPat { syntax }),
2180             _ => None,
2181         }
2182     }
2183     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2184 }
2185
2186
2187 impl PathPat {
2188     pub fn path(&self) -> Option<Path> {
2189         super::child_opt(self)
2190     }
2191 }
2192
2193 // PathSegment
2194 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2195 pub struct PathSegment {
2196     pub(crate) syntax: SyntaxNode,
2197 }
2198
2199 impl AstNode for PathSegment {
2200     fn cast(syntax: SyntaxNode) -> Option<Self> {
2201         match syntax.kind() {
2202             PATH_SEGMENT => Some(PathSegment { syntax }),
2203             _ => None,
2204         }
2205     }
2206     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2207 }
2208
2209
2210 impl PathSegment {
2211     pub fn name_ref(&self) -> Option<NameRef> {
2212         super::child_opt(self)
2213     }
2214
2215     pub fn type_arg_list(&self) -> Option<TypeArgList> {
2216         super::child_opt(self)
2217     }
2218 }
2219
2220 // PathType
2221 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2222 pub struct PathType {
2223     pub(crate) syntax: SyntaxNode,
2224 }
2225
2226 impl AstNode for PathType {
2227     fn cast(syntax: SyntaxNode) -> Option<Self> {
2228         match syntax.kind() {
2229             PATH_TYPE => Some(PathType { syntax }),
2230             _ => None,
2231         }
2232     }
2233     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2234 }
2235
2236
2237 impl PathType {
2238     pub fn path(&self) -> Option<Path> {
2239         super::child_opt(self)
2240     }
2241 }
2242
2243 // PlaceholderPat
2244 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2245 pub struct PlaceholderPat {
2246     pub(crate) syntax: SyntaxNode,
2247 }
2248
2249 impl AstNode for PlaceholderPat {
2250     fn cast(syntax: SyntaxNode) -> Option<Self> {
2251         match syntax.kind() {
2252             PLACEHOLDER_PAT => Some(PlaceholderPat { syntax }),
2253             _ => None,
2254         }
2255     }
2256     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2257 }
2258
2259
2260 impl PlaceholderPat {}
2261
2262 // PlaceholderType
2263 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2264 pub struct PlaceholderType {
2265     pub(crate) syntax: SyntaxNode,
2266 }
2267
2268 impl AstNode for PlaceholderType {
2269     fn cast(syntax: SyntaxNode) -> Option<Self> {
2270         match syntax.kind() {
2271             PLACEHOLDER_TYPE => Some(PlaceholderType { syntax }),
2272             _ => None,
2273         }
2274     }
2275     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2276 }
2277
2278
2279 impl PlaceholderType {}
2280
2281 // PointerType
2282 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2283 pub struct PointerType {
2284     pub(crate) syntax: SyntaxNode,
2285 }
2286
2287 impl AstNode for PointerType {
2288     fn cast(syntax: SyntaxNode) -> Option<Self> {
2289         match syntax.kind() {
2290             POINTER_TYPE => Some(PointerType { syntax }),
2291             _ => None,
2292         }
2293     }
2294     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2295 }
2296
2297
2298 impl PointerType {
2299     pub fn type_ref(&self) -> Option<TypeRef> {
2300         super::child_opt(self)
2301     }
2302 }
2303
2304 // PosFieldDef
2305 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2306 pub struct PosFieldDef {
2307     pub(crate) syntax: SyntaxNode,
2308 }
2309
2310 impl AstNode for PosFieldDef {
2311     fn cast(syntax: SyntaxNode) -> Option<Self> {
2312         match syntax.kind() {
2313             POS_FIELD_DEF => Some(PosFieldDef { syntax }),
2314             _ => None,
2315         }
2316     }
2317     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2318 }
2319
2320
2321 impl ast::VisibilityOwner for PosFieldDef {}
2322 impl ast::AttrsOwner for PosFieldDef {}
2323 impl PosFieldDef {
2324     pub fn type_ref(&self) -> Option<TypeRef> {
2325         super::child_opt(self)
2326     }
2327 }
2328
2329 // PosFieldDefList
2330 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2331 pub struct PosFieldDefList {
2332     pub(crate) syntax: SyntaxNode,
2333 }
2334
2335 impl AstNode for PosFieldDefList {
2336     fn cast(syntax: SyntaxNode) -> Option<Self> {
2337         match syntax.kind() {
2338             POS_FIELD_DEF_LIST => Some(PosFieldDefList { syntax }),
2339             _ => None,
2340         }
2341     }
2342     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2343 }
2344
2345
2346 impl PosFieldDefList {
2347     pub fn fields(&self) -> impl Iterator<Item = PosFieldDef> {
2348         super::children(self)
2349     }
2350 }
2351
2352 // PrefixExpr
2353 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2354 pub struct PrefixExpr {
2355     pub(crate) syntax: SyntaxNode,
2356 }
2357
2358 impl AstNode for PrefixExpr {
2359     fn cast(syntax: SyntaxNode) -> Option<Self> {
2360         match syntax.kind() {
2361             PREFIX_EXPR => Some(PrefixExpr { syntax }),
2362             _ => None,
2363         }
2364     }
2365     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2366 }
2367
2368
2369 impl PrefixExpr {
2370     pub fn expr(&self) -> Option<Expr> {
2371         super::child_opt(self)
2372     }
2373 }
2374
2375 // RangeExpr
2376 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2377 pub struct RangeExpr {
2378     pub(crate) syntax: SyntaxNode,
2379 }
2380
2381 impl AstNode for RangeExpr {
2382     fn cast(syntax: SyntaxNode) -> Option<Self> {
2383         match syntax.kind() {
2384             RANGE_EXPR => Some(RangeExpr { syntax }),
2385             _ => None,
2386         }
2387     }
2388     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2389 }
2390
2391
2392 impl RangeExpr {}
2393
2394 // RangePat
2395 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2396 pub struct RangePat {
2397     pub(crate) syntax: SyntaxNode,
2398 }
2399
2400 impl AstNode for RangePat {
2401     fn cast(syntax: SyntaxNode) -> Option<Self> {
2402         match syntax.kind() {
2403             RANGE_PAT => Some(RangePat { syntax }),
2404             _ => None,
2405         }
2406     }
2407     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2408 }
2409
2410
2411 impl RangePat {}
2412
2413 // RefExpr
2414 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2415 pub struct RefExpr {
2416     pub(crate) syntax: SyntaxNode,
2417 }
2418
2419 impl AstNode for RefExpr {
2420     fn cast(syntax: SyntaxNode) -> Option<Self> {
2421         match syntax.kind() {
2422             REF_EXPR => Some(RefExpr { syntax }),
2423             _ => None,
2424         }
2425     }
2426     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2427 }
2428
2429
2430 impl RefExpr {
2431     pub fn expr(&self) -> Option<Expr> {
2432         super::child_opt(self)
2433     }
2434 }
2435
2436 // RefPat
2437 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2438 pub struct RefPat {
2439     pub(crate) syntax: SyntaxNode,
2440 }
2441
2442 impl AstNode for RefPat {
2443     fn cast(syntax: SyntaxNode) -> Option<Self> {
2444         match syntax.kind() {
2445             REF_PAT => Some(RefPat { syntax }),
2446             _ => None,
2447         }
2448     }
2449     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2450 }
2451
2452
2453 impl RefPat {
2454     pub fn pat(&self) -> Option<Pat> {
2455         super::child_opt(self)
2456     }
2457 }
2458
2459 // ReferenceType
2460 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2461 pub struct ReferenceType {
2462     pub(crate) syntax: SyntaxNode,
2463 }
2464
2465 impl AstNode for ReferenceType {
2466     fn cast(syntax: SyntaxNode) -> Option<Self> {
2467         match syntax.kind() {
2468             REFERENCE_TYPE => Some(ReferenceType { syntax }),
2469             _ => None,
2470         }
2471     }
2472     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2473 }
2474
2475
2476 impl ReferenceType {
2477     pub fn type_ref(&self) -> Option<TypeRef> {
2478         super::child_opt(self)
2479     }
2480 }
2481
2482 // RetType
2483 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2484 pub struct RetType {
2485     pub(crate) syntax: SyntaxNode,
2486 }
2487
2488 impl AstNode for RetType {
2489     fn cast(syntax: SyntaxNode) -> Option<Self> {
2490         match syntax.kind() {
2491             RET_TYPE => Some(RetType { syntax }),
2492             _ => None,
2493         }
2494     }
2495     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2496 }
2497
2498
2499 impl RetType {
2500     pub fn type_ref(&self) -> Option<TypeRef> {
2501         super::child_opt(self)
2502     }
2503 }
2504
2505 // ReturnExpr
2506 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2507 pub struct ReturnExpr {
2508     pub(crate) syntax: SyntaxNode,
2509 }
2510
2511 impl AstNode for ReturnExpr {
2512     fn cast(syntax: SyntaxNode) -> Option<Self> {
2513         match syntax.kind() {
2514             RETURN_EXPR => Some(ReturnExpr { syntax }),
2515             _ => None,
2516         }
2517     }
2518     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2519 }
2520
2521
2522 impl ReturnExpr {
2523     pub fn expr(&self) -> Option<Expr> {
2524         super::child_opt(self)
2525     }
2526 }
2527
2528 // SelfParam
2529 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2530 pub struct SelfParam {
2531     pub(crate) syntax: SyntaxNode,
2532 }
2533
2534 impl AstNode for SelfParam {
2535     fn cast(syntax: SyntaxNode) -> Option<Self> {
2536         match syntax.kind() {
2537             SELF_PARAM => Some(SelfParam { syntax }),
2538             _ => None,
2539         }
2540     }
2541     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2542 }
2543
2544
2545 impl ast::TypeAscriptionOwner for SelfParam {}
2546 impl SelfParam {}
2547
2548 // SlicePat
2549 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2550 pub struct SlicePat {
2551     pub(crate) syntax: SyntaxNode,
2552 }
2553
2554 impl AstNode for SlicePat {
2555     fn cast(syntax: SyntaxNode) -> Option<Self> {
2556         match syntax.kind() {
2557             SLICE_PAT => Some(SlicePat { syntax }),
2558             _ => None,
2559         }
2560     }
2561     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2562 }
2563
2564
2565 impl SlicePat {}
2566
2567 // SliceType
2568 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2569 pub struct SliceType {
2570     pub(crate) syntax: SyntaxNode,
2571 }
2572
2573 impl AstNode for SliceType {
2574     fn cast(syntax: SyntaxNode) -> Option<Self> {
2575         match syntax.kind() {
2576             SLICE_TYPE => Some(SliceType { syntax }),
2577             _ => None,
2578         }
2579     }
2580     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2581 }
2582
2583
2584 impl SliceType {
2585     pub fn type_ref(&self) -> Option<TypeRef> {
2586         super::child_opt(self)
2587     }
2588 }
2589
2590 // SourceFile
2591 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2592 pub struct SourceFile {
2593     pub(crate) syntax: SyntaxNode,
2594 }
2595
2596 impl AstNode for SourceFile {
2597     fn cast(syntax: SyntaxNode) -> Option<Self> {
2598         match syntax.kind() {
2599             SOURCE_FILE => Some(SourceFile { syntax }),
2600             _ => None,
2601         }
2602     }
2603     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2604 }
2605
2606
2607 impl ast::ModuleItemOwner for SourceFile {}
2608 impl ast::FnDefOwner for SourceFile {}
2609 impl SourceFile {
2610     pub fn modules(&self) -> impl Iterator<Item = Module> {
2611         super::children(self)
2612     }
2613 }
2614
2615 // StaticDef
2616 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2617 pub struct StaticDef {
2618     pub(crate) syntax: SyntaxNode,
2619 }
2620
2621 impl AstNode for StaticDef {
2622     fn cast(syntax: SyntaxNode) -> Option<Self> {
2623         match syntax.kind() {
2624             STATIC_DEF => Some(StaticDef { syntax }),
2625             _ => None,
2626         }
2627     }
2628     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2629 }
2630
2631
2632 impl ast::VisibilityOwner for StaticDef {}
2633 impl ast::NameOwner for StaticDef {}
2634 impl ast::TypeParamsOwner for StaticDef {}
2635 impl ast::AttrsOwner for StaticDef {}
2636 impl ast::DocCommentsOwner for StaticDef {}
2637 impl ast::TypeAscriptionOwner for StaticDef {}
2638 impl StaticDef {
2639     pub fn body(&self) -> Option<Expr> {
2640         super::child_opt(self)
2641     }
2642 }
2643
2644 // Stmt
2645 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2646 pub struct Stmt {
2647     pub(crate) syntax: SyntaxNode,
2648 }
2649
2650 #[derive(Debug, Clone, PartialEq, Eq)]
2651 pub enum StmtKind {
2652     ExprStmt(ExprStmt),
2653     LetStmt(LetStmt),
2654 }
2655 impl From<ExprStmt> for Stmt {
2656     fn from(n: ExprStmt) -> Stmt {
2657         Stmt::cast(n.syntax).unwrap()
2658     }
2659 }
2660 impl From<LetStmt> for Stmt {
2661     fn from(n: LetStmt) -> Stmt {
2662         Stmt::cast(n.syntax).unwrap()
2663     }
2664 }
2665
2666
2667 impl AstNode for Stmt {
2668     fn cast(syntax: SyntaxNode) -> Option<Self> {
2669         match syntax.kind() {
2670             | EXPR_STMT
2671             | LET_STMT => Some(Stmt { syntax }),
2672             _ => None,
2673         }
2674     }
2675     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2676 }
2677
2678 impl Stmt {
2679     pub fn kind(&self) -> StmtKind {
2680         match self.syntax.kind() {
2681             EXPR_STMT => StmtKind::ExprStmt(ExprStmt::cast(self.syntax.clone()).unwrap()),
2682             LET_STMT => StmtKind::LetStmt(LetStmt::cast(self.syntax.clone()).unwrap()),
2683             _ => unreachable!(),
2684         }
2685     }
2686 }
2687
2688 impl Stmt {}
2689
2690 // StructDef
2691 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2692 pub struct StructDef {
2693     pub(crate) syntax: SyntaxNode,
2694 }
2695
2696 impl AstNode for StructDef {
2697     fn cast(syntax: SyntaxNode) -> Option<Self> {
2698         match syntax.kind() {
2699             STRUCT_DEF => Some(StructDef { syntax }),
2700             _ => None,
2701         }
2702     }
2703     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2704 }
2705
2706
2707 impl ast::VisibilityOwner for StructDef {}
2708 impl ast::NameOwner for StructDef {}
2709 impl ast::TypeParamsOwner for StructDef {}
2710 impl ast::AttrsOwner for StructDef {}
2711 impl ast::DocCommentsOwner for StructDef {}
2712 impl StructDef {}
2713
2714 // StructLit
2715 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2716 pub struct StructLit {
2717     pub(crate) syntax: SyntaxNode,
2718 }
2719
2720 impl AstNode for StructLit {
2721     fn cast(syntax: SyntaxNode) -> Option<Self> {
2722         match syntax.kind() {
2723             STRUCT_LIT => Some(StructLit { syntax }),
2724             _ => None,
2725         }
2726     }
2727     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2728 }
2729
2730
2731 impl StructLit {
2732     pub fn path(&self) -> Option<Path> {
2733         super::child_opt(self)
2734     }
2735
2736     pub fn named_field_list(&self) -> Option<NamedFieldList> {
2737         super::child_opt(self)
2738     }
2739 }
2740
2741 // StructPat
2742 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2743 pub struct StructPat {
2744     pub(crate) syntax: SyntaxNode,
2745 }
2746
2747 impl AstNode for StructPat {
2748     fn cast(syntax: SyntaxNode) -> Option<Self> {
2749         match syntax.kind() {
2750             STRUCT_PAT => Some(StructPat { syntax }),
2751             _ => None,
2752         }
2753     }
2754     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2755 }
2756
2757
2758 impl StructPat {
2759     pub fn field_pat_list(&self) -> Option<FieldPatList> {
2760         super::child_opt(self)
2761     }
2762
2763     pub fn path(&self) -> Option<Path> {
2764         super::child_opt(self)
2765     }
2766 }
2767
2768 // TokenTree
2769 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2770 pub struct TokenTree {
2771     pub(crate) syntax: SyntaxNode,
2772 }
2773
2774 impl AstNode for TokenTree {
2775     fn cast(syntax: SyntaxNode) -> Option<Self> {
2776         match syntax.kind() {
2777             TOKEN_TREE => Some(TokenTree { syntax }),
2778             _ => None,
2779         }
2780     }
2781     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2782 }
2783
2784
2785 impl TokenTree {}
2786
2787 // TraitDef
2788 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2789 pub struct TraitDef {
2790     pub(crate) syntax: SyntaxNode,
2791 }
2792
2793 impl AstNode for TraitDef {
2794     fn cast(syntax: SyntaxNode) -> Option<Self> {
2795         match syntax.kind() {
2796             TRAIT_DEF => Some(TraitDef { syntax }),
2797             _ => None,
2798         }
2799     }
2800     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2801 }
2802
2803
2804 impl ast::VisibilityOwner for TraitDef {}
2805 impl ast::NameOwner for TraitDef {}
2806 impl ast::AttrsOwner for TraitDef {}
2807 impl ast::DocCommentsOwner for TraitDef {}
2808 impl ast::TypeParamsOwner for TraitDef {}
2809 impl ast::TypeBoundsOwner for TraitDef {}
2810 impl TraitDef {
2811     pub fn item_list(&self) -> Option<ItemList> {
2812         super::child_opt(self)
2813     }
2814 }
2815
2816 // TryBlockExpr
2817 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2818 pub struct TryBlockExpr {
2819     pub(crate) syntax: SyntaxNode,
2820 }
2821
2822 impl AstNode for TryBlockExpr {
2823     fn cast(syntax: SyntaxNode) -> Option<Self> {
2824         match syntax.kind() {
2825             TRY_BLOCK_EXPR => Some(TryBlockExpr { syntax }),
2826             _ => None,
2827         }
2828     }
2829     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2830 }
2831
2832
2833 impl ast::TryBlockBodyOwner for TryBlockExpr {}
2834 impl TryBlockExpr {}
2835
2836 // TryExpr
2837 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2838 pub struct TryExpr {
2839     pub(crate) syntax: SyntaxNode,
2840 }
2841
2842 impl AstNode for TryExpr {
2843     fn cast(syntax: SyntaxNode) -> Option<Self> {
2844         match syntax.kind() {
2845             TRY_EXPR => Some(TryExpr { syntax }),
2846             _ => None,
2847         }
2848     }
2849     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2850 }
2851
2852
2853 impl TryExpr {
2854     pub fn expr(&self) -> Option<Expr> {
2855         super::child_opt(self)
2856     }
2857 }
2858
2859 // TupleExpr
2860 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2861 pub struct TupleExpr {
2862     pub(crate) syntax: SyntaxNode,
2863 }
2864
2865 impl AstNode for TupleExpr {
2866     fn cast(syntax: SyntaxNode) -> Option<Self> {
2867         match syntax.kind() {
2868             TUPLE_EXPR => Some(TupleExpr { syntax }),
2869             _ => None,
2870         }
2871     }
2872     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2873 }
2874
2875
2876 impl TupleExpr {
2877     pub fn exprs(&self) -> impl Iterator<Item = Expr> {
2878         super::children(self)
2879     }
2880 }
2881
2882 // TuplePat
2883 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2884 pub struct TuplePat {
2885     pub(crate) syntax: SyntaxNode,
2886 }
2887
2888 impl AstNode for TuplePat {
2889     fn cast(syntax: SyntaxNode) -> Option<Self> {
2890         match syntax.kind() {
2891             TUPLE_PAT => Some(TuplePat { syntax }),
2892             _ => None,
2893         }
2894     }
2895     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2896 }
2897
2898
2899 impl TuplePat {
2900     pub fn args(&self) -> impl Iterator<Item = Pat> {
2901         super::children(self)
2902     }
2903 }
2904
2905 // TupleStructPat
2906 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2907 pub struct TupleStructPat {
2908     pub(crate) syntax: SyntaxNode,
2909 }
2910
2911 impl AstNode for TupleStructPat {
2912     fn cast(syntax: SyntaxNode) -> Option<Self> {
2913         match syntax.kind() {
2914             TUPLE_STRUCT_PAT => Some(TupleStructPat { syntax }),
2915             _ => None,
2916         }
2917     }
2918     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2919 }
2920
2921
2922 impl TupleStructPat {
2923     pub fn args(&self) -> impl Iterator<Item = Pat> {
2924         super::children(self)
2925     }
2926
2927     pub fn path(&self) -> Option<Path> {
2928         super::child_opt(self)
2929     }
2930 }
2931
2932 // TupleType
2933 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2934 pub struct TupleType {
2935     pub(crate) syntax: SyntaxNode,
2936 }
2937
2938 impl AstNode for TupleType {
2939     fn cast(syntax: SyntaxNode) -> Option<Self> {
2940         match syntax.kind() {
2941             TUPLE_TYPE => Some(TupleType { syntax }),
2942             _ => None,
2943         }
2944     }
2945     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2946 }
2947
2948
2949 impl TupleType {
2950     pub fn fields(&self) -> impl Iterator<Item = TypeRef> {
2951         super::children(self)
2952     }
2953 }
2954
2955 // TypeAliasDef
2956 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2957 pub struct TypeAliasDef {
2958     pub(crate) syntax: SyntaxNode,
2959 }
2960
2961 impl AstNode for TypeAliasDef {
2962     fn cast(syntax: SyntaxNode) -> Option<Self> {
2963         match syntax.kind() {
2964             TYPE_ALIAS_DEF => Some(TypeAliasDef { syntax }),
2965             _ => None,
2966         }
2967     }
2968     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2969 }
2970
2971
2972 impl ast::VisibilityOwner for TypeAliasDef {}
2973 impl ast::NameOwner for TypeAliasDef {}
2974 impl ast::TypeParamsOwner for TypeAliasDef {}
2975 impl ast::AttrsOwner for TypeAliasDef {}
2976 impl ast::DocCommentsOwner for TypeAliasDef {}
2977 impl ast::TypeBoundsOwner for TypeAliasDef {}
2978 impl TypeAliasDef {
2979     pub fn type_ref(&self) -> Option<TypeRef> {
2980         super::child_opt(self)
2981     }
2982 }
2983
2984 // TypeArg
2985 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2986 pub struct TypeArg {
2987     pub(crate) syntax: SyntaxNode,
2988 }
2989
2990 impl AstNode for TypeArg {
2991     fn cast(syntax: SyntaxNode) -> Option<Self> {
2992         match syntax.kind() {
2993             TYPE_ARG => Some(TypeArg { syntax }),
2994             _ => None,
2995         }
2996     }
2997     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2998 }
2999
3000
3001 impl TypeArg {
3002     pub fn type_ref(&self) -> Option<TypeRef> {
3003         super::child_opt(self)
3004     }
3005 }
3006
3007 // TypeArgList
3008 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3009 pub struct TypeArgList {
3010     pub(crate) syntax: SyntaxNode,
3011 }
3012
3013 impl AstNode for TypeArgList {
3014     fn cast(syntax: SyntaxNode) -> Option<Self> {
3015         match syntax.kind() {
3016             TYPE_ARG_LIST => Some(TypeArgList { syntax }),
3017             _ => None,
3018         }
3019     }
3020     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3021 }
3022
3023
3024 impl TypeArgList {
3025     pub fn type_args(&self) -> impl Iterator<Item = TypeArg> {
3026         super::children(self)
3027     }
3028
3029     pub fn lifetime_args(&self) -> impl Iterator<Item = LifetimeArg> {
3030         super::children(self)
3031     }
3032
3033     pub fn assoc_type_args(&self) -> impl Iterator<Item = AssocTypeArg> {
3034         super::children(self)
3035     }
3036 }
3037
3038 // TypeBound
3039 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3040 pub struct TypeBound {
3041     pub(crate) syntax: SyntaxNode,
3042 }
3043
3044 impl AstNode for TypeBound {
3045     fn cast(syntax: SyntaxNode) -> Option<Self> {
3046         match syntax.kind() {
3047             TYPE_BOUND => Some(TypeBound { syntax }),
3048             _ => None,
3049         }
3050     }
3051     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3052 }
3053
3054
3055 impl TypeBound {
3056     pub fn type_ref(&self) -> Option<TypeRef> {
3057         super::child_opt(self)
3058     }
3059 }
3060
3061 // TypeBoundList
3062 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3063 pub struct TypeBoundList {
3064     pub(crate) syntax: SyntaxNode,
3065 }
3066
3067 impl AstNode for TypeBoundList {
3068     fn cast(syntax: SyntaxNode) -> Option<Self> {
3069         match syntax.kind() {
3070             TYPE_BOUND_LIST => Some(TypeBoundList { syntax }),
3071             _ => None,
3072         }
3073     }
3074     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3075 }
3076
3077
3078 impl TypeBoundList {
3079     pub fn bounds(&self) -> impl Iterator<Item = TypeBound> {
3080         super::children(self)
3081     }
3082 }
3083
3084 // TypeParam
3085 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3086 pub struct TypeParam {
3087     pub(crate) syntax: SyntaxNode,
3088 }
3089
3090 impl AstNode for TypeParam {
3091     fn cast(syntax: SyntaxNode) -> Option<Self> {
3092         match syntax.kind() {
3093             TYPE_PARAM => Some(TypeParam { syntax }),
3094             _ => None,
3095         }
3096     }
3097     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3098 }
3099
3100
3101 impl ast::NameOwner for TypeParam {}
3102 impl ast::AttrsOwner for TypeParam {}
3103 impl ast::TypeBoundsOwner for TypeParam {}
3104 impl ast::DefaultTypeParamOwner for TypeParam {}
3105 impl TypeParam {}
3106
3107 // TypeParamList
3108 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3109 pub struct TypeParamList {
3110     pub(crate) syntax: SyntaxNode,
3111 }
3112
3113 impl AstNode for TypeParamList {
3114     fn cast(syntax: SyntaxNode) -> Option<Self> {
3115         match syntax.kind() {
3116             TYPE_PARAM_LIST => Some(TypeParamList { syntax }),
3117             _ => None,
3118         }
3119     }
3120     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3121 }
3122
3123
3124 impl TypeParamList {
3125     pub fn type_params(&self) -> impl Iterator<Item = TypeParam> {
3126         super::children(self)
3127     }
3128
3129     pub fn lifetime_params(&self) -> impl Iterator<Item = LifetimeParam> {
3130         super::children(self)
3131     }
3132 }
3133
3134 // TypeRef
3135 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3136 pub struct TypeRef {
3137     pub(crate) syntax: SyntaxNode,
3138 }
3139
3140 #[derive(Debug, Clone, PartialEq, Eq)]
3141 pub enum TypeRefKind {
3142     ParenType(ParenType),
3143     TupleType(TupleType),
3144     NeverType(NeverType),
3145     PathType(PathType),
3146     PointerType(PointerType),
3147     ArrayType(ArrayType),
3148     SliceType(SliceType),
3149     ReferenceType(ReferenceType),
3150     PlaceholderType(PlaceholderType),
3151     FnPointerType(FnPointerType),
3152     ForType(ForType),
3153     ImplTraitType(ImplTraitType),
3154     DynTraitType(DynTraitType),
3155 }
3156 impl From<ParenType> for TypeRef {
3157     fn from(n: ParenType) -> TypeRef {
3158         TypeRef::cast(n.syntax).unwrap()
3159     }
3160 }
3161 impl From<TupleType> for TypeRef {
3162     fn from(n: TupleType) -> TypeRef {
3163         TypeRef::cast(n.syntax).unwrap()
3164     }
3165 }
3166 impl From<NeverType> for TypeRef {
3167     fn from(n: NeverType) -> TypeRef {
3168         TypeRef::cast(n.syntax).unwrap()
3169     }
3170 }
3171 impl From<PathType> for TypeRef {
3172     fn from(n: PathType) -> TypeRef {
3173         TypeRef::cast(n.syntax).unwrap()
3174     }
3175 }
3176 impl From<PointerType> for TypeRef {
3177     fn from(n: PointerType) -> TypeRef {
3178         TypeRef::cast(n.syntax).unwrap()
3179     }
3180 }
3181 impl From<ArrayType> for TypeRef {
3182     fn from(n: ArrayType) -> TypeRef {
3183         TypeRef::cast(n.syntax).unwrap()
3184     }
3185 }
3186 impl From<SliceType> for TypeRef {
3187     fn from(n: SliceType) -> TypeRef {
3188         TypeRef::cast(n.syntax).unwrap()
3189     }
3190 }
3191 impl From<ReferenceType> for TypeRef {
3192     fn from(n: ReferenceType) -> TypeRef {
3193         TypeRef::cast(n.syntax).unwrap()
3194     }
3195 }
3196 impl From<PlaceholderType> for TypeRef {
3197     fn from(n: PlaceholderType) -> TypeRef {
3198         TypeRef::cast(n.syntax).unwrap()
3199     }
3200 }
3201 impl From<FnPointerType> for TypeRef {
3202     fn from(n: FnPointerType) -> TypeRef {
3203         TypeRef::cast(n.syntax).unwrap()
3204     }
3205 }
3206 impl From<ForType> for TypeRef {
3207     fn from(n: ForType) -> TypeRef {
3208         TypeRef::cast(n.syntax).unwrap()
3209     }
3210 }
3211 impl From<ImplTraitType> for TypeRef {
3212     fn from(n: ImplTraitType) -> TypeRef {
3213         TypeRef::cast(n.syntax).unwrap()
3214     }
3215 }
3216 impl From<DynTraitType> for TypeRef {
3217     fn from(n: DynTraitType) -> TypeRef {
3218         TypeRef::cast(n.syntax).unwrap()
3219     }
3220 }
3221
3222
3223 impl AstNode for TypeRef {
3224     fn cast(syntax: SyntaxNode) -> Option<Self> {
3225         match syntax.kind() {
3226             | PAREN_TYPE
3227             | TUPLE_TYPE
3228             | NEVER_TYPE
3229             | PATH_TYPE
3230             | POINTER_TYPE
3231             | ARRAY_TYPE
3232             | SLICE_TYPE
3233             | REFERENCE_TYPE
3234             | PLACEHOLDER_TYPE
3235             | FN_POINTER_TYPE
3236             | FOR_TYPE
3237             | IMPL_TRAIT_TYPE
3238             | DYN_TRAIT_TYPE => Some(TypeRef { syntax }),
3239             _ => None,
3240         }
3241     }
3242     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3243 }
3244
3245 impl TypeRef {
3246     pub fn kind(&self) -> TypeRefKind {
3247         match self.syntax.kind() {
3248             PAREN_TYPE => TypeRefKind::ParenType(ParenType::cast(self.syntax.clone()).unwrap()),
3249             TUPLE_TYPE => TypeRefKind::TupleType(TupleType::cast(self.syntax.clone()).unwrap()),
3250             NEVER_TYPE => TypeRefKind::NeverType(NeverType::cast(self.syntax.clone()).unwrap()),
3251             PATH_TYPE => TypeRefKind::PathType(PathType::cast(self.syntax.clone()).unwrap()),
3252             POINTER_TYPE => TypeRefKind::PointerType(PointerType::cast(self.syntax.clone()).unwrap()),
3253             ARRAY_TYPE => TypeRefKind::ArrayType(ArrayType::cast(self.syntax.clone()).unwrap()),
3254             SLICE_TYPE => TypeRefKind::SliceType(SliceType::cast(self.syntax.clone()).unwrap()),
3255             REFERENCE_TYPE => TypeRefKind::ReferenceType(ReferenceType::cast(self.syntax.clone()).unwrap()),
3256             PLACEHOLDER_TYPE => TypeRefKind::PlaceholderType(PlaceholderType::cast(self.syntax.clone()).unwrap()),
3257             FN_POINTER_TYPE => TypeRefKind::FnPointerType(FnPointerType::cast(self.syntax.clone()).unwrap()),
3258             FOR_TYPE => TypeRefKind::ForType(ForType::cast(self.syntax.clone()).unwrap()),
3259             IMPL_TRAIT_TYPE => TypeRefKind::ImplTraitType(ImplTraitType::cast(self.syntax.clone()).unwrap()),
3260             DYN_TRAIT_TYPE => TypeRefKind::DynTraitType(DynTraitType::cast(self.syntax.clone()).unwrap()),
3261             _ => unreachable!(),
3262         }
3263     }
3264 }
3265
3266 impl TypeRef {}
3267
3268 // UseItem
3269 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3270 pub struct UseItem {
3271     pub(crate) syntax: SyntaxNode,
3272 }
3273
3274 impl AstNode for UseItem {
3275     fn cast(syntax: SyntaxNode) -> Option<Self> {
3276         match syntax.kind() {
3277             USE_ITEM => Some(UseItem { syntax }),
3278             _ => None,
3279         }
3280     }
3281     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3282 }
3283
3284
3285 impl ast::AttrsOwner for UseItem {}
3286 impl UseItem {
3287     pub fn use_tree(&self) -> Option<UseTree> {
3288         super::child_opt(self)
3289     }
3290 }
3291
3292 // UseTree
3293 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3294 pub struct UseTree {
3295     pub(crate) syntax: SyntaxNode,
3296 }
3297
3298 impl AstNode for UseTree {
3299     fn cast(syntax: SyntaxNode) -> Option<Self> {
3300         match syntax.kind() {
3301             USE_TREE => Some(UseTree { syntax }),
3302             _ => None,
3303         }
3304     }
3305     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3306 }
3307
3308
3309 impl UseTree {
3310     pub fn path(&self) -> Option<Path> {
3311         super::child_opt(self)
3312     }
3313
3314     pub fn use_tree_list(&self) -> Option<UseTreeList> {
3315         super::child_opt(self)
3316     }
3317
3318     pub fn alias(&self) -> Option<Alias> {
3319         super::child_opt(self)
3320     }
3321 }
3322
3323 // UseTreeList
3324 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3325 pub struct UseTreeList {
3326     pub(crate) syntax: SyntaxNode,
3327 }
3328
3329 impl AstNode for UseTreeList {
3330     fn cast(syntax: SyntaxNode) -> Option<Self> {
3331         match syntax.kind() {
3332             USE_TREE_LIST => Some(UseTreeList { syntax }),
3333             _ => None,
3334         }
3335     }
3336     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3337 }
3338
3339
3340 impl UseTreeList {
3341     pub fn use_trees(&self) -> impl Iterator<Item = UseTree> {
3342         super::children(self)
3343     }
3344 }
3345
3346 // Visibility
3347 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3348 pub struct Visibility {
3349     pub(crate) syntax: SyntaxNode,
3350 }
3351
3352 impl AstNode for Visibility {
3353     fn cast(syntax: SyntaxNode) -> Option<Self> {
3354         match syntax.kind() {
3355             VISIBILITY => Some(Visibility { syntax }),
3356             _ => None,
3357         }
3358     }
3359     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3360 }
3361
3362
3363 impl Visibility {}
3364
3365 // WhereClause
3366 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3367 pub struct WhereClause {
3368     pub(crate) syntax: SyntaxNode,
3369 }
3370
3371 impl AstNode for WhereClause {
3372     fn cast(syntax: SyntaxNode) -> Option<Self> {
3373         match syntax.kind() {
3374             WHERE_CLAUSE => Some(WhereClause { syntax }),
3375             _ => None,
3376         }
3377     }
3378     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3379 }
3380
3381
3382 impl WhereClause {
3383     pub fn predicates(&self) -> impl Iterator<Item = WherePred> {
3384         super::children(self)
3385     }
3386 }
3387
3388 // WherePred
3389 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3390 pub struct WherePred {
3391     pub(crate) syntax: SyntaxNode,
3392 }
3393
3394 impl AstNode for WherePred {
3395     fn cast(syntax: SyntaxNode) -> Option<Self> {
3396         match syntax.kind() {
3397             WHERE_PRED => Some(WherePred { syntax }),
3398             _ => None,
3399         }
3400     }
3401     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3402 }
3403
3404
3405 impl ast::TypeBoundsOwner for WherePred {}
3406 impl WherePred {
3407     pub fn type_ref(&self) -> Option<TypeRef> {
3408         super::child_opt(self)
3409     }
3410 }
3411
3412 // WhileExpr
3413 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3414 pub struct WhileExpr {
3415     pub(crate) syntax: SyntaxNode,
3416 }
3417
3418 impl AstNode for WhileExpr {
3419     fn cast(syntax: SyntaxNode) -> Option<Self> {
3420         match syntax.kind() {
3421             WHILE_EXPR => Some(WhileExpr { syntax }),
3422             _ => None,
3423         }
3424     }
3425     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3426 }
3427
3428
3429 impl ast::LoopBodyOwner for WhileExpr {}
3430 impl WhileExpr {
3431     pub fn condition(&self) -> Option<Condition> {
3432         super::child_opt(self)
3433     }
3434 }
3435