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