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