]> git.lizzy.rs Git - rust.git/blob - crates/ra_syntax/src/ast/generated.rs
Merge #1761
[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 }
2316 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2317 pub struct PathType {
2318     pub(crate) syntax: SyntaxNode,
2319 }
2320 impl AstNode for PathType {
2321     fn can_cast(kind: SyntaxKind) -> bool {
2322         match kind {
2323             PATH_TYPE => true,
2324             _ => false,
2325         }
2326     }
2327     fn cast(syntax: SyntaxNode) -> Option<Self> {
2328         if Self::can_cast(syntax.kind()) {
2329             Some(Self { syntax })
2330         } else {
2331             None
2332         }
2333     }
2334     fn syntax(&self) -> &SyntaxNode {
2335         &self.syntax
2336     }
2337 }
2338 impl PathType {
2339     pub fn path(&self) -> Option<Path> {
2340         AstChildren::new(&self.syntax).next()
2341     }
2342 }
2343 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2344 pub struct PlaceholderPat {
2345     pub(crate) syntax: SyntaxNode,
2346 }
2347 impl AstNode for PlaceholderPat {
2348     fn can_cast(kind: SyntaxKind) -> bool {
2349         match kind {
2350             PLACEHOLDER_PAT => true,
2351             _ => false,
2352         }
2353     }
2354     fn cast(syntax: SyntaxNode) -> Option<Self> {
2355         if Self::can_cast(syntax.kind()) {
2356             Some(Self { syntax })
2357         } else {
2358             None
2359         }
2360     }
2361     fn syntax(&self) -> &SyntaxNode {
2362         &self.syntax
2363     }
2364 }
2365 impl PlaceholderPat {}
2366 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2367 pub struct PlaceholderType {
2368     pub(crate) syntax: SyntaxNode,
2369 }
2370 impl AstNode for PlaceholderType {
2371     fn can_cast(kind: SyntaxKind) -> bool {
2372         match kind {
2373             PLACEHOLDER_TYPE => true,
2374             _ => false,
2375         }
2376     }
2377     fn cast(syntax: SyntaxNode) -> Option<Self> {
2378         if Self::can_cast(syntax.kind()) {
2379             Some(Self { syntax })
2380         } else {
2381             None
2382         }
2383     }
2384     fn syntax(&self) -> &SyntaxNode {
2385         &self.syntax
2386     }
2387 }
2388 impl PlaceholderType {}
2389 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2390 pub struct PointerType {
2391     pub(crate) syntax: SyntaxNode,
2392 }
2393 impl AstNode for PointerType {
2394     fn can_cast(kind: SyntaxKind) -> bool {
2395         match kind {
2396             POINTER_TYPE => true,
2397             _ => false,
2398         }
2399     }
2400     fn cast(syntax: SyntaxNode) -> Option<Self> {
2401         if Self::can_cast(syntax.kind()) {
2402             Some(Self { syntax })
2403         } else {
2404             None
2405         }
2406     }
2407     fn syntax(&self) -> &SyntaxNode {
2408         &self.syntax
2409     }
2410 }
2411 impl PointerType {
2412     pub fn type_ref(&self) -> Option<TypeRef> {
2413         AstChildren::new(&self.syntax).next()
2414     }
2415 }
2416 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2417 pub struct PrefixExpr {
2418     pub(crate) syntax: SyntaxNode,
2419 }
2420 impl AstNode for PrefixExpr {
2421     fn can_cast(kind: SyntaxKind) -> bool {
2422         match kind {
2423             PREFIX_EXPR => true,
2424             _ => false,
2425         }
2426     }
2427     fn cast(syntax: SyntaxNode) -> Option<Self> {
2428         if Self::can_cast(syntax.kind()) {
2429             Some(Self { syntax })
2430         } else {
2431             None
2432         }
2433     }
2434     fn syntax(&self) -> &SyntaxNode {
2435         &self.syntax
2436     }
2437 }
2438 impl PrefixExpr {
2439     pub fn expr(&self) -> Option<Expr> {
2440         AstChildren::new(&self.syntax).next()
2441     }
2442 }
2443 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2444 pub struct RangeExpr {
2445     pub(crate) syntax: SyntaxNode,
2446 }
2447 impl AstNode for RangeExpr {
2448     fn can_cast(kind: SyntaxKind) -> bool {
2449         match kind {
2450             RANGE_EXPR => true,
2451             _ => false,
2452         }
2453     }
2454     fn cast(syntax: SyntaxNode) -> Option<Self> {
2455         if Self::can_cast(syntax.kind()) {
2456             Some(Self { syntax })
2457         } else {
2458             None
2459         }
2460     }
2461     fn syntax(&self) -> &SyntaxNode {
2462         &self.syntax
2463     }
2464 }
2465 impl RangeExpr {}
2466 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2467 pub struct RangePat {
2468     pub(crate) syntax: SyntaxNode,
2469 }
2470 impl AstNode for RangePat {
2471     fn can_cast(kind: SyntaxKind) -> bool {
2472         match kind {
2473             RANGE_PAT => true,
2474             _ => false,
2475         }
2476     }
2477     fn cast(syntax: SyntaxNode) -> Option<Self> {
2478         if Self::can_cast(syntax.kind()) {
2479             Some(Self { syntax })
2480         } else {
2481             None
2482         }
2483     }
2484     fn syntax(&self) -> &SyntaxNode {
2485         &self.syntax
2486     }
2487 }
2488 impl RangePat {}
2489 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2490 pub struct RecordField {
2491     pub(crate) syntax: SyntaxNode,
2492 }
2493 impl AstNode for RecordField {
2494     fn can_cast(kind: SyntaxKind) -> bool {
2495         match kind {
2496             RECORD_FIELD => true,
2497             _ => false,
2498         }
2499     }
2500     fn cast(syntax: SyntaxNode) -> Option<Self> {
2501         if Self::can_cast(syntax.kind()) {
2502             Some(Self { syntax })
2503         } else {
2504             None
2505         }
2506     }
2507     fn syntax(&self) -> &SyntaxNode {
2508         &self.syntax
2509     }
2510 }
2511 impl RecordField {
2512     pub fn name_ref(&self) -> Option<NameRef> {
2513         AstChildren::new(&self.syntax).next()
2514     }
2515     pub fn expr(&self) -> Option<Expr> {
2516         AstChildren::new(&self.syntax).next()
2517     }
2518 }
2519 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2520 pub struct RecordFieldDef {
2521     pub(crate) syntax: SyntaxNode,
2522 }
2523 impl AstNode for RecordFieldDef {
2524     fn can_cast(kind: SyntaxKind) -> bool {
2525         match kind {
2526             RECORD_FIELD_DEF => true,
2527             _ => false,
2528         }
2529     }
2530     fn cast(syntax: SyntaxNode) -> Option<Self> {
2531         if Self::can_cast(syntax.kind()) {
2532             Some(Self { syntax })
2533         } else {
2534             None
2535         }
2536     }
2537     fn syntax(&self) -> &SyntaxNode {
2538         &self.syntax
2539     }
2540 }
2541 impl ast::VisibilityOwner for RecordFieldDef {}
2542 impl ast::NameOwner for RecordFieldDef {}
2543 impl ast::AttrsOwner for RecordFieldDef {}
2544 impl ast::DocCommentsOwner for RecordFieldDef {}
2545 impl ast::TypeAscriptionOwner for RecordFieldDef {}
2546 impl RecordFieldDef {}
2547 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2548 pub struct RecordFieldDefList {
2549     pub(crate) syntax: SyntaxNode,
2550 }
2551 impl AstNode for RecordFieldDefList {
2552     fn can_cast(kind: SyntaxKind) -> bool {
2553         match kind {
2554             RECORD_FIELD_DEF_LIST => true,
2555             _ => false,
2556         }
2557     }
2558     fn cast(syntax: SyntaxNode) -> Option<Self> {
2559         if Self::can_cast(syntax.kind()) {
2560             Some(Self { syntax })
2561         } else {
2562             None
2563         }
2564     }
2565     fn syntax(&self) -> &SyntaxNode {
2566         &self.syntax
2567     }
2568 }
2569 impl RecordFieldDefList {
2570     pub fn fields(&self) -> AstChildren<RecordFieldDef> {
2571         AstChildren::new(&self.syntax)
2572     }
2573 }
2574 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2575 pub struct RecordFieldList {
2576     pub(crate) syntax: SyntaxNode,
2577 }
2578 impl AstNode for RecordFieldList {
2579     fn can_cast(kind: SyntaxKind) -> bool {
2580         match kind {
2581             RECORD_FIELD_LIST => true,
2582             _ => false,
2583         }
2584     }
2585     fn cast(syntax: SyntaxNode) -> Option<Self> {
2586         if Self::can_cast(syntax.kind()) {
2587             Some(Self { syntax })
2588         } else {
2589             None
2590         }
2591     }
2592     fn syntax(&self) -> &SyntaxNode {
2593         &self.syntax
2594     }
2595 }
2596 impl RecordFieldList {
2597     pub fn fields(&self) -> AstChildren<RecordField> {
2598         AstChildren::new(&self.syntax)
2599     }
2600     pub fn spread(&self) -> Option<Expr> {
2601         AstChildren::new(&self.syntax).next()
2602     }
2603 }
2604 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2605 pub struct RecordFieldPat {
2606     pub(crate) syntax: SyntaxNode,
2607 }
2608 impl AstNode for RecordFieldPat {
2609     fn can_cast(kind: SyntaxKind) -> bool {
2610         match kind {
2611             RECORD_FIELD_PAT => true,
2612             _ => false,
2613         }
2614     }
2615     fn cast(syntax: SyntaxNode) -> Option<Self> {
2616         if Self::can_cast(syntax.kind()) {
2617             Some(Self { syntax })
2618         } else {
2619             None
2620         }
2621     }
2622     fn syntax(&self) -> &SyntaxNode {
2623         &self.syntax
2624     }
2625 }
2626 impl ast::NameOwner for RecordFieldPat {}
2627 impl RecordFieldPat {
2628     pub fn pat(&self) -> Option<Pat> {
2629         AstChildren::new(&self.syntax).next()
2630     }
2631 }
2632 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2633 pub struct RecordFieldPatList {
2634     pub(crate) syntax: SyntaxNode,
2635 }
2636 impl AstNode for RecordFieldPatList {
2637     fn can_cast(kind: SyntaxKind) -> bool {
2638         match kind {
2639             RECORD_FIELD_PAT_LIST => true,
2640             _ => false,
2641         }
2642     }
2643     fn cast(syntax: SyntaxNode) -> Option<Self> {
2644         if Self::can_cast(syntax.kind()) {
2645             Some(Self { syntax })
2646         } else {
2647             None
2648         }
2649     }
2650     fn syntax(&self) -> &SyntaxNode {
2651         &self.syntax
2652     }
2653 }
2654 impl RecordFieldPatList {
2655     pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> {
2656         AstChildren::new(&self.syntax)
2657     }
2658     pub fn bind_pats(&self) -> AstChildren<BindPat> {
2659         AstChildren::new(&self.syntax)
2660     }
2661 }
2662 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2663 pub struct RecordLit {
2664     pub(crate) syntax: SyntaxNode,
2665 }
2666 impl AstNode for RecordLit {
2667     fn can_cast(kind: SyntaxKind) -> bool {
2668         match kind {
2669             RECORD_LIT => true,
2670             _ => false,
2671         }
2672     }
2673     fn cast(syntax: SyntaxNode) -> Option<Self> {
2674         if Self::can_cast(syntax.kind()) {
2675             Some(Self { syntax })
2676         } else {
2677             None
2678         }
2679     }
2680     fn syntax(&self) -> &SyntaxNode {
2681         &self.syntax
2682     }
2683 }
2684 impl RecordLit {
2685     pub fn path(&self) -> Option<Path> {
2686         AstChildren::new(&self.syntax).next()
2687     }
2688     pub fn record_field_list(&self) -> Option<RecordFieldList> {
2689         AstChildren::new(&self.syntax).next()
2690     }
2691 }
2692 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2693 pub struct RecordPat {
2694     pub(crate) syntax: SyntaxNode,
2695 }
2696 impl AstNode for RecordPat {
2697     fn can_cast(kind: SyntaxKind) -> bool {
2698         match kind {
2699             RECORD_PAT => true,
2700             _ => false,
2701         }
2702     }
2703     fn cast(syntax: SyntaxNode) -> Option<Self> {
2704         if Self::can_cast(syntax.kind()) {
2705             Some(Self { syntax })
2706         } else {
2707             None
2708         }
2709     }
2710     fn syntax(&self) -> &SyntaxNode {
2711         &self.syntax
2712     }
2713 }
2714 impl RecordPat {
2715     pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> {
2716         AstChildren::new(&self.syntax).next()
2717     }
2718     pub fn path(&self) -> Option<Path> {
2719         AstChildren::new(&self.syntax).next()
2720     }
2721 }
2722 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2723 pub struct RefExpr {
2724     pub(crate) syntax: SyntaxNode,
2725 }
2726 impl AstNode for RefExpr {
2727     fn can_cast(kind: SyntaxKind) -> bool {
2728         match kind {
2729             REF_EXPR => true,
2730             _ => false,
2731         }
2732     }
2733     fn cast(syntax: SyntaxNode) -> Option<Self> {
2734         if Self::can_cast(syntax.kind()) {
2735             Some(Self { syntax })
2736         } else {
2737             None
2738         }
2739     }
2740     fn syntax(&self) -> &SyntaxNode {
2741         &self.syntax
2742     }
2743 }
2744 impl RefExpr {
2745     pub fn expr(&self) -> Option<Expr> {
2746         AstChildren::new(&self.syntax).next()
2747     }
2748 }
2749 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2750 pub struct RefPat {
2751     pub(crate) syntax: SyntaxNode,
2752 }
2753 impl AstNode for RefPat {
2754     fn can_cast(kind: SyntaxKind) -> bool {
2755         match kind {
2756             REF_PAT => true,
2757             _ => false,
2758         }
2759     }
2760     fn cast(syntax: SyntaxNode) -> Option<Self> {
2761         if Self::can_cast(syntax.kind()) {
2762             Some(Self { syntax })
2763         } else {
2764             None
2765         }
2766     }
2767     fn syntax(&self) -> &SyntaxNode {
2768         &self.syntax
2769     }
2770 }
2771 impl RefPat {
2772     pub fn pat(&self) -> Option<Pat> {
2773         AstChildren::new(&self.syntax).next()
2774     }
2775 }
2776 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2777 pub struct ReferenceType {
2778     pub(crate) syntax: SyntaxNode,
2779 }
2780 impl AstNode for ReferenceType {
2781     fn can_cast(kind: SyntaxKind) -> bool {
2782         match kind {
2783             REFERENCE_TYPE => true,
2784             _ => false,
2785         }
2786     }
2787     fn cast(syntax: SyntaxNode) -> Option<Self> {
2788         if Self::can_cast(syntax.kind()) {
2789             Some(Self { syntax })
2790         } else {
2791             None
2792         }
2793     }
2794     fn syntax(&self) -> &SyntaxNode {
2795         &self.syntax
2796     }
2797 }
2798 impl ReferenceType {
2799     pub fn type_ref(&self) -> Option<TypeRef> {
2800         AstChildren::new(&self.syntax).next()
2801     }
2802 }
2803 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2804 pub struct RetType {
2805     pub(crate) syntax: SyntaxNode,
2806 }
2807 impl AstNode for RetType {
2808     fn can_cast(kind: SyntaxKind) -> bool {
2809         match kind {
2810             RET_TYPE => true,
2811             _ => false,
2812         }
2813     }
2814     fn cast(syntax: SyntaxNode) -> Option<Self> {
2815         if Self::can_cast(syntax.kind()) {
2816             Some(Self { syntax })
2817         } else {
2818             None
2819         }
2820     }
2821     fn syntax(&self) -> &SyntaxNode {
2822         &self.syntax
2823     }
2824 }
2825 impl RetType {
2826     pub fn type_ref(&self) -> Option<TypeRef> {
2827         AstChildren::new(&self.syntax).next()
2828     }
2829 }
2830 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2831 pub struct ReturnExpr {
2832     pub(crate) syntax: SyntaxNode,
2833 }
2834 impl AstNode for ReturnExpr {
2835     fn can_cast(kind: SyntaxKind) -> bool {
2836         match kind {
2837             RETURN_EXPR => true,
2838             _ => false,
2839         }
2840     }
2841     fn cast(syntax: SyntaxNode) -> Option<Self> {
2842         if Self::can_cast(syntax.kind()) {
2843             Some(Self { syntax })
2844         } else {
2845             None
2846         }
2847     }
2848     fn syntax(&self) -> &SyntaxNode {
2849         &self.syntax
2850     }
2851 }
2852 impl ReturnExpr {
2853     pub fn expr(&self) -> Option<Expr> {
2854         AstChildren::new(&self.syntax).next()
2855     }
2856 }
2857 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2858 pub struct SelfParam {
2859     pub(crate) syntax: SyntaxNode,
2860 }
2861 impl AstNode for SelfParam {
2862     fn can_cast(kind: SyntaxKind) -> bool {
2863         match kind {
2864             SELF_PARAM => true,
2865             _ => false,
2866         }
2867     }
2868     fn cast(syntax: SyntaxNode) -> Option<Self> {
2869         if Self::can_cast(syntax.kind()) {
2870             Some(Self { syntax })
2871         } else {
2872             None
2873         }
2874     }
2875     fn syntax(&self) -> &SyntaxNode {
2876         &self.syntax
2877     }
2878 }
2879 impl ast::TypeAscriptionOwner for SelfParam {}
2880 impl ast::AttrsOwner for SelfParam {}
2881 impl SelfParam {}
2882 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2883 pub struct SlicePat {
2884     pub(crate) syntax: SyntaxNode,
2885 }
2886 impl AstNode for SlicePat {
2887     fn can_cast(kind: SyntaxKind) -> bool {
2888         match kind {
2889             SLICE_PAT => true,
2890             _ => false,
2891         }
2892     }
2893     fn cast(syntax: SyntaxNode) -> Option<Self> {
2894         if Self::can_cast(syntax.kind()) {
2895             Some(Self { syntax })
2896         } else {
2897             None
2898         }
2899     }
2900     fn syntax(&self) -> &SyntaxNode {
2901         &self.syntax
2902     }
2903 }
2904 impl SlicePat {}
2905 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2906 pub struct SliceType {
2907     pub(crate) syntax: SyntaxNode,
2908 }
2909 impl AstNode for SliceType {
2910     fn can_cast(kind: SyntaxKind) -> bool {
2911         match kind {
2912             SLICE_TYPE => true,
2913             _ => false,
2914         }
2915     }
2916     fn cast(syntax: SyntaxNode) -> Option<Self> {
2917         if Self::can_cast(syntax.kind()) {
2918             Some(Self { syntax })
2919         } else {
2920             None
2921         }
2922     }
2923     fn syntax(&self) -> &SyntaxNode {
2924         &self.syntax
2925     }
2926 }
2927 impl SliceType {
2928     pub fn type_ref(&self) -> Option<TypeRef> {
2929         AstChildren::new(&self.syntax).next()
2930     }
2931 }
2932 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2933 pub struct SourceFile {
2934     pub(crate) syntax: SyntaxNode,
2935 }
2936 impl AstNode for SourceFile {
2937     fn can_cast(kind: SyntaxKind) -> bool {
2938         match kind {
2939             SOURCE_FILE => true,
2940             _ => false,
2941         }
2942     }
2943     fn cast(syntax: SyntaxNode) -> Option<Self> {
2944         if Self::can_cast(syntax.kind()) {
2945             Some(Self { syntax })
2946         } else {
2947             None
2948         }
2949     }
2950     fn syntax(&self) -> &SyntaxNode {
2951         &self.syntax
2952     }
2953 }
2954 impl ast::ModuleItemOwner for SourceFile {}
2955 impl ast::FnDefOwner for SourceFile {}
2956 impl SourceFile {
2957     pub fn modules(&self) -> AstChildren<Module> {
2958         AstChildren::new(&self.syntax)
2959     }
2960 }
2961 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2962 pub struct StaticDef {
2963     pub(crate) syntax: SyntaxNode,
2964 }
2965 impl AstNode for StaticDef {
2966     fn can_cast(kind: SyntaxKind) -> bool {
2967         match kind {
2968             STATIC_DEF => true,
2969             _ => false,
2970         }
2971     }
2972     fn cast(syntax: SyntaxNode) -> Option<Self> {
2973         if Self::can_cast(syntax.kind()) {
2974             Some(Self { syntax })
2975         } else {
2976             None
2977         }
2978     }
2979     fn syntax(&self) -> &SyntaxNode {
2980         &self.syntax
2981     }
2982 }
2983 impl ast::VisibilityOwner for StaticDef {}
2984 impl ast::NameOwner for StaticDef {}
2985 impl ast::TypeParamsOwner for StaticDef {}
2986 impl ast::AttrsOwner for StaticDef {}
2987 impl ast::DocCommentsOwner for StaticDef {}
2988 impl ast::TypeAscriptionOwner for StaticDef {}
2989 impl StaticDef {
2990     pub fn body(&self) -> Option<Expr> {
2991         AstChildren::new(&self.syntax).next()
2992     }
2993 }
2994 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2995 pub enum Stmt {
2996     ExprStmt(ExprStmt),
2997     LetStmt(LetStmt),
2998 }
2999 impl From<ExprStmt> for Stmt {
3000     fn from(node: ExprStmt) -> Stmt {
3001         Stmt::ExprStmt(node)
3002     }
3003 }
3004 impl From<LetStmt> for Stmt {
3005     fn from(node: LetStmt) -> Stmt {
3006         Stmt::LetStmt(node)
3007     }
3008 }
3009 impl AstNode for Stmt {
3010     fn can_cast(kind: SyntaxKind) -> bool {
3011         match kind {
3012             EXPR_STMT | LET_STMT => true,
3013             _ => false,
3014         }
3015     }
3016     fn cast(syntax: SyntaxNode) -> Option<Self> {
3017         let res = match syntax.kind() {
3018             EXPR_STMT => Stmt::ExprStmt(ExprStmt { syntax }),
3019             LET_STMT => Stmt::LetStmt(LetStmt { syntax }),
3020             _ => return None,
3021         };
3022         Some(res)
3023     }
3024     fn syntax(&self) -> &SyntaxNode {
3025         match self {
3026             Stmt::ExprStmt(it) => &it.syntax,
3027             Stmt::LetStmt(it) => &it.syntax,
3028         }
3029     }
3030 }
3031 impl Stmt {}
3032 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3033 pub struct StructDef {
3034     pub(crate) syntax: SyntaxNode,
3035 }
3036 impl AstNode for StructDef {
3037     fn can_cast(kind: SyntaxKind) -> bool {
3038         match kind {
3039             STRUCT_DEF => true,
3040             _ => false,
3041         }
3042     }
3043     fn cast(syntax: SyntaxNode) -> Option<Self> {
3044         if Self::can_cast(syntax.kind()) {
3045             Some(Self { syntax })
3046         } else {
3047             None
3048         }
3049     }
3050     fn syntax(&self) -> &SyntaxNode {
3051         &self.syntax
3052     }
3053 }
3054 impl ast::VisibilityOwner for StructDef {}
3055 impl ast::NameOwner for StructDef {}
3056 impl ast::TypeParamsOwner for StructDef {}
3057 impl ast::AttrsOwner for StructDef {}
3058 impl ast::DocCommentsOwner for StructDef {}
3059 impl StructDef {}
3060 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3061 pub struct TokenTree {
3062     pub(crate) syntax: SyntaxNode,
3063 }
3064 impl AstNode for TokenTree {
3065     fn can_cast(kind: SyntaxKind) -> bool {
3066         match kind {
3067             TOKEN_TREE => true,
3068             _ => false,
3069         }
3070     }
3071     fn cast(syntax: SyntaxNode) -> Option<Self> {
3072         if Self::can_cast(syntax.kind()) {
3073             Some(Self { syntax })
3074         } else {
3075             None
3076         }
3077     }
3078     fn syntax(&self) -> &SyntaxNode {
3079         &self.syntax
3080     }
3081 }
3082 impl TokenTree {}
3083 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3084 pub struct TraitDef {
3085     pub(crate) syntax: SyntaxNode,
3086 }
3087 impl AstNode for TraitDef {
3088     fn can_cast(kind: SyntaxKind) -> bool {
3089         match kind {
3090             TRAIT_DEF => true,
3091             _ => false,
3092         }
3093     }
3094     fn cast(syntax: SyntaxNode) -> Option<Self> {
3095         if Self::can_cast(syntax.kind()) {
3096             Some(Self { syntax })
3097         } else {
3098             None
3099         }
3100     }
3101     fn syntax(&self) -> &SyntaxNode {
3102         &self.syntax
3103     }
3104 }
3105 impl ast::VisibilityOwner for TraitDef {}
3106 impl ast::NameOwner for TraitDef {}
3107 impl ast::AttrsOwner for TraitDef {}
3108 impl ast::DocCommentsOwner for TraitDef {}
3109 impl ast::TypeParamsOwner for TraitDef {}
3110 impl ast::TypeBoundsOwner for TraitDef {}
3111 impl TraitDef {
3112     pub fn item_list(&self) -> Option<ItemList> {
3113         AstChildren::new(&self.syntax).next()
3114     }
3115 }
3116 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3117 pub struct TryBlockExpr {
3118     pub(crate) syntax: SyntaxNode,
3119 }
3120 impl AstNode for TryBlockExpr {
3121     fn can_cast(kind: SyntaxKind) -> bool {
3122         match kind {
3123             TRY_BLOCK_EXPR => true,
3124             _ => false,
3125         }
3126     }
3127     fn cast(syntax: SyntaxNode) -> Option<Self> {
3128         if Self::can_cast(syntax.kind()) {
3129             Some(Self { syntax })
3130         } else {
3131             None
3132         }
3133     }
3134     fn syntax(&self) -> &SyntaxNode {
3135         &self.syntax
3136     }
3137 }
3138 impl TryBlockExpr {
3139     pub fn body(&self) -> Option<BlockExpr> {
3140         AstChildren::new(&self.syntax).next()
3141     }
3142 }
3143 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3144 pub struct TryExpr {
3145     pub(crate) syntax: SyntaxNode,
3146 }
3147 impl AstNode for TryExpr {
3148     fn can_cast(kind: SyntaxKind) -> bool {
3149         match kind {
3150             TRY_EXPR => true,
3151             _ => false,
3152         }
3153     }
3154     fn cast(syntax: SyntaxNode) -> Option<Self> {
3155         if Self::can_cast(syntax.kind()) {
3156             Some(Self { syntax })
3157         } else {
3158             None
3159         }
3160     }
3161     fn syntax(&self) -> &SyntaxNode {
3162         &self.syntax
3163     }
3164 }
3165 impl TryExpr {
3166     pub fn expr(&self) -> Option<Expr> {
3167         AstChildren::new(&self.syntax).next()
3168     }
3169 }
3170 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3171 pub struct TupleExpr {
3172     pub(crate) syntax: SyntaxNode,
3173 }
3174 impl AstNode for TupleExpr {
3175     fn can_cast(kind: SyntaxKind) -> bool {
3176         match kind {
3177             TUPLE_EXPR => true,
3178             _ => false,
3179         }
3180     }
3181     fn cast(syntax: SyntaxNode) -> Option<Self> {
3182         if Self::can_cast(syntax.kind()) {
3183             Some(Self { syntax })
3184         } else {
3185             None
3186         }
3187     }
3188     fn syntax(&self) -> &SyntaxNode {
3189         &self.syntax
3190     }
3191 }
3192 impl TupleExpr {
3193     pub fn exprs(&self) -> AstChildren<Expr> {
3194         AstChildren::new(&self.syntax)
3195     }
3196 }
3197 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3198 pub struct TupleFieldDef {
3199     pub(crate) syntax: SyntaxNode,
3200 }
3201 impl AstNode for TupleFieldDef {
3202     fn can_cast(kind: SyntaxKind) -> bool {
3203         match kind {
3204             TUPLE_FIELD_DEF => true,
3205             _ => false,
3206         }
3207     }
3208     fn cast(syntax: SyntaxNode) -> Option<Self> {
3209         if Self::can_cast(syntax.kind()) {
3210             Some(Self { syntax })
3211         } else {
3212             None
3213         }
3214     }
3215     fn syntax(&self) -> &SyntaxNode {
3216         &self.syntax
3217     }
3218 }
3219 impl ast::VisibilityOwner for TupleFieldDef {}
3220 impl ast::AttrsOwner for TupleFieldDef {}
3221 impl TupleFieldDef {
3222     pub fn type_ref(&self) -> Option<TypeRef> {
3223         AstChildren::new(&self.syntax).next()
3224     }
3225 }
3226 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3227 pub struct TupleFieldDefList {
3228     pub(crate) syntax: SyntaxNode,
3229 }
3230 impl AstNode for TupleFieldDefList {
3231     fn can_cast(kind: SyntaxKind) -> bool {
3232         match kind {
3233             TUPLE_FIELD_DEF_LIST => true,
3234             _ => false,
3235         }
3236     }
3237     fn cast(syntax: SyntaxNode) -> Option<Self> {
3238         if Self::can_cast(syntax.kind()) {
3239             Some(Self { syntax })
3240         } else {
3241             None
3242         }
3243     }
3244     fn syntax(&self) -> &SyntaxNode {
3245         &self.syntax
3246     }
3247 }
3248 impl TupleFieldDefList {
3249     pub fn fields(&self) -> AstChildren<TupleFieldDef> {
3250         AstChildren::new(&self.syntax)
3251     }
3252 }
3253 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3254 pub struct TuplePat {
3255     pub(crate) syntax: SyntaxNode,
3256 }
3257 impl AstNode for TuplePat {
3258     fn can_cast(kind: SyntaxKind) -> bool {
3259         match kind {
3260             TUPLE_PAT => true,
3261             _ => false,
3262         }
3263     }
3264     fn cast(syntax: SyntaxNode) -> Option<Self> {
3265         if Self::can_cast(syntax.kind()) {
3266             Some(Self { syntax })
3267         } else {
3268             None
3269         }
3270     }
3271     fn syntax(&self) -> &SyntaxNode {
3272         &self.syntax
3273     }
3274 }
3275 impl TuplePat {
3276     pub fn args(&self) -> AstChildren<Pat> {
3277         AstChildren::new(&self.syntax)
3278     }
3279 }
3280 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3281 pub struct TupleStructPat {
3282     pub(crate) syntax: SyntaxNode,
3283 }
3284 impl AstNode for TupleStructPat {
3285     fn can_cast(kind: SyntaxKind) -> bool {
3286         match kind {
3287             TUPLE_STRUCT_PAT => true,
3288             _ => false,
3289         }
3290     }
3291     fn cast(syntax: SyntaxNode) -> Option<Self> {
3292         if Self::can_cast(syntax.kind()) {
3293             Some(Self { syntax })
3294         } else {
3295             None
3296         }
3297     }
3298     fn syntax(&self) -> &SyntaxNode {
3299         &self.syntax
3300     }
3301 }
3302 impl TupleStructPat {
3303     pub fn args(&self) -> AstChildren<Pat> {
3304         AstChildren::new(&self.syntax)
3305     }
3306     pub fn path(&self) -> Option<Path> {
3307         AstChildren::new(&self.syntax).next()
3308     }
3309 }
3310 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3311 pub struct TupleType {
3312     pub(crate) syntax: SyntaxNode,
3313 }
3314 impl AstNode for TupleType {
3315     fn can_cast(kind: SyntaxKind) -> bool {
3316         match kind {
3317             TUPLE_TYPE => true,
3318             _ => false,
3319         }
3320     }
3321     fn cast(syntax: SyntaxNode) -> Option<Self> {
3322         if Self::can_cast(syntax.kind()) {
3323             Some(Self { syntax })
3324         } else {
3325             None
3326         }
3327     }
3328     fn syntax(&self) -> &SyntaxNode {
3329         &self.syntax
3330     }
3331 }
3332 impl TupleType {
3333     pub fn fields(&self) -> AstChildren<TypeRef> {
3334         AstChildren::new(&self.syntax)
3335     }
3336 }
3337 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3338 pub struct TypeAliasDef {
3339     pub(crate) syntax: SyntaxNode,
3340 }
3341 impl AstNode for TypeAliasDef {
3342     fn can_cast(kind: SyntaxKind) -> bool {
3343         match kind {
3344             TYPE_ALIAS_DEF => true,
3345             _ => false,
3346         }
3347     }
3348     fn cast(syntax: SyntaxNode) -> Option<Self> {
3349         if Self::can_cast(syntax.kind()) {
3350             Some(Self { syntax })
3351         } else {
3352             None
3353         }
3354     }
3355     fn syntax(&self) -> &SyntaxNode {
3356         &self.syntax
3357     }
3358 }
3359 impl ast::VisibilityOwner for TypeAliasDef {}
3360 impl ast::NameOwner for TypeAliasDef {}
3361 impl ast::TypeParamsOwner for TypeAliasDef {}
3362 impl ast::AttrsOwner for TypeAliasDef {}
3363 impl ast::DocCommentsOwner for TypeAliasDef {}
3364 impl ast::TypeBoundsOwner for TypeAliasDef {}
3365 impl TypeAliasDef {
3366     pub fn type_ref(&self) -> Option<TypeRef> {
3367         AstChildren::new(&self.syntax).next()
3368     }
3369 }
3370 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3371 pub struct TypeArg {
3372     pub(crate) syntax: SyntaxNode,
3373 }
3374 impl AstNode for TypeArg {
3375     fn can_cast(kind: SyntaxKind) -> bool {
3376         match kind {
3377             TYPE_ARG => true,
3378             _ => false,
3379         }
3380     }
3381     fn cast(syntax: SyntaxNode) -> Option<Self> {
3382         if Self::can_cast(syntax.kind()) {
3383             Some(Self { syntax })
3384         } else {
3385             None
3386         }
3387     }
3388     fn syntax(&self) -> &SyntaxNode {
3389         &self.syntax
3390     }
3391 }
3392 impl TypeArg {
3393     pub fn type_ref(&self) -> Option<TypeRef> {
3394         AstChildren::new(&self.syntax).next()
3395     }
3396 }
3397 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3398 pub struct TypeArgList {
3399     pub(crate) syntax: SyntaxNode,
3400 }
3401 impl AstNode for TypeArgList {
3402     fn can_cast(kind: SyntaxKind) -> bool {
3403         match kind {
3404             TYPE_ARG_LIST => true,
3405             _ => false,
3406         }
3407     }
3408     fn cast(syntax: SyntaxNode) -> Option<Self> {
3409         if Self::can_cast(syntax.kind()) {
3410             Some(Self { syntax })
3411         } else {
3412             None
3413         }
3414     }
3415     fn syntax(&self) -> &SyntaxNode {
3416         &self.syntax
3417     }
3418 }
3419 impl TypeArgList {
3420     pub fn type_args(&self) -> AstChildren<TypeArg> {
3421         AstChildren::new(&self.syntax)
3422     }
3423     pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> {
3424         AstChildren::new(&self.syntax)
3425     }
3426     pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> {
3427         AstChildren::new(&self.syntax)
3428     }
3429 }
3430 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3431 pub struct TypeBound {
3432     pub(crate) syntax: SyntaxNode,
3433 }
3434 impl AstNode for TypeBound {
3435     fn can_cast(kind: SyntaxKind) -> bool {
3436         match kind {
3437             TYPE_BOUND => true,
3438             _ => false,
3439         }
3440     }
3441     fn cast(syntax: SyntaxNode) -> Option<Self> {
3442         if Self::can_cast(syntax.kind()) {
3443             Some(Self { syntax })
3444         } else {
3445             None
3446         }
3447     }
3448     fn syntax(&self) -> &SyntaxNode {
3449         &self.syntax
3450     }
3451 }
3452 impl TypeBound {
3453     pub fn type_ref(&self) -> Option<TypeRef> {
3454         AstChildren::new(&self.syntax).next()
3455     }
3456 }
3457 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3458 pub struct TypeBoundList {
3459     pub(crate) syntax: SyntaxNode,
3460 }
3461 impl AstNode for TypeBoundList {
3462     fn can_cast(kind: SyntaxKind) -> bool {
3463         match kind {
3464             TYPE_BOUND_LIST => true,
3465             _ => false,
3466         }
3467     }
3468     fn cast(syntax: SyntaxNode) -> Option<Self> {
3469         if Self::can_cast(syntax.kind()) {
3470             Some(Self { syntax })
3471         } else {
3472             None
3473         }
3474     }
3475     fn syntax(&self) -> &SyntaxNode {
3476         &self.syntax
3477     }
3478 }
3479 impl TypeBoundList {
3480     pub fn bounds(&self) -> AstChildren<TypeBound> {
3481         AstChildren::new(&self.syntax)
3482     }
3483 }
3484 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3485 pub struct TypeParam {
3486     pub(crate) syntax: SyntaxNode,
3487 }
3488 impl AstNode for TypeParam {
3489     fn can_cast(kind: SyntaxKind) -> bool {
3490         match kind {
3491             TYPE_PARAM => true,
3492             _ => false,
3493         }
3494     }
3495     fn cast(syntax: SyntaxNode) -> Option<Self> {
3496         if Self::can_cast(syntax.kind()) {
3497             Some(Self { syntax })
3498         } else {
3499             None
3500         }
3501     }
3502     fn syntax(&self) -> &SyntaxNode {
3503         &self.syntax
3504     }
3505 }
3506 impl ast::NameOwner for TypeParam {}
3507 impl ast::AttrsOwner for TypeParam {}
3508 impl ast::TypeBoundsOwner for TypeParam {}
3509 impl ast::DefaultTypeParamOwner for TypeParam {}
3510 impl TypeParam {}
3511 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3512 pub struct TypeParamList {
3513     pub(crate) syntax: SyntaxNode,
3514 }
3515 impl AstNode for TypeParamList {
3516     fn can_cast(kind: SyntaxKind) -> bool {
3517         match kind {
3518             TYPE_PARAM_LIST => true,
3519             _ => false,
3520         }
3521     }
3522     fn cast(syntax: SyntaxNode) -> Option<Self> {
3523         if Self::can_cast(syntax.kind()) {
3524             Some(Self { syntax })
3525         } else {
3526             None
3527         }
3528     }
3529     fn syntax(&self) -> &SyntaxNode {
3530         &self.syntax
3531     }
3532 }
3533 impl TypeParamList {
3534     pub fn type_params(&self) -> AstChildren<TypeParam> {
3535         AstChildren::new(&self.syntax)
3536     }
3537     pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> {
3538         AstChildren::new(&self.syntax)
3539     }
3540 }
3541 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3542 pub enum TypeRef {
3543     ParenType(ParenType),
3544     TupleType(TupleType),
3545     NeverType(NeverType),
3546     PathType(PathType),
3547     PointerType(PointerType),
3548     ArrayType(ArrayType),
3549     SliceType(SliceType),
3550     ReferenceType(ReferenceType),
3551     PlaceholderType(PlaceholderType),
3552     FnPointerType(FnPointerType),
3553     ForType(ForType),
3554     ImplTraitType(ImplTraitType),
3555     DynTraitType(DynTraitType),
3556 }
3557 impl From<ParenType> for TypeRef {
3558     fn from(node: ParenType) -> TypeRef {
3559         TypeRef::ParenType(node)
3560     }
3561 }
3562 impl From<TupleType> for TypeRef {
3563     fn from(node: TupleType) -> TypeRef {
3564         TypeRef::TupleType(node)
3565     }
3566 }
3567 impl From<NeverType> for TypeRef {
3568     fn from(node: NeverType) -> TypeRef {
3569         TypeRef::NeverType(node)
3570     }
3571 }
3572 impl From<PathType> for TypeRef {
3573     fn from(node: PathType) -> TypeRef {
3574         TypeRef::PathType(node)
3575     }
3576 }
3577 impl From<PointerType> for TypeRef {
3578     fn from(node: PointerType) -> TypeRef {
3579         TypeRef::PointerType(node)
3580     }
3581 }
3582 impl From<ArrayType> for TypeRef {
3583     fn from(node: ArrayType) -> TypeRef {
3584         TypeRef::ArrayType(node)
3585     }
3586 }
3587 impl From<SliceType> for TypeRef {
3588     fn from(node: SliceType) -> TypeRef {
3589         TypeRef::SliceType(node)
3590     }
3591 }
3592 impl From<ReferenceType> for TypeRef {
3593     fn from(node: ReferenceType) -> TypeRef {
3594         TypeRef::ReferenceType(node)
3595     }
3596 }
3597 impl From<PlaceholderType> for TypeRef {
3598     fn from(node: PlaceholderType) -> TypeRef {
3599         TypeRef::PlaceholderType(node)
3600     }
3601 }
3602 impl From<FnPointerType> for TypeRef {
3603     fn from(node: FnPointerType) -> TypeRef {
3604         TypeRef::FnPointerType(node)
3605     }
3606 }
3607 impl From<ForType> for TypeRef {
3608     fn from(node: ForType) -> TypeRef {
3609         TypeRef::ForType(node)
3610     }
3611 }
3612 impl From<ImplTraitType> for TypeRef {
3613     fn from(node: ImplTraitType) -> TypeRef {
3614         TypeRef::ImplTraitType(node)
3615     }
3616 }
3617 impl From<DynTraitType> for TypeRef {
3618     fn from(node: DynTraitType) -> TypeRef {
3619         TypeRef::DynTraitType(node)
3620     }
3621 }
3622 impl AstNode for TypeRef {
3623     fn can_cast(kind: SyntaxKind) -> bool {
3624         match kind {
3625             PAREN_TYPE | TUPLE_TYPE | NEVER_TYPE | PATH_TYPE | POINTER_TYPE | ARRAY_TYPE
3626             | SLICE_TYPE | REFERENCE_TYPE | PLACEHOLDER_TYPE | FN_POINTER_TYPE | FOR_TYPE
3627             | IMPL_TRAIT_TYPE | DYN_TRAIT_TYPE => true,
3628             _ => false,
3629         }
3630     }
3631     fn cast(syntax: SyntaxNode) -> Option<Self> {
3632         let res = match syntax.kind() {
3633             PAREN_TYPE => TypeRef::ParenType(ParenType { syntax }),
3634             TUPLE_TYPE => TypeRef::TupleType(TupleType { syntax }),
3635             NEVER_TYPE => TypeRef::NeverType(NeverType { syntax }),
3636             PATH_TYPE => TypeRef::PathType(PathType { syntax }),
3637             POINTER_TYPE => TypeRef::PointerType(PointerType { syntax }),
3638             ARRAY_TYPE => TypeRef::ArrayType(ArrayType { syntax }),
3639             SLICE_TYPE => TypeRef::SliceType(SliceType { syntax }),
3640             REFERENCE_TYPE => TypeRef::ReferenceType(ReferenceType { syntax }),
3641             PLACEHOLDER_TYPE => TypeRef::PlaceholderType(PlaceholderType { syntax }),
3642             FN_POINTER_TYPE => TypeRef::FnPointerType(FnPointerType { syntax }),
3643             FOR_TYPE => TypeRef::ForType(ForType { syntax }),
3644             IMPL_TRAIT_TYPE => TypeRef::ImplTraitType(ImplTraitType { syntax }),
3645             DYN_TRAIT_TYPE => TypeRef::DynTraitType(DynTraitType { syntax }),
3646             _ => return None,
3647         };
3648         Some(res)
3649     }
3650     fn syntax(&self) -> &SyntaxNode {
3651         match self {
3652             TypeRef::ParenType(it) => &it.syntax,
3653             TypeRef::TupleType(it) => &it.syntax,
3654             TypeRef::NeverType(it) => &it.syntax,
3655             TypeRef::PathType(it) => &it.syntax,
3656             TypeRef::PointerType(it) => &it.syntax,
3657             TypeRef::ArrayType(it) => &it.syntax,
3658             TypeRef::SliceType(it) => &it.syntax,
3659             TypeRef::ReferenceType(it) => &it.syntax,
3660             TypeRef::PlaceholderType(it) => &it.syntax,
3661             TypeRef::FnPointerType(it) => &it.syntax,
3662             TypeRef::ForType(it) => &it.syntax,
3663             TypeRef::ImplTraitType(it) => &it.syntax,
3664             TypeRef::DynTraitType(it) => &it.syntax,
3665         }
3666     }
3667 }
3668 impl TypeRef {}
3669 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3670 pub struct UseItem {
3671     pub(crate) syntax: SyntaxNode,
3672 }
3673 impl AstNode for UseItem {
3674     fn can_cast(kind: SyntaxKind) -> bool {
3675         match kind {
3676             USE_ITEM => true,
3677             _ => false,
3678         }
3679     }
3680     fn cast(syntax: SyntaxNode) -> Option<Self> {
3681         if Self::can_cast(syntax.kind()) {
3682             Some(Self { syntax })
3683         } else {
3684             None
3685         }
3686     }
3687     fn syntax(&self) -> &SyntaxNode {
3688         &self.syntax
3689     }
3690 }
3691 impl ast::AttrsOwner for UseItem {}
3692 impl UseItem {
3693     pub fn use_tree(&self) -> Option<UseTree> {
3694         AstChildren::new(&self.syntax).next()
3695     }
3696 }
3697 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3698 pub struct UseTree {
3699     pub(crate) syntax: SyntaxNode,
3700 }
3701 impl AstNode for UseTree {
3702     fn can_cast(kind: SyntaxKind) -> bool {
3703         match kind {
3704             USE_TREE => true,
3705             _ => false,
3706         }
3707     }
3708     fn cast(syntax: SyntaxNode) -> Option<Self> {
3709         if Self::can_cast(syntax.kind()) {
3710             Some(Self { syntax })
3711         } else {
3712             None
3713         }
3714     }
3715     fn syntax(&self) -> &SyntaxNode {
3716         &self.syntax
3717     }
3718 }
3719 impl UseTree {
3720     pub fn path(&self) -> Option<Path> {
3721         AstChildren::new(&self.syntax).next()
3722     }
3723     pub fn use_tree_list(&self) -> Option<UseTreeList> {
3724         AstChildren::new(&self.syntax).next()
3725     }
3726     pub fn alias(&self) -> Option<Alias> {
3727         AstChildren::new(&self.syntax).next()
3728     }
3729 }
3730 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3731 pub struct UseTreeList {
3732     pub(crate) syntax: SyntaxNode,
3733 }
3734 impl AstNode for UseTreeList {
3735     fn can_cast(kind: SyntaxKind) -> bool {
3736         match kind {
3737             USE_TREE_LIST => true,
3738             _ => false,
3739         }
3740     }
3741     fn cast(syntax: SyntaxNode) -> Option<Self> {
3742         if Self::can_cast(syntax.kind()) {
3743             Some(Self { syntax })
3744         } else {
3745             None
3746         }
3747     }
3748     fn syntax(&self) -> &SyntaxNode {
3749         &self.syntax
3750     }
3751 }
3752 impl UseTreeList {
3753     pub fn use_trees(&self) -> AstChildren<UseTree> {
3754         AstChildren::new(&self.syntax)
3755     }
3756 }
3757 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3758 pub struct Visibility {
3759     pub(crate) syntax: SyntaxNode,
3760 }
3761 impl AstNode for Visibility {
3762     fn can_cast(kind: SyntaxKind) -> bool {
3763         match kind {
3764             VISIBILITY => true,
3765             _ => false,
3766         }
3767     }
3768     fn cast(syntax: SyntaxNode) -> Option<Self> {
3769         if Self::can_cast(syntax.kind()) {
3770             Some(Self { syntax })
3771         } else {
3772             None
3773         }
3774     }
3775     fn syntax(&self) -> &SyntaxNode {
3776         &self.syntax
3777     }
3778 }
3779 impl Visibility {}
3780 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3781 pub struct WhereClause {
3782     pub(crate) syntax: SyntaxNode,
3783 }
3784 impl AstNode for WhereClause {
3785     fn can_cast(kind: SyntaxKind) -> bool {
3786         match kind {
3787             WHERE_CLAUSE => true,
3788             _ => false,
3789         }
3790     }
3791     fn cast(syntax: SyntaxNode) -> Option<Self> {
3792         if Self::can_cast(syntax.kind()) {
3793             Some(Self { syntax })
3794         } else {
3795             None
3796         }
3797     }
3798     fn syntax(&self) -> &SyntaxNode {
3799         &self.syntax
3800     }
3801 }
3802 impl WhereClause {
3803     pub fn predicates(&self) -> AstChildren<WherePred> {
3804         AstChildren::new(&self.syntax)
3805     }
3806 }
3807 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3808 pub struct WherePred {
3809     pub(crate) syntax: SyntaxNode,
3810 }
3811 impl AstNode for WherePred {
3812     fn can_cast(kind: SyntaxKind) -> bool {
3813         match kind {
3814             WHERE_PRED => true,
3815             _ => false,
3816         }
3817     }
3818     fn cast(syntax: SyntaxNode) -> Option<Self> {
3819         if Self::can_cast(syntax.kind()) {
3820             Some(Self { syntax })
3821         } else {
3822             None
3823         }
3824     }
3825     fn syntax(&self) -> &SyntaxNode {
3826         &self.syntax
3827     }
3828 }
3829 impl ast::TypeBoundsOwner for WherePred {}
3830 impl WherePred {
3831     pub fn type_ref(&self) -> Option<TypeRef> {
3832         AstChildren::new(&self.syntax).next()
3833     }
3834 }
3835 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3836 pub struct WhileExpr {
3837     pub(crate) syntax: SyntaxNode,
3838 }
3839 impl AstNode for WhileExpr {
3840     fn can_cast(kind: SyntaxKind) -> bool {
3841         match kind {
3842             WHILE_EXPR => true,
3843             _ => false,
3844         }
3845     }
3846     fn cast(syntax: SyntaxNode) -> Option<Self> {
3847         if Self::can_cast(syntax.kind()) {
3848             Some(Self { syntax })
3849         } else {
3850             None
3851         }
3852     }
3853     fn syntax(&self) -> &SyntaxNode {
3854         &self.syntax
3855     }
3856 }
3857 impl ast::LoopBodyOwner for WhileExpr {}
3858 impl WhileExpr {
3859     pub fn condition(&self) -> Option<Condition> {
3860         AstChildren::new(&self.syntax).next()
3861     }
3862 }