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