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