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