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