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