]> git.lizzy.rs Git - rust.git/blob - crates/ra_syntax/src/ast/generated.rs
Add `ModuleItemsOwner` to `Block`
[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 body(&self) -> Option<Expr> {
1430         AstChildren::new(&self.syntax).next()
1431     }
1432 }
1433 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1434 pub struct LetStmt {
1435     pub(crate) syntax: SyntaxNode,
1436 }
1437 impl AstNode for LetStmt {
1438     fn can_cast(kind: SyntaxKind) -> bool {
1439         match kind {
1440             LET_STMT => true,
1441             _ => false,
1442         }
1443     }
1444     fn cast(syntax: SyntaxNode) -> Option<Self> {
1445         if Self::can_cast(syntax.kind()) {
1446             Some(Self { syntax })
1447         } else {
1448             None
1449         }
1450     }
1451     fn syntax(&self) -> &SyntaxNode {
1452         &self.syntax
1453     }
1454 }
1455 impl ast::TypeAscriptionOwner for LetStmt {}
1456 impl LetStmt {
1457     pub fn pat(&self) -> Option<Pat> {
1458         AstChildren::new(&self.syntax).next()
1459     }
1460     pub fn initializer(&self) -> Option<Expr> {
1461         AstChildren::new(&self.syntax).next()
1462     }
1463 }
1464 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1465 pub struct LifetimeArg {
1466     pub(crate) syntax: SyntaxNode,
1467 }
1468 impl AstNode for LifetimeArg {
1469     fn can_cast(kind: SyntaxKind) -> bool {
1470         match kind {
1471             LIFETIME_ARG => true,
1472             _ => false,
1473         }
1474     }
1475     fn cast(syntax: SyntaxNode) -> Option<Self> {
1476         if Self::can_cast(syntax.kind()) {
1477             Some(Self { syntax })
1478         } else {
1479             None
1480         }
1481     }
1482     fn syntax(&self) -> &SyntaxNode {
1483         &self.syntax
1484     }
1485 }
1486 impl LifetimeArg {}
1487 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1488 pub struct LifetimeParam {
1489     pub(crate) syntax: SyntaxNode,
1490 }
1491 impl AstNode for LifetimeParam {
1492     fn can_cast(kind: SyntaxKind) -> bool {
1493         match kind {
1494             LIFETIME_PARAM => true,
1495             _ => false,
1496         }
1497     }
1498     fn cast(syntax: SyntaxNode) -> Option<Self> {
1499         if Self::can_cast(syntax.kind()) {
1500             Some(Self { syntax })
1501         } else {
1502             None
1503         }
1504     }
1505     fn syntax(&self) -> &SyntaxNode {
1506         &self.syntax
1507     }
1508 }
1509 impl ast::AttrsOwner for LifetimeParam {}
1510 impl LifetimeParam {}
1511 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1512 pub struct Literal {
1513     pub(crate) syntax: SyntaxNode,
1514 }
1515 impl AstNode for Literal {
1516     fn can_cast(kind: SyntaxKind) -> bool {
1517         match kind {
1518             LITERAL => true,
1519             _ => false,
1520         }
1521     }
1522     fn cast(syntax: SyntaxNode) -> Option<Self> {
1523         if Self::can_cast(syntax.kind()) {
1524             Some(Self { syntax })
1525         } else {
1526             None
1527         }
1528     }
1529     fn syntax(&self) -> &SyntaxNode {
1530         &self.syntax
1531     }
1532 }
1533 impl Literal {}
1534 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1535 pub struct LiteralPat {
1536     pub(crate) syntax: SyntaxNode,
1537 }
1538 impl AstNode for LiteralPat {
1539     fn can_cast(kind: SyntaxKind) -> bool {
1540         match kind {
1541             LITERAL_PAT => true,
1542             _ => false,
1543         }
1544     }
1545     fn cast(syntax: SyntaxNode) -> Option<Self> {
1546         if Self::can_cast(syntax.kind()) {
1547             Some(Self { syntax })
1548         } else {
1549             None
1550         }
1551     }
1552     fn syntax(&self) -> &SyntaxNode {
1553         &self.syntax
1554     }
1555 }
1556 impl LiteralPat {
1557     pub fn literal(&self) -> Option<Literal> {
1558         AstChildren::new(&self.syntax).next()
1559     }
1560 }
1561 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1562 pub struct LoopExpr {
1563     pub(crate) syntax: SyntaxNode,
1564 }
1565 impl AstNode for LoopExpr {
1566     fn can_cast(kind: SyntaxKind) -> bool {
1567         match kind {
1568             LOOP_EXPR => true,
1569             _ => false,
1570         }
1571     }
1572     fn cast(syntax: SyntaxNode) -> Option<Self> {
1573         if Self::can_cast(syntax.kind()) {
1574             Some(Self { syntax })
1575         } else {
1576             None
1577         }
1578     }
1579     fn syntax(&self) -> &SyntaxNode {
1580         &self.syntax
1581     }
1582 }
1583 impl ast::LoopBodyOwner for LoopExpr {}
1584 impl LoopExpr {}
1585 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1586 pub struct MacroCall {
1587     pub(crate) syntax: SyntaxNode,
1588 }
1589 impl AstNode for MacroCall {
1590     fn can_cast(kind: SyntaxKind) -> bool {
1591         match kind {
1592             MACRO_CALL => true,
1593             _ => false,
1594         }
1595     }
1596     fn cast(syntax: SyntaxNode) -> Option<Self> {
1597         if Self::can_cast(syntax.kind()) {
1598             Some(Self { syntax })
1599         } else {
1600             None
1601         }
1602     }
1603     fn syntax(&self) -> &SyntaxNode {
1604         &self.syntax
1605     }
1606 }
1607 impl ast::NameOwner for MacroCall {}
1608 impl ast::AttrsOwner for MacroCall {}
1609 impl ast::DocCommentsOwner for MacroCall {}
1610 impl MacroCall {
1611     pub fn token_tree(&self) -> Option<TokenTree> {
1612         AstChildren::new(&self.syntax).next()
1613     }
1614     pub fn path(&self) -> Option<Path> {
1615         AstChildren::new(&self.syntax).next()
1616     }
1617 }
1618 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1619 pub struct MacroItems {
1620     pub(crate) syntax: SyntaxNode,
1621 }
1622 impl AstNode for MacroItems {
1623     fn can_cast(kind: SyntaxKind) -> bool {
1624         match kind {
1625             MACRO_ITEMS => true,
1626             _ => false,
1627         }
1628     }
1629     fn cast(syntax: SyntaxNode) -> Option<Self> {
1630         if Self::can_cast(syntax.kind()) {
1631             Some(Self { syntax })
1632         } else {
1633             None
1634         }
1635     }
1636     fn syntax(&self) -> &SyntaxNode {
1637         &self.syntax
1638     }
1639 }
1640 impl ast::ModuleItemOwner for MacroItems {}
1641 impl ast::FnDefOwner for MacroItems {}
1642 impl MacroItems {}
1643 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1644 pub struct MacroStmts {
1645     pub(crate) syntax: SyntaxNode,
1646 }
1647 impl AstNode for MacroStmts {
1648     fn can_cast(kind: SyntaxKind) -> bool {
1649         match kind {
1650             MACRO_STMTS => true,
1651             _ => false,
1652         }
1653     }
1654     fn cast(syntax: SyntaxNode) -> Option<Self> {
1655         if Self::can_cast(syntax.kind()) {
1656             Some(Self { syntax })
1657         } else {
1658             None
1659         }
1660     }
1661     fn syntax(&self) -> &SyntaxNode {
1662         &self.syntax
1663     }
1664 }
1665 impl MacroStmts {
1666     pub fn statements(&self) -> AstChildren<Stmt> {
1667         AstChildren::new(&self.syntax)
1668     }
1669     pub fn expr(&self) -> Option<Expr> {
1670         AstChildren::new(&self.syntax).next()
1671     }
1672 }
1673 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1674 pub struct MatchArm {
1675     pub(crate) syntax: SyntaxNode,
1676 }
1677 impl AstNode for MatchArm {
1678     fn can_cast(kind: SyntaxKind) -> bool {
1679         match kind {
1680             MATCH_ARM => true,
1681             _ => false,
1682         }
1683     }
1684     fn cast(syntax: SyntaxNode) -> Option<Self> {
1685         if Self::can_cast(syntax.kind()) {
1686             Some(Self { syntax })
1687         } else {
1688             None
1689         }
1690     }
1691     fn syntax(&self) -> &SyntaxNode {
1692         &self.syntax
1693     }
1694 }
1695 impl ast::AttrsOwner for MatchArm {}
1696 impl MatchArm {
1697     pub fn pats(&self) -> AstChildren<Pat> {
1698         AstChildren::new(&self.syntax)
1699     }
1700     pub fn guard(&self) -> Option<MatchGuard> {
1701         AstChildren::new(&self.syntax).next()
1702     }
1703     pub fn expr(&self) -> Option<Expr> {
1704         AstChildren::new(&self.syntax).next()
1705     }
1706 }
1707 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1708 pub struct MatchArmList {
1709     pub(crate) syntax: SyntaxNode,
1710 }
1711 impl AstNode for MatchArmList {
1712     fn can_cast(kind: SyntaxKind) -> bool {
1713         match kind {
1714             MATCH_ARM_LIST => true,
1715             _ => false,
1716         }
1717     }
1718     fn cast(syntax: SyntaxNode) -> Option<Self> {
1719         if Self::can_cast(syntax.kind()) {
1720             Some(Self { syntax })
1721         } else {
1722             None
1723         }
1724     }
1725     fn syntax(&self) -> &SyntaxNode {
1726         &self.syntax
1727     }
1728 }
1729 impl ast::AttrsOwner for MatchArmList {}
1730 impl MatchArmList {
1731     pub fn arms(&self) -> AstChildren<MatchArm> {
1732         AstChildren::new(&self.syntax)
1733     }
1734 }
1735 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1736 pub struct MatchExpr {
1737     pub(crate) syntax: SyntaxNode,
1738 }
1739 impl AstNode for MatchExpr {
1740     fn can_cast(kind: SyntaxKind) -> bool {
1741         match kind {
1742             MATCH_EXPR => true,
1743             _ => false,
1744         }
1745     }
1746     fn cast(syntax: SyntaxNode) -> Option<Self> {
1747         if Self::can_cast(syntax.kind()) {
1748             Some(Self { syntax })
1749         } else {
1750             None
1751         }
1752     }
1753     fn syntax(&self) -> &SyntaxNode {
1754         &self.syntax
1755     }
1756 }
1757 impl MatchExpr {
1758     pub fn expr(&self) -> Option<Expr> {
1759         AstChildren::new(&self.syntax).next()
1760     }
1761     pub fn match_arm_list(&self) -> Option<MatchArmList> {
1762         AstChildren::new(&self.syntax).next()
1763     }
1764 }
1765 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1766 pub struct MatchGuard {
1767     pub(crate) syntax: SyntaxNode,
1768 }
1769 impl AstNode for MatchGuard {
1770     fn can_cast(kind: SyntaxKind) -> bool {
1771         match kind {
1772             MATCH_GUARD => true,
1773             _ => false,
1774         }
1775     }
1776     fn cast(syntax: SyntaxNode) -> Option<Self> {
1777         if Self::can_cast(syntax.kind()) {
1778             Some(Self { syntax })
1779         } else {
1780             None
1781         }
1782     }
1783     fn syntax(&self) -> &SyntaxNode {
1784         &self.syntax
1785     }
1786 }
1787 impl MatchGuard {
1788     pub fn expr(&self) -> Option<Expr> {
1789         AstChildren::new(&self.syntax).next()
1790     }
1791 }
1792 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1793 pub struct MethodCallExpr {
1794     pub(crate) syntax: SyntaxNode,
1795 }
1796 impl AstNode for MethodCallExpr {
1797     fn can_cast(kind: SyntaxKind) -> bool {
1798         match kind {
1799             METHOD_CALL_EXPR => true,
1800             _ => false,
1801         }
1802     }
1803     fn cast(syntax: SyntaxNode) -> Option<Self> {
1804         if Self::can_cast(syntax.kind()) {
1805             Some(Self { syntax })
1806         } else {
1807             None
1808         }
1809     }
1810     fn syntax(&self) -> &SyntaxNode {
1811         &self.syntax
1812     }
1813 }
1814 impl ast::ArgListOwner for MethodCallExpr {}
1815 impl MethodCallExpr {
1816     pub fn expr(&self) -> Option<Expr> {
1817         AstChildren::new(&self.syntax).next()
1818     }
1819     pub fn name_ref(&self) -> Option<NameRef> {
1820         AstChildren::new(&self.syntax).next()
1821     }
1822     pub fn type_arg_list(&self) -> Option<TypeArgList> {
1823         AstChildren::new(&self.syntax).next()
1824     }
1825 }
1826 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1827 pub struct Module {
1828     pub(crate) syntax: SyntaxNode,
1829 }
1830 impl AstNode for Module {
1831     fn can_cast(kind: SyntaxKind) -> bool {
1832         match kind {
1833             MODULE => true,
1834             _ => false,
1835         }
1836     }
1837     fn cast(syntax: SyntaxNode) -> Option<Self> {
1838         if Self::can_cast(syntax.kind()) {
1839             Some(Self { syntax })
1840         } else {
1841             None
1842         }
1843     }
1844     fn syntax(&self) -> &SyntaxNode {
1845         &self.syntax
1846     }
1847 }
1848 impl ast::VisibilityOwner for Module {}
1849 impl ast::NameOwner for Module {}
1850 impl ast::AttrsOwner for Module {}
1851 impl ast::DocCommentsOwner for Module {}
1852 impl Module {
1853     pub fn item_list(&self) -> Option<ItemList> {
1854         AstChildren::new(&self.syntax).next()
1855     }
1856 }
1857 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1858 pub enum ModuleItem {
1859     StructDef(StructDef),
1860     UnionDef(UnionDef),
1861     EnumDef(EnumDef),
1862     FnDef(FnDef),
1863     TraitDef(TraitDef),
1864     TypeAliasDef(TypeAliasDef),
1865     ImplBlock(ImplBlock),
1866     UseItem(UseItem),
1867     ExternCrateItem(ExternCrateItem),
1868     ConstDef(ConstDef),
1869     StaticDef(StaticDef),
1870     Module(Module),
1871 }
1872 impl From<StructDef> for ModuleItem {
1873     fn from(node: StructDef) -> ModuleItem {
1874         ModuleItem::StructDef(node)
1875     }
1876 }
1877 impl From<UnionDef> for ModuleItem {
1878     fn from(node: UnionDef) -> ModuleItem {
1879         ModuleItem::UnionDef(node)
1880     }
1881 }
1882 impl From<EnumDef> for ModuleItem {
1883     fn from(node: EnumDef) -> ModuleItem {
1884         ModuleItem::EnumDef(node)
1885     }
1886 }
1887 impl From<FnDef> for ModuleItem {
1888     fn from(node: FnDef) -> ModuleItem {
1889         ModuleItem::FnDef(node)
1890     }
1891 }
1892 impl From<TraitDef> for ModuleItem {
1893     fn from(node: TraitDef) -> ModuleItem {
1894         ModuleItem::TraitDef(node)
1895     }
1896 }
1897 impl From<TypeAliasDef> for ModuleItem {
1898     fn from(node: TypeAliasDef) -> ModuleItem {
1899         ModuleItem::TypeAliasDef(node)
1900     }
1901 }
1902 impl From<ImplBlock> for ModuleItem {
1903     fn from(node: ImplBlock) -> ModuleItem {
1904         ModuleItem::ImplBlock(node)
1905     }
1906 }
1907 impl From<UseItem> for ModuleItem {
1908     fn from(node: UseItem) -> ModuleItem {
1909         ModuleItem::UseItem(node)
1910     }
1911 }
1912 impl From<ExternCrateItem> for ModuleItem {
1913     fn from(node: ExternCrateItem) -> ModuleItem {
1914         ModuleItem::ExternCrateItem(node)
1915     }
1916 }
1917 impl From<ConstDef> for ModuleItem {
1918     fn from(node: ConstDef) -> ModuleItem {
1919         ModuleItem::ConstDef(node)
1920     }
1921 }
1922 impl From<StaticDef> for ModuleItem {
1923     fn from(node: StaticDef) -> ModuleItem {
1924         ModuleItem::StaticDef(node)
1925     }
1926 }
1927 impl From<Module> for ModuleItem {
1928     fn from(node: Module) -> ModuleItem {
1929         ModuleItem::Module(node)
1930     }
1931 }
1932 impl AstNode for ModuleItem {
1933     fn can_cast(kind: SyntaxKind) -> bool {
1934         match kind {
1935             STRUCT_DEF | UNION_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF
1936             | IMPL_BLOCK | USE_ITEM | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE => true,
1937             _ => false,
1938         }
1939     }
1940     fn cast(syntax: SyntaxNode) -> Option<Self> {
1941         let res = match syntax.kind() {
1942             STRUCT_DEF => ModuleItem::StructDef(StructDef { syntax }),
1943             UNION_DEF => ModuleItem::UnionDef(UnionDef { syntax }),
1944             ENUM_DEF => ModuleItem::EnumDef(EnumDef { syntax }),
1945             FN_DEF => ModuleItem::FnDef(FnDef { syntax }),
1946             TRAIT_DEF => ModuleItem::TraitDef(TraitDef { syntax }),
1947             TYPE_ALIAS_DEF => ModuleItem::TypeAliasDef(TypeAliasDef { syntax }),
1948             IMPL_BLOCK => ModuleItem::ImplBlock(ImplBlock { syntax }),
1949             USE_ITEM => ModuleItem::UseItem(UseItem { syntax }),
1950             EXTERN_CRATE_ITEM => ModuleItem::ExternCrateItem(ExternCrateItem { syntax }),
1951             CONST_DEF => ModuleItem::ConstDef(ConstDef { syntax }),
1952             STATIC_DEF => ModuleItem::StaticDef(StaticDef { syntax }),
1953             MODULE => ModuleItem::Module(Module { syntax }),
1954             _ => return None,
1955         };
1956         Some(res)
1957     }
1958     fn syntax(&self) -> &SyntaxNode {
1959         match self {
1960             ModuleItem::StructDef(it) => &it.syntax,
1961             ModuleItem::UnionDef(it) => &it.syntax,
1962             ModuleItem::EnumDef(it) => &it.syntax,
1963             ModuleItem::FnDef(it) => &it.syntax,
1964             ModuleItem::TraitDef(it) => &it.syntax,
1965             ModuleItem::TypeAliasDef(it) => &it.syntax,
1966             ModuleItem::ImplBlock(it) => &it.syntax,
1967             ModuleItem::UseItem(it) => &it.syntax,
1968             ModuleItem::ExternCrateItem(it) => &it.syntax,
1969             ModuleItem::ConstDef(it) => &it.syntax,
1970             ModuleItem::StaticDef(it) => &it.syntax,
1971             ModuleItem::Module(it) => &it.syntax,
1972         }
1973     }
1974 }
1975 impl ast::AttrsOwner for ModuleItem {}
1976 impl ModuleItem {}
1977 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1978 pub struct Name {
1979     pub(crate) syntax: SyntaxNode,
1980 }
1981 impl AstNode for Name {
1982     fn can_cast(kind: SyntaxKind) -> bool {
1983         match kind {
1984             NAME => true,
1985             _ => false,
1986         }
1987     }
1988     fn cast(syntax: SyntaxNode) -> Option<Self> {
1989         if Self::can_cast(syntax.kind()) {
1990             Some(Self { syntax })
1991         } else {
1992             None
1993         }
1994     }
1995     fn syntax(&self) -> &SyntaxNode {
1996         &self.syntax
1997     }
1998 }
1999 impl Name {}
2000 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2001 pub struct NameRef {
2002     pub(crate) syntax: SyntaxNode,
2003 }
2004 impl AstNode for NameRef {
2005     fn can_cast(kind: SyntaxKind) -> bool {
2006         match kind {
2007             NAME_REF => true,
2008             _ => false,
2009         }
2010     }
2011     fn cast(syntax: SyntaxNode) -> Option<Self> {
2012         if Self::can_cast(syntax.kind()) {
2013             Some(Self { syntax })
2014         } else {
2015             None
2016         }
2017     }
2018     fn syntax(&self) -> &SyntaxNode {
2019         &self.syntax
2020     }
2021 }
2022 impl NameRef {}
2023 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2024 pub struct NeverType {
2025     pub(crate) syntax: SyntaxNode,
2026 }
2027 impl AstNode for NeverType {
2028     fn can_cast(kind: SyntaxKind) -> bool {
2029         match kind {
2030             NEVER_TYPE => true,
2031             _ => false,
2032         }
2033     }
2034     fn cast(syntax: SyntaxNode) -> Option<Self> {
2035         if Self::can_cast(syntax.kind()) {
2036             Some(Self { syntax })
2037         } else {
2038             None
2039         }
2040     }
2041     fn syntax(&self) -> &SyntaxNode {
2042         &self.syntax
2043     }
2044 }
2045 impl NeverType {}
2046 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2047 pub enum NominalDef {
2048     StructDef(StructDef),
2049     EnumDef(EnumDef),
2050     UnionDef(UnionDef),
2051 }
2052 impl From<StructDef> for NominalDef {
2053     fn from(node: StructDef) -> NominalDef {
2054         NominalDef::StructDef(node)
2055     }
2056 }
2057 impl From<EnumDef> for NominalDef {
2058     fn from(node: EnumDef) -> NominalDef {
2059         NominalDef::EnumDef(node)
2060     }
2061 }
2062 impl From<UnionDef> for NominalDef {
2063     fn from(node: UnionDef) -> NominalDef {
2064         NominalDef::UnionDef(node)
2065     }
2066 }
2067 impl AstNode for NominalDef {
2068     fn can_cast(kind: SyntaxKind) -> bool {
2069         match kind {
2070             STRUCT_DEF | ENUM_DEF | UNION_DEF => true,
2071             _ => false,
2072         }
2073     }
2074     fn cast(syntax: SyntaxNode) -> Option<Self> {
2075         let res = match syntax.kind() {
2076             STRUCT_DEF => NominalDef::StructDef(StructDef { syntax }),
2077             ENUM_DEF => NominalDef::EnumDef(EnumDef { syntax }),
2078             UNION_DEF => NominalDef::UnionDef(UnionDef { syntax }),
2079             _ => return None,
2080         };
2081         Some(res)
2082     }
2083     fn syntax(&self) -> &SyntaxNode {
2084         match self {
2085             NominalDef::StructDef(it) => &it.syntax,
2086             NominalDef::EnumDef(it) => &it.syntax,
2087             NominalDef::UnionDef(it) => &it.syntax,
2088         }
2089     }
2090 }
2091 impl ast::NameOwner for NominalDef {}
2092 impl ast::TypeParamsOwner for NominalDef {}
2093 impl ast::AttrsOwner for NominalDef {}
2094 impl NominalDef {}
2095 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2096 pub struct Param {
2097     pub(crate) syntax: SyntaxNode,
2098 }
2099 impl AstNode for Param {
2100     fn can_cast(kind: SyntaxKind) -> bool {
2101         match kind {
2102             PARAM => true,
2103             _ => false,
2104         }
2105     }
2106     fn cast(syntax: SyntaxNode) -> Option<Self> {
2107         if Self::can_cast(syntax.kind()) {
2108             Some(Self { syntax })
2109         } else {
2110             None
2111         }
2112     }
2113     fn syntax(&self) -> &SyntaxNode {
2114         &self.syntax
2115     }
2116 }
2117 impl ast::TypeAscriptionOwner for Param {}
2118 impl ast::AttrsOwner for Param {}
2119 impl Param {
2120     pub fn pat(&self) -> Option<Pat> {
2121         AstChildren::new(&self.syntax).next()
2122     }
2123 }
2124 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2125 pub struct ParamList {
2126     pub(crate) syntax: SyntaxNode,
2127 }
2128 impl AstNode for ParamList {
2129     fn can_cast(kind: SyntaxKind) -> bool {
2130         match kind {
2131             PARAM_LIST => true,
2132             _ => false,
2133         }
2134     }
2135     fn cast(syntax: SyntaxNode) -> Option<Self> {
2136         if Self::can_cast(syntax.kind()) {
2137             Some(Self { syntax })
2138         } else {
2139             None
2140         }
2141     }
2142     fn syntax(&self) -> &SyntaxNode {
2143         &self.syntax
2144     }
2145 }
2146 impl ParamList {
2147     pub fn params(&self) -> AstChildren<Param> {
2148         AstChildren::new(&self.syntax)
2149     }
2150     pub fn self_param(&self) -> Option<SelfParam> {
2151         AstChildren::new(&self.syntax).next()
2152     }
2153 }
2154 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2155 pub struct ParenExpr {
2156     pub(crate) syntax: SyntaxNode,
2157 }
2158 impl AstNode for ParenExpr {
2159     fn can_cast(kind: SyntaxKind) -> bool {
2160         match kind {
2161             PAREN_EXPR => true,
2162             _ => false,
2163         }
2164     }
2165     fn cast(syntax: SyntaxNode) -> Option<Self> {
2166         if Self::can_cast(syntax.kind()) {
2167             Some(Self { syntax })
2168         } else {
2169             None
2170         }
2171     }
2172     fn syntax(&self) -> &SyntaxNode {
2173         &self.syntax
2174     }
2175 }
2176 impl ParenExpr {
2177     pub fn expr(&self) -> Option<Expr> {
2178         AstChildren::new(&self.syntax).next()
2179     }
2180 }
2181 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2182 pub struct ParenType {
2183     pub(crate) syntax: SyntaxNode,
2184 }
2185 impl AstNode for ParenType {
2186     fn can_cast(kind: SyntaxKind) -> bool {
2187         match kind {
2188             PAREN_TYPE => true,
2189             _ => false,
2190         }
2191     }
2192     fn cast(syntax: SyntaxNode) -> Option<Self> {
2193         if Self::can_cast(syntax.kind()) {
2194             Some(Self { syntax })
2195         } else {
2196             None
2197         }
2198     }
2199     fn syntax(&self) -> &SyntaxNode {
2200         &self.syntax
2201     }
2202 }
2203 impl ParenType {
2204     pub fn type_ref(&self) -> Option<TypeRef> {
2205         AstChildren::new(&self.syntax).next()
2206     }
2207 }
2208 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2209 pub enum Pat {
2210     RefPat(RefPat),
2211     BoxPat(BoxPat),
2212     BindPat(BindPat),
2213     PlaceholderPat(PlaceholderPat),
2214     DotDotPat(DotDotPat),
2215     PathPat(PathPat),
2216     RecordPat(RecordPat),
2217     TupleStructPat(TupleStructPat),
2218     TuplePat(TuplePat),
2219     SlicePat(SlicePat),
2220     RangePat(RangePat),
2221     LiteralPat(LiteralPat),
2222 }
2223 impl From<RefPat> for Pat {
2224     fn from(node: RefPat) -> Pat {
2225         Pat::RefPat(node)
2226     }
2227 }
2228 impl From<BoxPat> for Pat {
2229     fn from(node: BoxPat) -> Pat {
2230         Pat::BoxPat(node)
2231     }
2232 }
2233 impl From<BindPat> for Pat {
2234     fn from(node: BindPat) -> Pat {
2235         Pat::BindPat(node)
2236     }
2237 }
2238 impl From<PlaceholderPat> for Pat {
2239     fn from(node: PlaceholderPat) -> Pat {
2240         Pat::PlaceholderPat(node)
2241     }
2242 }
2243 impl From<DotDotPat> for Pat {
2244     fn from(node: DotDotPat) -> Pat {
2245         Pat::DotDotPat(node)
2246     }
2247 }
2248 impl From<PathPat> for Pat {
2249     fn from(node: PathPat) -> Pat {
2250         Pat::PathPat(node)
2251     }
2252 }
2253 impl From<RecordPat> for Pat {
2254     fn from(node: RecordPat) -> Pat {
2255         Pat::RecordPat(node)
2256     }
2257 }
2258 impl From<TupleStructPat> for Pat {
2259     fn from(node: TupleStructPat) -> Pat {
2260         Pat::TupleStructPat(node)
2261     }
2262 }
2263 impl From<TuplePat> for Pat {
2264     fn from(node: TuplePat) -> Pat {
2265         Pat::TuplePat(node)
2266     }
2267 }
2268 impl From<SlicePat> for Pat {
2269     fn from(node: SlicePat) -> Pat {
2270         Pat::SlicePat(node)
2271     }
2272 }
2273 impl From<RangePat> for Pat {
2274     fn from(node: RangePat) -> Pat {
2275         Pat::RangePat(node)
2276     }
2277 }
2278 impl From<LiteralPat> for Pat {
2279     fn from(node: LiteralPat) -> Pat {
2280         Pat::LiteralPat(node)
2281     }
2282 }
2283 impl AstNode for Pat {
2284     fn can_cast(kind: SyntaxKind) -> bool {
2285         match kind {
2286             REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT | PATH_PAT
2287             | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT | LITERAL_PAT => {
2288                 true
2289             }
2290             _ => false,
2291         }
2292     }
2293     fn cast(syntax: SyntaxNode) -> Option<Self> {
2294         let res = match syntax.kind() {
2295             REF_PAT => Pat::RefPat(RefPat { syntax }),
2296             BOX_PAT => Pat::BoxPat(BoxPat { syntax }),
2297             BIND_PAT => Pat::BindPat(BindPat { syntax }),
2298             PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }),
2299             DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }),
2300             PATH_PAT => Pat::PathPat(PathPat { syntax }),
2301             RECORD_PAT => Pat::RecordPat(RecordPat { syntax }),
2302             TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }),
2303             TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }),
2304             SLICE_PAT => Pat::SlicePat(SlicePat { syntax }),
2305             RANGE_PAT => Pat::RangePat(RangePat { syntax }),
2306             LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }),
2307             _ => return None,
2308         };
2309         Some(res)
2310     }
2311     fn syntax(&self) -> &SyntaxNode {
2312         match self {
2313             Pat::RefPat(it) => &it.syntax,
2314             Pat::BoxPat(it) => &it.syntax,
2315             Pat::BindPat(it) => &it.syntax,
2316             Pat::PlaceholderPat(it) => &it.syntax,
2317             Pat::DotDotPat(it) => &it.syntax,
2318             Pat::PathPat(it) => &it.syntax,
2319             Pat::RecordPat(it) => &it.syntax,
2320             Pat::TupleStructPat(it) => &it.syntax,
2321             Pat::TuplePat(it) => &it.syntax,
2322             Pat::SlicePat(it) => &it.syntax,
2323             Pat::RangePat(it) => &it.syntax,
2324             Pat::LiteralPat(it) => &it.syntax,
2325         }
2326     }
2327 }
2328 impl Pat {}
2329 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2330 pub struct Path {
2331     pub(crate) syntax: SyntaxNode,
2332 }
2333 impl AstNode for Path {
2334     fn can_cast(kind: SyntaxKind) -> bool {
2335         match kind {
2336             PATH => true,
2337             _ => false,
2338         }
2339     }
2340     fn cast(syntax: SyntaxNode) -> Option<Self> {
2341         if Self::can_cast(syntax.kind()) {
2342             Some(Self { syntax })
2343         } else {
2344             None
2345         }
2346     }
2347     fn syntax(&self) -> &SyntaxNode {
2348         &self.syntax
2349     }
2350 }
2351 impl Path {
2352     pub fn segment(&self) -> Option<PathSegment> {
2353         AstChildren::new(&self.syntax).next()
2354     }
2355     pub fn qualifier(&self) -> Option<Path> {
2356         AstChildren::new(&self.syntax).next()
2357     }
2358 }
2359 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2360 pub struct PathExpr {
2361     pub(crate) syntax: SyntaxNode,
2362 }
2363 impl AstNode for PathExpr {
2364     fn can_cast(kind: SyntaxKind) -> bool {
2365         match kind {
2366             PATH_EXPR => true,
2367             _ => false,
2368         }
2369     }
2370     fn cast(syntax: SyntaxNode) -> Option<Self> {
2371         if Self::can_cast(syntax.kind()) {
2372             Some(Self { syntax })
2373         } else {
2374             None
2375         }
2376     }
2377     fn syntax(&self) -> &SyntaxNode {
2378         &self.syntax
2379     }
2380 }
2381 impl PathExpr {
2382     pub fn path(&self) -> Option<Path> {
2383         AstChildren::new(&self.syntax).next()
2384     }
2385 }
2386 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2387 pub struct PathPat {
2388     pub(crate) syntax: SyntaxNode,
2389 }
2390 impl AstNode for PathPat {
2391     fn can_cast(kind: SyntaxKind) -> bool {
2392         match kind {
2393             PATH_PAT => true,
2394             _ => false,
2395         }
2396     }
2397     fn cast(syntax: SyntaxNode) -> Option<Self> {
2398         if Self::can_cast(syntax.kind()) {
2399             Some(Self { syntax })
2400         } else {
2401             None
2402         }
2403     }
2404     fn syntax(&self) -> &SyntaxNode {
2405         &self.syntax
2406     }
2407 }
2408 impl PathPat {
2409     pub fn path(&self) -> Option<Path> {
2410         AstChildren::new(&self.syntax).next()
2411     }
2412 }
2413 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2414 pub struct PathSegment {
2415     pub(crate) syntax: SyntaxNode,
2416 }
2417 impl AstNode for PathSegment {
2418     fn can_cast(kind: SyntaxKind) -> bool {
2419         match kind {
2420             PATH_SEGMENT => true,
2421             _ => false,
2422         }
2423     }
2424     fn cast(syntax: SyntaxNode) -> Option<Self> {
2425         if Self::can_cast(syntax.kind()) {
2426             Some(Self { syntax })
2427         } else {
2428             None
2429         }
2430     }
2431     fn syntax(&self) -> &SyntaxNode {
2432         &self.syntax
2433     }
2434 }
2435 impl PathSegment {
2436     pub fn name_ref(&self) -> Option<NameRef> {
2437         AstChildren::new(&self.syntax).next()
2438     }
2439     pub fn type_arg_list(&self) -> Option<TypeArgList> {
2440         AstChildren::new(&self.syntax).next()
2441     }
2442     pub fn param_list(&self) -> Option<ParamList> {
2443         AstChildren::new(&self.syntax).next()
2444     }
2445     pub fn ret_type(&self) -> Option<RetType> {
2446         AstChildren::new(&self.syntax).next()
2447     }
2448     pub fn path_type(&self) -> Option<PathType> {
2449         AstChildren::new(&self.syntax).next()
2450     }
2451 }
2452 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2453 pub struct PathType {
2454     pub(crate) syntax: SyntaxNode,
2455 }
2456 impl AstNode for PathType {
2457     fn can_cast(kind: SyntaxKind) -> bool {
2458         match kind {
2459             PATH_TYPE => true,
2460             _ => false,
2461         }
2462     }
2463     fn cast(syntax: SyntaxNode) -> Option<Self> {
2464         if Self::can_cast(syntax.kind()) {
2465             Some(Self { syntax })
2466         } else {
2467             None
2468         }
2469     }
2470     fn syntax(&self) -> &SyntaxNode {
2471         &self.syntax
2472     }
2473 }
2474 impl PathType {
2475     pub fn path(&self) -> Option<Path> {
2476         AstChildren::new(&self.syntax).next()
2477     }
2478 }
2479 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2480 pub struct PlaceholderPat {
2481     pub(crate) syntax: SyntaxNode,
2482 }
2483 impl AstNode for PlaceholderPat {
2484     fn can_cast(kind: SyntaxKind) -> bool {
2485         match kind {
2486             PLACEHOLDER_PAT => true,
2487             _ => false,
2488         }
2489     }
2490     fn cast(syntax: SyntaxNode) -> Option<Self> {
2491         if Self::can_cast(syntax.kind()) {
2492             Some(Self { syntax })
2493         } else {
2494             None
2495         }
2496     }
2497     fn syntax(&self) -> &SyntaxNode {
2498         &self.syntax
2499     }
2500 }
2501 impl PlaceholderPat {}
2502 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2503 pub struct PlaceholderType {
2504     pub(crate) syntax: SyntaxNode,
2505 }
2506 impl AstNode for PlaceholderType {
2507     fn can_cast(kind: SyntaxKind) -> bool {
2508         match kind {
2509             PLACEHOLDER_TYPE => true,
2510             _ => false,
2511         }
2512     }
2513     fn cast(syntax: SyntaxNode) -> Option<Self> {
2514         if Self::can_cast(syntax.kind()) {
2515             Some(Self { syntax })
2516         } else {
2517             None
2518         }
2519     }
2520     fn syntax(&self) -> &SyntaxNode {
2521         &self.syntax
2522     }
2523 }
2524 impl PlaceholderType {}
2525 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2526 pub struct PointerType {
2527     pub(crate) syntax: SyntaxNode,
2528 }
2529 impl AstNode for PointerType {
2530     fn can_cast(kind: SyntaxKind) -> bool {
2531         match kind {
2532             POINTER_TYPE => true,
2533             _ => false,
2534         }
2535     }
2536     fn cast(syntax: SyntaxNode) -> Option<Self> {
2537         if Self::can_cast(syntax.kind()) {
2538             Some(Self { syntax })
2539         } else {
2540             None
2541         }
2542     }
2543     fn syntax(&self) -> &SyntaxNode {
2544         &self.syntax
2545     }
2546 }
2547 impl PointerType {
2548     pub fn type_ref(&self) -> Option<TypeRef> {
2549         AstChildren::new(&self.syntax).next()
2550     }
2551 }
2552 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2553 pub struct PrefixExpr {
2554     pub(crate) syntax: SyntaxNode,
2555 }
2556 impl AstNode for PrefixExpr {
2557     fn can_cast(kind: SyntaxKind) -> bool {
2558         match kind {
2559             PREFIX_EXPR => true,
2560             _ => false,
2561         }
2562     }
2563     fn cast(syntax: SyntaxNode) -> Option<Self> {
2564         if Self::can_cast(syntax.kind()) {
2565             Some(Self { syntax })
2566         } else {
2567             None
2568         }
2569     }
2570     fn syntax(&self) -> &SyntaxNode {
2571         &self.syntax
2572     }
2573 }
2574 impl PrefixExpr {
2575     pub fn expr(&self) -> Option<Expr> {
2576         AstChildren::new(&self.syntax).next()
2577     }
2578 }
2579 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2580 pub struct RangeExpr {
2581     pub(crate) syntax: SyntaxNode,
2582 }
2583 impl AstNode for RangeExpr {
2584     fn can_cast(kind: SyntaxKind) -> bool {
2585         match kind {
2586             RANGE_EXPR => true,
2587             _ => false,
2588         }
2589     }
2590     fn cast(syntax: SyntaxNode) -> Option<Self> {
2591         if Self::can_cast(syntax.kind()) {
2592             Some(Self { syntax })
2593         } else {
2594             None
2595         }
2596     }
2597     fn syntax(&self) -> &SyntaxNode {
2598         &self.syntax
2599     }
2600 }
2601 impl RangeExpr {}
2602 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2603 pub struct RangePat {
2604     pub(crate) syntax: SyntaxNode,
2605 }
2606 impl AstNode for RangePat {
2607     fn can_cast(kind: SyntaxKind) -> bool {
2608         match kind {
2609             RANGE_PAT => true,
2610             _ => false,
2611         }
2612     }
2613     fn cast(syntax: SyntaxNode) -> Option<Self> {
2614         if Self::can_cast(syntax.kind()) {
2615             Some(Self { syntax })
2616         } else {
2617             None
2618         }
2619     }
2620     fn syntax(&self) -> &SyntaxNode {
2621         &self.syntax
2622     }
2623 }
2624 impl RangePat {}
2625 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2626 pub struct RecordField {
2627     pub(crate) syntax: SyntaxNode,
2628 }
2629 impl AstNode for RecordField {
2630     fn can_cast(kind: SyntaxKind) -> bool {
2631         match kind {
2632             RECORD_FIELD => true,
2633             _ => false,
2634         }
2635     }
2636     fn cast(syntax: SyntaxNode) -> Option<Self> {
2637         if Self::can_cast(syntax.kind()) {
2638             Some(Self { syntax })
2639         } else {
2640             None
2641         }
2642     }
2643     fn syntax(&self) -> &SyntaxNode {
2644         &self.syntax
2645     }
2646 }
2647 impl RecordField {
2648     pub fn name_ref(&self) -> Option<NameRef> {
2649         AstChildren::new(&self.syntax).next()
2650     }
2651     pub fn expr(&self) -> Option<Expr> {
2652         AstChildren::new(&self.syntax).next()
2653     }
2654 }
2655 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2656 pub struct RecordFieldDef {
2657     pub(crate) syntax: SyntaxNode,
2658 }
2659 impl AstNode for RecordFieldDef {
2660     fn can_cast(kind: SyntaxKind) -> bool {
2661         match kind {
2662             RECORD_FIELD_DEF => true,
2663             _ => false,
2664         }
2665     }
2666     fn cast(syntax: SyntaxNode) -> Option<Self> {
2667         if Self::can_cast(syntax.kind()) {
2668             Some(Self { syntax })
2669         } else {
2670             None
2671         }
2672     }
2673     fn syntax(&self) -> &SyntaxNode {
2674         &self.syntax
2675     }
2676 }
2677 impl ast::VisibilityOwner for RecordFieldDef {}
2678 impl ast::NameOwner for RecordFieldDef {}
2679 impl ast::AttrsOwner for RecordFieldDef {}
2680 impl ast::DocCommentsOwner for RecordFieldDef {}
2681 impl ast::TypeAscriptionOwner for RecordFieldDef {}
2682 impl RecordFieldDef {}
2683 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2684 pub struct RecordFieldDefList {
2685     pub(crate) syntax: SyntaxNode,
2686 }
2687 impl AstNode for RecordFieldDefList {
2688     fn can_cast(kind: SyntaxKind) -> bool {
2689         match kind {
2690             RECORD_FIELD_DEF_LIST => true,
2691             _ => false,
2692         }
2693     }
2694     fn cast(syntax: SyntaxNode) -> Option<Self> {
2695         if Self::can_cast(syntax.kind()) {
2696             Some(Self { syntax })
2697         } else {
2698             None
2699         }
2700     }
2701     fn syntax(&self) -> &SyntaxNode {
2702         &self.syntax
2703     }
2704 }
2705 impl RecordFieldDefList {
2706     pub fn fields(&self) -> AstChildren<RecordFieldDef> {
2707         AstChildren::new(&self.syntax)
2708     }
2709 }
2710 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2711 pub struct RecordFieldList {
2712     pub(crate) syntax: SyntaxNode,
2713 }
2714 impl AstNode for RecordFieldList {
2715     fn can_cast(kind: SyntaxKind) -> bool {
2716         match kind {
2717             RECORD_FIELD_LIST => true,
2718             _ => false,
2719         }
2720     }
2721     fn cast(syntax: SyntaxNode) -> Option<Self> {
2722         if Self::can_cast(syntax.kind()) {
2723             Some(Self { syntax })
2724         } else {
2725             None
2726         }
2727     }
2728     fn syntax(&self) -> &SyntaxNode {
2729         &self.syntax
2730     }
2731 }
2732 impl RecordFieldList {
2733     pub fn fields(&self) -> AstChildren<RecordField> {
2734         AstChildren::new(&self.syntax)
2735     }
2736     pub fn spread(&self) -> Option<Expr> {
2737         AstChildren::new(&self.syntax).next()
2738     }
2739 }
2740 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2741 pub struct RecordFieldPat {
2742     pub(crate) syntax: SyntaxNode,
2743 }
2744 impl AstNode for RecordFieldPat {
2745     fn can_cast(kind: SyntaxKind) -> bool {
2746         match kind {
2747             RECORD_FIELD_PAT => true,
2748             _ => false,
2749         }
2750     }
2751     fn cast(syntax: SyntaxNode) -> Option<Self> {
2752         if Self::can_cast(syntax.kind()) {
2753             Some(Self { syntax })
2754         } else {
2755             None
2756         }
2757     }
2758     fn syntax(&self) -> &SyntaxNode {
2759         &self.syntax
2760     }
2761 }
2762 impl ast::NameOwner for RecordFieldPat {}
2763 impl RecordFieldPat {
2764     pub fn pat(&self) -> Option<Pat> {
2765         AstChildren::new(&self.syntax).next()
2766     }
2767 }
2768 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2769 pub struct RecordFieldPatList {
2770     pub(crate) syntax: SyntaxNode,
2771 }
2772 impl AstNode for RecordFieldPatList {
2773     fn can_cast(kind: SyntaxKind) -> bool {
2774         match kind {
2775             RECORD_FIELD_PAT_LIST => true,
2776             _ => false,
2777         }
2778     }
2779     fn cast(syntax: SyntaxNode) -> Option<Self> {
2780         if Self::can_cast(syntax.kind()) {
2781             Some(Self { syntax })
2782         } else {
2783             None
2784         }
2785     }
2786     fn syntax(&self) -> &SyntaxNode {
2787         &self.syntax
2788     }
2789 }
2790 impl RecordFieldPatList {
2791     pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> {
2792         AstChildren::new(&self.syntax)
2793     }
2794     pub fn bind_pats(&self) -> AstChildren<BindPat> {
2795         AstChildren::new(&self.syntax)
2796     }
2797 }
2798 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2799 pub struct RecordLit {
2800     pub(crate) syntax: SyntaxNode,
2801 }
2802 impl AstNode for RecordLit {
2803     fn can_cast(kind: SyntaxKind) -> bool {
2804         match kind {
2805             RECORD_LIT => true,
2806             _ => false,
2807         }
2808     }
2809     fn cast(syntax: SyntaxNode) -> Option<Self> {
2810         if Self::can_cast(syntax.kind()) {
2811             Some(Self { syntax })
2812         } else {
2813             None
2814         }
2815     }
2816     fn syntax(&self) -> &SyntaxNode {
2817         &self.syntax
2818     }
2819 }
2820 impl RecordLit {
2821     pub fn path(&self) -> Option<Path> {
2822         AstChildren::new(&self.syntax).next()
2823     }
2824     pub fn record_field_list(&self) -> Option<RecordFieldList> {
2825         AstChildren::new(&self.syntax).next()
2826     }
2827 }
2828 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2829 pub struct RecordPat {
2830     pub(crate) syntax: SyntaxNode,
2831 }
2832 impl AstNode for RecordPat {
2833     fn can_cast(kind: SyntaxKind) -> bool {
2834         match kind {
2835             RECORD_PAT => true,
2836             _ => false,
2837         }
2838     }
2839     fn cast(syntax: SyntaxNode) -> Option<Self> {
2840         if Self::can_cast(syntax.kind()) {
2841             Some(Self { syntax })
2842         } else {
2843             None
2844         }
2845     }
2846     fn syntax(&self) -> &SyntaxNode {
2847         &self.syntax
2848     }
2849 }
2850 impl RecordPat {
2851     pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> {
2852         AstChildren::new(&self.syntax).next()
2853     }
2854     pub fn path(&self) -> Option<Path> {
2855         AstChildren::new(&self.syntax).next()
2856     }
2857 }
2858 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2859 pub struct RefExpr {
2860     pub(crate) syntax: SyntaxNode,
2861 }
2862 impl AstNode for RefExpr {
2863     fn can_cast(kind: SyntaxKind) -> bool {
2864         match kind {
2865             REF_EXPR => true,
2866             _ => false,
2867         }
2868     }
2869     fn cast(syntax: SyntaxNode) -> Option<Self> {
2870         if Self::can_cast(syntax.kind()) {
2871             Some(Self { syntax })
2872         } else {
2873             None
2874         }
2875     }
2876     fn syntax(&self) -> &SyntaxNode {
2877         &self.syntax
2878     }
2879 }
2880 impl RefExpr {
2881     pub fn expr(&self) -> Option<Expr> {
2882         AstChildren::new(&self.syntax).next()
2883     }
2884 }
2885 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2886 pub struct RefPat {
2887     pub(crate) syntax: SyntaxNode,
2888 }
2889 impl AstNode for RefPat {
2890     fn can_cast(kind: SyntaxKind) -> bool {
2891         match kind {
2892             REF_PAT => true,
2893             _ => false,
2894         }
2895     }
2896     fn cast(syntax: SyntaxNode) -> Option<Self> {
2897         if Self::can_cast(syntax.kind()) {
2898             Some(Self { syntax })
2899         } else {
2900             None
2901         }
2902     }
2903     fn syntax(&self) -> &SyntaxNode {
2904         &self.syntax
2905     }
2906 }
2907 impl RefPat {
2908     pub fn pat(&self) -> Option<Pat> {
2909         AstChildren::new(&self.syntax).next()
2910     }
2911 }
2912 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2913 pub struct ReferenceType {
2914     pub(crate) syntax: SyntaxNode,
2915 }
2916 impl AstNode for ReferenceType {
2917     fn can_cast(kind: SyntaxKind) -> bool {
2918         match kind {
2919             REFERENCE_TYPE => true,
2920             _ => false,
2921         }
2922     }
2923     fn cast(syntax: SyntaxNode) -> Option<Self> {
2924         if Self::can_cast(syntax.kind()) {
2925             Some(Self { syntax })
2926         } else {
2927             None
2928         }
2929     }
2930     fn syntax(&self) -> &SyntaxNode {
2931         &self.syntax
2932     }
2933 }
2934 impl ReferenceType {
2935     pub fn type_ref(&self) -> Option<TypeRef> {
2936         AstChildren::new(&self.syntax).next()
2937     }
2938 }
2939 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2940 pub struct RetType {
2941     pub(crate) syntax: SyntaxNode,
2942 }
2943 impl AstNode for RetType {
2944     fn can_cast(kind: SyntaxKind) -> bool {
2945         match kind {
2946             RET_TYPE => true,
2947             _ => false,
2948         }
2949     }
2950     fn cast(syntax: SyntaxNode) -> Option<Self> {
2951         if Self::can_cast(syntax.kind()) {
2952             Some(Self { syntax })
2953         } else {
2954             None
2955         }
2956     }
2957     fn syntax(&self) -> &SyntaxNode {
2958         &self.syntax
2959     }
2960 }
2961 impl RetType {
2962     pub fn type_ref(&self) -> Option<TypeRef> {
2963         AstChildren::new(&self.syntax).next()
2964     }
2965 }
2966 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2967 pub struct ReturnExpr {
2968     pub(crate) syntax: SyntaxNode,
2969 }
2970 impl AstNode for ReturnExpr {
2971     fn can_cast(kind: SyntaxKind) -> bool {
2972         match kind {
2973             RETURN_EXPR => true,
2974             _ => false,
2975         }
2976     }
2977     fn cast(syntax: SyntaxNode) -> Option<Self> {
2978         if Self::can_cast(syntax.kind()) {
2979             Some(Self { syntax })
2980         } else {
2981             None
2982         }
2983     }
2984     fn syntax(&self) -> &SyntaxNode {
2985         &self.syntax
2986     }
2987 }
2988 impl ReturnExpr {
2989     pub fn expr(&self) -> Option<Expr> {
2990         AstChildren::new(&self.syntax).next()
2991     }
2992 }
2993 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2994 pub struct SelfParam {
2995     pub(crate) syntax: SyntaxNode,
2996 }
2997 impl AstNode for SelfParam {
2998     fn can_cast(kind: SyntaxKind) -> bool {
2999         match kind {
3000             SELF_PARAM => true,
3001             _ => false,
3002         }
3003     }
3004     fn cast(syntax: SyntaxNode) -> Option<Self> {
3005         if Self::can_cast(syntax.kind()) {
3006             Some(Self { syntax })
3007         } else {
3008             None
3009         }
3010     }
3011     fn syntax(&self) -> &SyntaxNode {
3012         &self.syntax
3013     }
3014 }
3015 impl ast::TypeAscriptionOwner for SelfParam {}
3016 impl ast::AttrsOwner for SelfParam {}
3017 impl SelfParam {}
3018 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3019 pub struct SlicePat {
3020     pub(crate) syntax: SyntaxNode,
3021 }
3022 impl AstNode for SlicePat {
3023     fn can_cast(kind: SyntaxKind) -> bool {
3024         match kind {
3025             SLICE_PAT => true,
3026             _ => false,
3027         }
3028     }
3029     fn cast(syntax: SyntaxNode) -> Option<Self> {
3030         if Self::can_cast(syntax.kind()) {
3031             Some(Self { syntax })
3032         } else {
3033             None
3034         }
3035     }
3036     fn syntax(&self) -> &SyntaxNode {
3037         &self.syntax
3038     }
3039 }
3040 impl SlicePat {}
3041 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3042 pub struct SliceType {
3043     pub(crate) syntax: SyntaxNode,
3044 }
3045 impl AstNode for SliceType {
3046     fn can_cast(kind: SyntaxKind) -> bool {
3047         match kind {
3048             SLICE_TYPE => true,
3049             _ => false,
3050         }
3051     }
3052     fn cast(syntax: SyntaxNode) -> Option<Self> {
3053         if Self::can_cast(syntax.kind()) {
3054             Some(Self { syntax })
3055         } else {
3056             None
3057         }
3058     }
3059     fn syntax(&self) -> &SyntaxNode {
3060         &self.syntax
3061     }
3062 }
3063 impl SliceType {
3064     pub fn type_ref(&self) -> Option<TypeRef> {
3065         AstChildren::new(&self.syntax).next()
3066     }
3067 }
3068 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3069 pub struct SourceFile {
3070     pub(crate) syntax: SyntaxNode,
3071 }
3072 impl AstNode for SourceFile {
3073     fn can_cast(kind: SyntaxKind) -> bool {
3074         match kind {
3075             SOURCE_FILE => true,
3076             _ => false,
3077         }
3078     }
3079     fn cast(syntax: SyntaxNode) -> Option<Self> {
3080         if Self::can_cast(syntax.kind()) {
3081             Some(Self { syntax })
3082         } else {
3083             None
3084         }
3085     }
3086     fn syntax(&self) -> &SyntaxNode {
3087         &self.syntax
3088     }
3089 }
3090 impl ast::ModuleItemOwner for SourceFile {}
3091 impl ast::FnDefOwner for SourceFile {}
3092 impl SourceFile {
3093     pub fn modules(&self) -> AstChildren<Module> {
3094         AstChildren::new(&self.syntax)
3095     }
3096 }
3097 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3098 pub struct StaticDef {
3099     pub(crate) syntax: SyntaxNode,
3100 }
3101 impl AstNode for StaticDef {
3102     fn can_cast(kind: SyntaxKind) -> bool {
3103         match kind {
3104             STATIC_DEF => true,
3105             _ => false,
3106         }
3107     }
3108     fn cast(syntax: SyntaxNode) -> Option<Self> {
3109         if Self::can_cast(syntax.kind()) {
3110             Some(Self { syntax })
3111         } else {
3112             None
3113         }
3114     }
3115     fn syntax(&self) -> &SyntaxNode {
3116         &self.syntax
3117     }
3118 }
3119 impl ast::VisibilityOwner for StaticDef {}
3120 impl ast::NameOwner for StaticDef {}
3121 impl ast::TypeParamsOwner for StaticDef {}
3122 impl ast::AttrsOwner for StaticDef {}
3123 impl ast::DocCommentsOwner for StaticDef {}
3124 impl ast::TypeAscriptionOwner for StaticDef {}
3125 impl StaticDef {
3126     pub fn body(&self) -> Option<Expr> {
3127         AstChildren::new(&self.syntax).next()
3128     }
3129 }
3130 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3131 pub enum Stmt {
3132     ExprStmt(ExprStmt),
3133     LetStmt(LetStmt),
3134 }
3135 impl From<ExprStmt> for Stmt {
3136     fn from(node: ExprStmt) -> Stmt {
3137         Stmt::ExprStmt(node)
3138     }
3139 }
3140 impl From<LetStmt> for Stmt {
3141     fn from(node: LetStmt) -> Stmt {
3142         Stmt::LetStmt(node)
3143     }
3144 }
3145 impl AstNode for Stmt {
3146     fn can_cast(kind: SyntaxKind) -> bool {
3147         match kind {
3148             EXPR_STMT | LET_STMT => true,
3149             _ => false,
3150         }
3151     }
3152     fn cast(syntax: SyntaxNode) -> Option<Self> {
3153         let res = match syntax.kind() {
3154             EXPR_STMT => Stmt::ExprStmt(ExprStmt { syntax }),
3155             LET_STMT => Stmt::LetStmt(LetStmt { syntax }),
3156             _ => return None,
3157         };
3158         Some(res)
3159     }
3160     fn syntax(&self) -> &SyntaxNode {
3161         match self {
3162             Stmt::ExprStmt(it) => &it.syntax,
3163             Stmt::LetStmt(it) => &it.syntax,
3164         }
3165     }
3166 }
3167 impl Stmt {}
3168 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3169 pub struct StructDef {
3170     pub(crate) syntax: SyntaxNode,
3171 }
3172 impl AstNode for StructDef {
3173     fn can_cast(kind: SyntaxKind) -> bool {
3174         match kind {
3175             STRUCT_DEF => true,
3176             _ => false,
3177         }
3178     }
3179     fn cast(syntax: SyntaxNode) -> Option<Self> {
3180         if Self::can_cast(syntax.kind()) {
3181             Some(Self { syntax })
3182         } else {
3183             None
3184         }
3185     }
3186     fn syntax(&self) -> &SyntaxNode {
3187         &self.syntax
3188     }
3189 }
3190 impl ast::VisibilityOwner for StructDef {}
3191 impl ast::NameOwner for StructDef {}
3192 impl ast::TypeParamsOwner for StructDef {}
3193 impl ast::AttrsOwner for StructDef {}
3194 impl ast::DocCommentsOwner for StructDef {}
3195 impl StructDef {}
3196 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3197 pub struct TokenTree {
3198     pub(crate) syntax: SyntaxNode,
3199 }
3200 impl AstNode for TokenTree {
3201     fn can_cast(kind: SyntaxKind) -> bool {
3202         match kind {
3203             TOKEN_TREE => true,
3204             _ => false,
3205         }
3206     }
3207     fn cast(syntax: SyntaxNode) -> Option<Self> {
3208         if Self::can_cast(syntax.kind()) {
3209             Some(Self { syntax })
3210         } else {
3211             None
3212         }
3213     }
3214     fn syntax(&self) -> &SyntaxNode {
3215         &self.syntax
3216     }
3217 }
3218 impl TokenTree {}
3219 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3220 pub struct TraitDef {
3221     pub(crate) syntax: SyntaxNode,
3222 }
3223 impl AstNode for TraitDef {
3224     fn can_cast(kind: SyntaxKind) -> bool {
3225         match kind {
3226             TRAIT_DEF => true,
3227             _ => false,
3228         }
3229     }
3230     fn cast(syntax: SyntaxNode) -> Option<Self> {
3231         if Self::can_cast(syntax.kind()) {
3232             Some(Self { syntax })
3233         } else {
3234             None
3235         }
3236     }
3237     fn syntax(&self) -> &SyntaxNode {
3238         &self.syntax
3239     }
3240 }
3241 impl ast::VisibilityOwner for TraitDef {}
3242 impl ast::NameOwner for TraitDef {}
3243 impl ast::AttrsOwner for TraitDef {}
3244 impl ast::DocCommentsOwner for TraitDef {}
3245 impl ast::TypeParamsOwner for TraitDef {}
3246 impl ast::TypeBoundsOwner for TraitDef {}
3247 impl TraitDef {
3248     pub fn item_list(&self) -> Option<ItemList> {
3249         AstChildren::new(&self.syntax).next()
3250     }
3251 }
3252 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3253 pub struct TryBlockExpr {
3254     pub(crate) syntax: SyntaxNode,
3255 }
3256 impl AstNode for TryBlockExpr {
3257     fn can_cast(kind: SyntaxKind) -> bool {
3258         match kind {
3259             TRY_BLOCK_EXPR => true,
3260             _ => false,
3261         }
3262     }
3263     fn cast(syntax: SyntaxNode) -> Option<Self> {
3264         if Self::can_cast(syntax.kind()) {
3265             Some(Self { syntax })
3266         } else {
3267             None
3268         }
3269     }
3270     fn syntax(&self) -> &SyntaxNode {
3271         &self.syntax
3272     }
3273 }
3274 impl TryBlockExpr {
3275     pub fn body(&self) -> Option<BlockExpr> {
3276         AstChildren::new(&self.syntax).next()
3277     }
3278 }
3279 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3280 pub struct TryExpr {
3281     pub(crate) syntax: SyntaxNode,
3282 }
3283 impl AstNode for TryExpr {
3284     fn can_cast(kind: SyntaxKind) -> bool {
3285         match kind {
3286             TRY_EXPR => true,
3287             _ => false,
3288         }
3289     }
3290     fn cast(syntax: SyntaxNode) -> Option<Self> {
3291         if Self::can_cast(syntax.kind()) {
3292             Some(Self { syntax })
3293         } else {
3294             None
3295         }
3296     }
3297     fn syntax(&self) -> &SyntaxNode {
3298         &self.syntax
3299     }
3300 }
3301 impl TryExpr {
3302     pub fn expr(&self) -> Option<Expr> {
3303         AstChildren::new(&self.syntax).next()
3304     }
3305 }
3306 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3307 pub struct TupleExpr {
3308     pub(crate) syntax: SyntaxNode,
3309 }
3310 impl AstNode for TupleExpr {
3311     fn can_cast(kind: SyntaxKind) -> bool {
3312         match kind {
3313             TUPLE_EXPR => true,
3314             _ => false,
3315         }
3316     }
3317     fn cast(syntax: SyntaxNode) -> Option<Self> {
3318         if Self::can_cast(syntax.kind()) {
3319             Some(Self { syntax })
3320         } else {
3321             None
3322         }
3323     }
3324     fn syntax(&self) -> &SyntaxNode {
3325         &self.syntax
3326     }
3327 }
3328 impl TupleExpr {
3329     pub fn exprs(&self) -> AstChildren<Expr> {
3330         AstChildren::new(&self.syntax)
3331     }
3332 }
3333 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3334 pub struct TupleFieldDef {
3335     pub(crate) syntax: SyntaxNode,
3336 }
3337 impl AstNode for TupleFieldDef {
3338     fn can_cast(kind: SyntaxKind) -> bool {
3339         match kind {
3340             TUPLE_FIELD_DEF => true,
3341             _ => false,
3342         }
3343     }
3344     fn cast(syntax: SyntaxNode) -> Option<Self> {
3345         if Self::can_cast(syntax.kind()) {
3346             Some(Self { syntax })
3347         } else {
3348             None
3349         }
3350     }
3351     fn syntax(&self) -> &SyntaxNode {
3352         &self.syntax
3353     }
3354 }
3355 impl ast::VisibilityOwner for TupleFieldDef {}
3356 impl ast::AttrsOwner for TupleFieldDef {}
3357 impl TupleFieldDef {
3358     pub fn type_ref(&self) -> Option<TypeRef> {
3359         AstChildren::new(&self.syntax).next()
3360     }
3361 }
3362 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3363 pub struct TupleFieldDefList {
3364     pub(crate) syntax: SyntaxNode,
3365 }
3366 impl AstNode for TupleFieldDefList {
3367     fn can_cast(kind: SyntaxKind) -> bool {
3368         match kind {
3369             TUPLE_FIELD_DEF_LIST => true,
3370             _ => false,
3371         }
3372     }
3373     fn cast(syntax: SyntaxNode) -> Option<Self> {
3374         if Self::can_cast(syntax.kind()) {
3375             Some(Self { syntax })
3376         } else {
3377             None
3378         }
3379     }
3380     fn syntax(&self) -> &SyntaxNode {
3381         &self.syntax
3382     }
3383 }
3384 impl TupleFieldDefList {
3385     pub fn fields(&self) -> AstChildren<TupleFieldDef> {
3386         AstChildren::new(&self.syntax)
3387     }
3388 }
3389 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3390 pub struct TuplePat {
3391     pub(crate) syntax: SyntaxNode,
3392 }
3393 impl AstNode for TuplePat {
3394     fn can_cast(kind: SyntaxKind) -> bool {
3395         match kind {
3396             TUPLE_PAT => true,
3397             _ => false,
3398         }
3399     }
3400     fn cast(syntax: SyntaxNode) -> Option<Self> {
3401         if Self::can_cast(syntax.kind()) {
3402             Some(Self { syntax })
3403         } else {
3404             None
3405         }
3406     }
3407     fn syntax(&self) -> &SyntaxNode {
3408         &self.syntax
3409     }
3410 }
3411 impl TuplePat {
3412     pub fn args(&self) -> AstChildren<Pat> {
3413         AstChildren::new(&self.syntax)
3414     }
3415 }
3416 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3417 pub struct TupleStructPat {
3418     pub(crate) syntax: SyntaxNode,
3419 }
3420 impl AstNode for TupleStructPat {
3421     fn can_cast(kind: SyntaxKind) -> bool {
3422         match kind {
3423             TUPLE_STRUCT_PAT => true,
3424             _ => false,
3425         }
3426     }
3427     fn cast(syntax: SyntaxNode) -> Option<Self> {
3428         if Self::can_cast(syntax.kind()) {
3429             Some(Self { syntax })
3430         } else {
3431             None
3432         }
3433     }
3434     fn syntax(&self) -> &SyntaxNode {
3435         &self.syntax
3436     }
3437 }
3438 impl TupleStructPat {
3439     pub fn args(&self) -> AstChildren<Pat> {
3440         AstChildren::new(&self.syntax)
3441     }
3442     pub fn path(&self) -> Option<Path> {
3443         AstChildren::new(&self.syntax).next()
3444     }
3445 }
3446 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3447 pub struct TupleType {
3448     pub(crate) syntax: SyntaxNode,
3449 }
3450 impl AstNode for TupleType {
3451     fn can_cast(kind: SyntaxKind) -> bool {
3452         match kind {
3453             TUPLE_TYPE => true,
3454             _ => false,
3455         }
3456     }
3457     fn cast(syntax: SyntaxNode) -> Option<Self> {
3458         if Self::can_cast(syntax.kind()) {
3459             Some(Self { syntax })
3460         } else {
3461             None
3462         }
3463     }
3464     fn syntax(&self) -> &SyntaxNode {
3465         &self.syntax
3466     }
3467 }
3468 impl TupleType {
3469     pub fn fields(&self) -> AstChildren<TypeRef> {
3470         AstChildren::new(&self.syntax)
3471     }
3472 }
3473 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3474 pub struct TypeAliasDef {
3475     pub(crate) syntax: SyntaxNode,
3476 }
3477 impl AstNode for TypeAliasDef {
3478     fn can_cast(kind: SyntaxKind) -> bool {
3479         match kind {
3480             TYPE_ALIAS_DEF => true,
3481             _ => false,
3482         }
3483     }
3484     fn cast(syntax: SyntaxNode) -> Option<Self> {
3485         if Self::can_cast(syntax.kind()) {
3486             Some(Self { syntax })
3487         } else {
3488             None
3489         }
3490     }
3491     fn syntax(&self) -> &SyntaxNode {
3492         &self.syntax
3493     }
3494 }
3495 impl ast::VisibilityOwner for TypeAliasDef {}
3496 impl ast::NameOwner for TypeAliasDef {}
3497 impl ast::TypeParamsOwner for TypeAliasDef {}
3498 impl ast::AttrsOwner for TypeAliasDef {}
3499 impl ast::DocCommentsOwner for TypeAliasDef {}
3500 impl ast::TypeBoundsOwner for TypeAliasDef {}
3501 impl TypeAliasDef {
3502     pub fn type_ref(&self) -> Option<TypeRef> {
3503         AstChildren::new(&self.syntax).next()
3504     }
3505 }
3506 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3507 pub struct TypeArg {
3508     pub(crate) syntax: SyntaxNode,
3509 }
3510 impl AstNode for TypeArg {
3511     fn can_cast(kind: SyntaxKind) -> bool {
3512         match kind {
3513             TYPE_ARG => true,
3514             _ => false,
3515         }
3516     }
3517     fn cast(syntax: SyntaxNode) -> Option<Self> {
3518         if Self::can_cast(syntax.kind()) {
3519             Some(Self { syntax })
3520         } else {
3521             None
3522         }
3523     }
3524     fn syntax(&self) -> &SyntaxNode {
3525         &self.syntax
3526     }
3527 }
3528 impl TypeArg {
3529     pub fn type_ref(&self) -> Option<TypeRef> {
3530         AstChildren::new(&self.syntax).next()
3531     }
3532 }
3533 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3534 pub struct TypeArgList {
3535     pub(crate) syntax: SyntaxNode,
3536 }
3537 impl AstNode for TypeArgList {
3538     fn can_cast(kind: SyntaxKind) -> bool {
3539         match kind {
3540             TYPE_ARG_LIST => true,
3541             _ => false,
3542         }
3543     }
3544     fn cast(syntax: SyntaxNode) -> Option<Self> {
3545         if Self::can_cast(syntax.kind()) {
3546             Some(Self { syntax })
3547         } else {
3548             None
3549         }
3550     }
3551     fn syntax(&self) -> &SyntaxNode {
3552         &self.syntax
3553     }
3554 }
3555 impl TypeArgList {
3556     pub fn type_args(&self) -> AstChildren<TypeArg> {
3557         AstChildren::new(&self.syntax)
3558     }
3559     pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> {
3560         AstChildren::new(&self.syntax)
3561     }
3562     pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> {
3563         AstChildren::new(&self.syntax)
3564     }
3565 }
3566 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3567 pub struct TypeBound {
3568     pub(crate) syntax: SyntaxNode,
3569 }
3570 impl AstNode for TypeBound {
3571     fn can_cast(kind: SyntaxKind) -> bool {
3572         match kind {
3573             TYPE_BOUND => true,
3574             _ => false,
3575         }
3576     }
3577     fn cast(syntax: SyntaxNode) -> Option<Self> {
3578         if Self::can_cast(syntax.kind()) {
3579             Some(Self { syntax })
3580         } else {
3581             None
3582         }
3583     }
3584     fn syntax(&self) -> &SyntaxNode {
3585         &self.syntax
3586     }
3587 }
3588 impl TypeBound {
3589     pub fn type_ref(&self) -> Option<TypeRef> {
3590         AstChildren::new(&self.syntax).next()
3591     }
3592 }
3593 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3594 pub struct TypeBoundList {
3595     pub(crate) syntax: SyntaxNode,
3596 }
3597 impl AstNode for TypeBoundList {
3598     fn can_cast(kind: SyntaxKind) -> bool {
3599         match kind {
3600             TYPE_BOUND_LIST => true,
3601             _ => false,
3602         }
3603     }
3604     fn cast(syntax: SyntaxNode) -> Option<Self> {
3605         if Self::can_cast(syntax.kind()) {
3606             Some(Self { syntax })
3607         } else {
3608             None
3609         }
3610     }
3611     fn syntax(&self) -> &SyntaxNode {
3612         &self.syntax
3613     }
3614 }
3615 impl TypeBoundList {
3616     pub fn bounds(&self) -> AstChildren<TypeBound> {
3617         AstChildren::new(&self.syntax)
3618     }
3619 }
3620 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3621 pub struct TypeParam {
3622     pub(crate) syntax: SyntaxNode,
3623 }
3624 impl AstNode for TypeParam {
3625     fn can_cast(kind: SyntaxKind) -> bool {
3626         match kind {
3627             TYPE_PARAM => true,
3628             _ => false,
3629         }
3630     }
3631     fn cast(syntax: SyntaxNode) -> Option<Self> {
3632         if Self::can_cast(syntax.kind()) {
3633             Some(Self { syntax })
3634         } else {
3635             None
3636         }
3637     }
3638     fn syntax(&self) -> &SyntaxNode {
3639         &self.syntax
3640     }
3641 }
3642 impl ast::NameOwner for TypeParam {}
3643 impl ast::AttrsOwner for TypeParam {}
3644 impl ast::TypeBoundsOwner for TypeParam {}
3645 impl TypeParam {
3646     pub fn default_type(&self) -> Option<TypeRef> {
3647         AstChildren::new(&self.syntax).next()
3648     }
3649 }
3650 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3651 pub struct TypeParamList {
3652     pub(crate) syntax: SyntaxNode,
3653 }
3654 impl AstNode for TypeParamList {
3655     fn can_cast(kind: SyntaxKind) -> bool {
3656         match kind {
3657             TYPE_PARAM_LIST => true,
3658             _ => false,
3659         }
3660     }
3661     fn cast(syntax: SyntaxNode) -> Option<Self> {
3662         if Self::can_cast(syntax.kind()) {
3663             Some(Self { syntax })
3664         } else {
3665             None
3666         }
3667     }
3668     fn syntax(&self) -> &SyntaxNode {
3669         &self.syntax
3670     }
3671 }
3672 impl TypeParamList {
3673     pub fn type_params(&self) -> AstChildren<TypeParam> {
3674         AstChildren::new(&self.syntax)
3675     }
3676     pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> {
3677         AstChildren::new(&self.syntax)
3678     }
3679 }
3680 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3681 pub enum TypeRef {
3682     ParenType(ParenType),
3683     TupleType(TupleType),
3684     NeverType(NeverType),
3685     PathType(PathType),
3686     PointerType(PointerType),
3687     ArrayType(ArrayType),
3688     SliceType(SliceType),
3689     ReferenceType(ReferenceType),
3690     PlaceholderType(PlaceholderType),
3691     FnPointerType(FnPointerType),
3692     ForType(ForType),
3693     ImplTraitType(ImplTraitType),
3694     DynTraitType(DynTraitType),
3695 }
3696 impl From<ParenType> for TypeRef {
3697     fn from(node: ParenType) -> TypeRef {
3698         TypeRef::ParenType(node)
3699     }
3700 }
3701 impl From<TupleType> for TypeRef {
3702     fn from(node: TupleType) -> TypeRef {
3703         TypeRef::TupleType(node)
3704     }
3705 }
3706 impl From<NeverType> for TypeRef {
3707     fn from(node: NeverType) -> TypeRef {
3708         TypeRef::NeverType(node)
3709     }
3710 }
3711 impl From<PathType> for TypeRef {
3712     fn from(node: PathType) -> TypeRef {
3713         TypeRef::PathType(node)
3714     }
3715 }
3716 impl From<PointerType> for TypeRef {
3717     fn from(node: PointerType) -> TypeRef {
3718         TypeRef::PointerType(node)
3719     }
3720 }
3721 impl From<ArrayType> for TypeRef {
3722     fn from(node: ArrayType) -> TypeRef {
3723         TypeRef::ArrayType(node)
3724     }
3725 }
3726 impl From<SliceType> for TypeRef {
3727     fn from(node: SliceType) -> TypeRef {
3728         TypeRef::SliceType(node)
3729     }
3730 }
3731 impl From<ReferenceType> for TypeRef {
3732     fn from(node: ReferenceType) -> TypeRef {
3733         TypeRef::ReferenceType(node)
3734     }
3735 }
3736 impl From<PlaceholderType> for TypeRef {
3737     fn from(node: PlaceholderType) -> TypeRef {
3738         TypeRef::PlaceholderType(node)
3739     }
3740 }
3741 impl From<FnPointerType> for TypeRef {
3742     fn from(node: FnPointerType) -> TypeRef {
3743         TypeRef::FnPointerType(node)
3744     }
3745 }
3746 impl From<ForType> for TypeRef {
3747     fn from(node: ForType) -> TypeRef {
3748         TypeRef::ForType(node)
3749     }
3750 }
3751 impl From<ImplTraitType> for TypeRef {
3752     fn from(node: ImplTraitType) -> TypeRef {
3753         TypeRef::ImplTraitType(node)
3754     }
3755 }
3756 impl From<DynTraitType> for TypeRef {
3757     fn from(node: DynTraitType) -> TypeRef {
3758         TypeRef::DynTraitType(node)
3759     }
3760 }
3761 impl AstNode for TypeRef {
3762     fn can_cast(kind: SyntaxKind) -> bool {
3763         match kind {
3764             PAREN_TYPE | TUPLE_TYPE | NEVER_TYPE | PATH_TYPE | POINTER_TYPE | ARRAY_TYPE
3765             | SLICE_TYPE | REFERENCE_TYPE | PLACEHOLDER_TYPE | FN_POINTER_TYPE | FOR_TYPE
3766             | IMPL_TRAIT_TYPE | DYN_TRAIT_TYPE => true,
3767             _ => false,
3768         }
3769     }
3770     fn cast(syntax: SyntaxNode) -> Option<Self> {
3771         let res = match syntax.kind() {
3772             PAREN_TYPE => TypeRef::ParenType(ParenType { syntax }),
3773             TUPLE_TYPE => TypeRef::TupleType(TupleType { syntax }),
3774             NEVER_TYPE => TypeRef::NeverType(NeverType { syntax }),
3775             PATH_TYPE => TypeRef::PathType(PathType { syntax }),
3776             POINTER_TYPE => TypeRef::PointerType(PointerType { syntax }),
3777             ARRAY_TYPE => TypeRef::ArrayType(ArrayType { syntax }),
3778             SLICE_TYPE => TypeRef::SliceType(SliceType { syntax }),
3779             REFERENCE_TYPE => TypeRef::ReferenceType(ReferenceType { syntax }),
3780             PLACEHOLDER_TYPE => TypeRef::PlaceholderType(PlaceholderType { syntax }),
3781             FN_POINTER_TYPE => TypeRef::FnPointerType(FnPointerType { syntax }),
3782             FOR_TYPE => TypeRef::ForType(ForType { syntax }),
3783             IMPL_TRAIT_TYPE => TypeRef::ImplTraitType(ImplTraitType { syntax }),
3784             DYN_TRAIT_TYPE => TypeRef::DynTraitType(DynTraitType { syntax }),
3785             _ => return None,
3786         };
3787         Some(res)
3788     }
3789     fn syntax(&self) -> &SyntaxNode {
3790         match self {
3791             TypeRef::ParenType(it) => &it.syntax,
3792             TypeRef::TupleType(it) => &it.syntax,
3793             TypeRef::NeverType(it) => &it.syntax,
3794             TypeRef::PathType(it) => &it.syntax,
3795             TypeRef::PointerType(it) => &it.syntax,
3796             TypeRef::ArrayType(it) => &it.syntax,
3797             TypeRef::SliceType(it) => &it.syntax,
3798             TypeRef::ReferenceType(it) => &it.syntax,
3799             TypeRef::PlaceholderType(it) => &it.syntax,
3800             TypeRef::FnPointerType(it) => &it.syntax,
3801             TypeRef::ForType(it) => &it.syntax,
3802             TypeRef::ImplTraitType(it) => &it.syntax,
3803             TypeRef::DynTraitType(it) => &it.syntax,
3804         }
3805     }
3806 }
3807 impl TypeRef {}
3808 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3809 pub struct UnionDef {
3810     pub(crate) syntax: SyntaxNode,
3811 }
3812 impl AstNode for UnionDef {
3813     fn can_cast(kind: SyntaxKind) -> bool {
3814         match kind {
3815             UNION_DEF => true,
3816             _ => false,
3817         }
3818     }
3819     fn cast(syntax: SyntaxNode) -> Option<Self> {
3820         if Self::can_cast(syntax.kind()) {
3821             Some(Self { syntax })
3822         } else {
3823             None
3824         }
3825     }
3826     fn syntax(&self) -> &SyntaxNode {
3827         &self.syntax
3828     }
3829 }
3830 impl ast::VisibilityOwner for UnionDef {}
3831 impl ast::NameOwner for UnionDef {}
3832 impl ast::TypeParamsOwner for UnionDef {}
3833 impl ast::AttrsOwner for UnionDef {}
3834 impl ast::DocCommentsOwner for UnionDef {}
3835 impl UnionDef {
3836     pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> {
3837         AstChildren::new(&self.syntax).next()
3838     }
3839 }
3840 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3841 pub struct UseItem {
3842     pub(crate) syntax: SyntaxNode,
3843 }
3844 impl AstNode for UseItem {
3845     fn can_cast(kind: SyntaxKind) -> bool {
3846         match kind {
3847             USE_ITEM => true,
3848             _ => false,
3849         }
3850     }
3851     fn cast(syntax: SyntaxNode) -> Option<Self> {
3852         if Self::can_cast(syntax.kind()) {
3853             Some(Self { syntax })
3854         } else {
3855             None
3856         }
3857     }
3858     fn syntax(&self) -> &SyntaxNode {
3859         &self.syntax
3860     }
3861 }
3862 impl ast::AttrsOwner for UseItem {}
3863 impl UseItem {
3864     pub fn use_tree(&self) -> Option<UseTree> {
3865         AstChildren::new(&self.syntax).next()
3866     }
3867 }
3868 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3869 pub struct UseTree {
3870     pub(crate) syntax: SyntaxNode,
3871 }
3872 impl AstNode for UseTree {
3873     fn can_cast(kind: SyntaxKind) -> bool {
3874         match kind {
3875             USE_TREE => true,
3876             _ => false,
3877         }
3878     }
3879     fn cast(syntax: SyntaxNode) -> Option<Self> {
3880         if Self::can_cast(syntax.kind()) {
3881             Some(Self { syntax })
3882         } else {
3883             None
3884         }
3885     }
3886     fn syntax(&self) -> &SyntaxNode {
3887         &self.syntax
3888     }
3889 }
3890 impl UseTree {
3891     pub fn path(&self) -> Option<Path> {
3892         AstChildren::new(&self.syntax).next()
3893     }
3894     pub fn use_tree_list(&self) -> Option<UseTreeList> {
3895         AstChildren::new(&self.syntax).next()
3896     }
3897     pub fn alias(&self) -> Option<Alias> {
3898         AstChildren::new(&self.syntax).next()
3899     }
3900 }
3901 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3902 pub struct UseTreeList {
3903     pub(crate) syntax: SyntaxNode,
3904 }
3905 impl AstNode for UseTreeList {
3906     fn can_cast(kind: SyntaxKind) -> bool {
3907         match kind {
3908             USE_TREE_LIST => true,
3909             _ => false,
3910         }
3911     }
3912     fn cast(syntax: SyntaxNode) -> Option<Self> {
3913         if Self::can_cast(syntax.kind()) {
3914             Some(Self { syntax })
3915         } else {
3916             None
3917         }
3918     }
3919     fn syntax(&self) -> &SyntaxNode {
3920         &self.syntax
3921     }
3922 }
3923 impl UseTreeList {
3924     pub fn use_trees(&self) -> AstChildren<UseTree> {
3925         AstChildren::new(&self.syntax)
3926     }
3927 }
3928 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3929 pub struct Visibility {
3930     pub(crate) syntax: SyntaxNode,
3931 }
3932 impl AstNode for Visibility {
3933     fn can_cast(kind: SyntaxKind) -> bool {
3934         match kind {
3935             VISIBILITY => true,
3936             _ => false,
3937         }
3938     }
3939     fn cast(syntax: SyntaxNode) -> Option<Self> {
3940         if Self::can_cast(syntax.kind()) {
3941             Some(Self { syntax })
3942         } else {
3943             None
3944         }
3945     }
3946     fn syntax(&self) -> &SyntaxNode {
3947         &self.syntax
3948     }
3949 }
3950 impl Visibility {}
3951 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3952 pub struct WhereClause {
3953     pub(crate) syntax: SyntaxNode,
3954 }
3955 impl AstNode for WhereClause {
3956     fn can_cast(kind: SyntaxKind) -> bool {
3957         match kind {
3958             WHERE_CLAUSE => true,
3959             _ => false,
3960         }
3961     }
3962     fn cast(syntax: SyntaxNode) -> Option<Self> {
3963         if Self::can_cast(syntax.kind()) {
3964             Some(Self { syntax })
3965         } else {
3966             None
3967         }
3968     }
3969     fn syntax(&self) -> &SyntaxNode {
3970         &self.syntax
3971     }
3972 }
3973 impl WhereClause {
3974     pub fn predicates(&self) -> AstChildren<WherePred> {
3975         AstChildren::new(&self.syntax)
3976     }
3977 }
3978 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3979 pub struct WherePred {
3980     pub(crate) syntax: SyntaxNode,
3981 }
3982 impl AstNode for WherePred {
3983     fn can_cast(kind: SyntaxKind) -> bool {
3984         match kind {
3985             WHERE_PRED => true,
3986             _ => false,
3987         }
3988     }
3989     fn cast(syntax: SyntaxNode) -> Option<Self> {
3990         if Self::can_cast(syntax.kind()) {
3991             Some(Self { syntax })
3992         } else {
3993             None
3994         }
3995     }
3996     fn syntax(&self) -> &SyntaxNode {
3997         &self.syntax
3998     }
3999 }
4000 impl ast::TypeBoundsOwner for WherePred {}
4001 impl WherePred {
4002     pub fn type_ref(&self) -> Option<TypeRef> {
4003         AstChildren::new(&self.syntax).next()
4004     }
4005 }
4006 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
4007 pub struct WhileExpr {
4008     pub(crate) syntax: SyntaxNode,
4009 }
4010 impl AstNode for WhileExpr {
4011     fn can_cast(kind: SyntaxKind) -> bool {
4012         match kind {
4013             WHILE_EXPR => true,
4014             _ => false,
4015         }
4016     }
4017     fn cast(syntax: SyntaxNode) -> Option<Self> {
4018         if Self::can_cast(syntax.kind()) {
4019             Some(Self { syntax })
4020         } else {
4021             None
4022         }
4023     }
4024     fn syntax(&self) -> &SyntaxNode {
4025         &self.syntax
4026     }
4027 }
4028 impl ast::LoopBodyOwner for WhileExpr {}
4029 impl WhileExpr {
4030     pub fn condition(&self) -> Option<Condition> {
4031         AstChildren::new(&self.syntax).next()
4032     }
4033 }