]> git.lizzy.rs Git - rust.git/blob - crates/ra_syntax/src/ast/generated.rs
remove ast::*Kind enums
[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     StructLit(StructLit),
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<StructLit> for Expr {
702     fn from(node: StructLit) -> Expr {
703         Expr::StructLit(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 | STRUCT_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             STRUCT_LIT => Expr::StructLit(StructLit { 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::StructLit(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 FieldPat {
950     pub(crate) syntax: SyntaxNode,
951 }
952 impl AstNode for FieldPat {
953     fn can_cast(kind: SyntaxKind) -> bool {
954         match kind {
955             FIELD_PAT => 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::NameOwner for FieldPat {}
971 impl FieldPat {
972     pub fn pat(&self) -> Option<Pat> {
973         AstChildren::new(&self.syntax).next()
974     }
975 }
976 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
977 pub struct FieldPatList {
978     pub(crate) syntax: SyntaxNode,
979 }
980 impl AstNode for FieldPatList {
981     fn can_cast(kind: SyntaxKind) -> bool {
982         match kind {
983             FIELD_PAT_LIST => true,
984             _ => false,
985         }
986     }
987     fn cast(syntax: SyntaxNode) -> Option<Self> {
988         if Self::can_cast(syntax.kind()) {
989             Some(Self { syntax })
990         } else {
991             None
992         }
993     }
994     fn syntax(&self) -> &SyntaxNode {
995         &self.syntax
996     }
997 }
998 impl FieldPatList {
999     pub fn field_pats(&self) -> AstChildren<FieldPat> {
1000         AstChildren::new(&self.syntax)
1001     }
1002     pub fn bind_pats(&self) -> AstChildren<BindPat> {
1003         AstChildren::new(&self.syntax)
1004     }
1005 }
1006 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1007 pub struct FnDef {
1008     pub(crate) syntax: SyntaxNode,
1009 }
1010 impl AstNode for FnDef {
1011     fn can_cast(kind: SyntaxKind) -> bool {
1012         match kind {
1013             FN_DEF => true,
1014             _ => false,
1015         }
1016     }
1017     fn cast(syntax: SyntaxNode) -> Option<Self> {
1018         if Self::can_cast(syntax.kind()) {
1019             Some(Self { syntax })
1020         } else {
1021             None
1022         }
1023     }
1024     fn syntax(&self) -> &SyntaxNode {
1025         &self.syntax
1026     }
1027 }
1028 impl ast::VisibilityOwner for FnDef {}
1029 impl ast::NameOwner for FnDef {}
1030 impl ast::TypeParamsOwner for FnDef {}
1031 impl ast::AttrsOwner for FnDef {}
1032 impl ast::DocCommentsOwner for FnDef {}
1033 impl FnDef {
1034     pub fn param_list(&self) -> Option<ParamList> {
1035         AstChildren::new(&self.syntax).next()
1036     }
1037     pub fn body(&self) -> Option<Block> {
1038         AstChildren::new(&self.syntax).next()
1039     }
1040     pub fn ret_type(&self) -> Option<RetType> {
1041         AstChildren::new(&self.syntax).next()
1042     }
1043 }
1044 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1045 pub struct FnPointerType {
1046     pub(crate) syntax: SyntaxNode,
1047 }
1048 impl AstNode for FnPointerType {
1049     fn can_cast(kind: SyntaxKind) -> bool {
1050         match kind {
1051             FN_POINTER_TYPE => true,
1052             _ => false,
1053         }
1054     }
1055     fn cast(syntax: SyntaxNode) -> Option<Self> {
1056         if Self::can_cast(syntax.kind()) {
1057             Some(Self { syntax })
1058         } else {
1059             None
1060         }
1061     }
1062     fn syntax(&self) -> &SyntaxNode {
1063         &self.syntax
1064     }
1065 }
1066 impl FnPointerType {
1067     pub fn param_list(&self) -> Option<ParamList> {
1068         AstChildren::new(&self.syntax).next()
1069     }
1070     pub fn ret_type(&self) -> Option<RetType> {
1071         AstChildren::new(&self.syntax).next()
1072     }
1073 }
1074 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1075 pub struct ForExpr {
1076     pub(crate) syntax: SyntaxNode,
1077 }
1078 impl AstNode for ForExpr {
1079     fn can_cast(kind: SyntaxKind) -> bool {
1080         match kind {
1081             FOR_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 ast::LoopBodyOwner for ForExpr {}
1097 impl ForExpr {
1098     pub fn pat(&self) -> Option<Pat> {
1099         AstChildren::new(&self.syntax).next()
1100     }
1101     pub fn iterable(&self) -> Option<Expr> {
1102         AstChildren::new(&self.syntax).next()
1103     }
1104 }
1105 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1106 pub struct ForType {
1107     pub(crate) syntax: SyntaxNode,
1108 }
1109 impl AstNode for ForType {
1110     fn can_cast(kind: SyntaxKind) -> bool {
1111         match kind {
1112             FOR_TYPE => true,
1113             _ => false,
1114         }
1115     }
1116     fn cast(syntax: SyntaxNode) -> Option<Self> {
1117         if Self::can_cast(syntax.kind()) {
1118             Some(Self { syntax })
1119         } else {
1120             None
1121         }
1122     }
1123     fn syntax(&self) -> &SyntaxNode {
1124         &self.syntax
1125     }
1126 }
1127 impl ForType {
1128     pub fn type_ref(&self) -> Option<TypeRef> {
1129         AstChildren::new(&self.syntax).next()
1130     }
1131 }
1132 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1133 pub struct IfExpr {
1134     pub(crate) syntax: SyntaxNode,
1135 }
1136 impl AstNode for IfExpr {
1137     fn can_cast(kind: SyntaxKind) -> bool {
1138         match kind {
1139             IF_EXPR => true,
1140             _ => false,
1141         }
1142     }
1143     fn cast(syntax: SyntaxNode) -> Option<Self> {
1144         if Self::can_cast(syntax.kind()) {
1145             Some(Self { syntax })
1146         } else {
1147             None
1148         }
1149     }
1150     fn syntax(&self) -> &SyntaxNode {
1151         &self.syntax
1152     }
1153 }
1154 impl IfExpr {
1155     pub fn condition(&self) -> Option<Condition> {
1156         AstChildren::new(&self.syntax).next()
1157     }
1158 }
1159 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1160 pub struct ImplBlock {
1161     pub(crate) syntax: SyntaxNode,
1162 }
1163 impl AstNode for ImplBlock {
1164     fn can_cast(kind: SyntaxKind) -> bool {
1165         match kind {
1166             IMPL_BLOCK => true,
1167             _ => false,
1168         }
1169     }
1170     fn cast(syntax: SyntaxNode) -> Option<Self> {
1171         if Self::can_cast(syntax.kind()) {
1172             Some(Self { syntax })
1173         } else {
1174             None
1175         }
1176     }
1177     fn syntax(&self) -> &SyntaxNode {
1178         &self.syntax
1179     }
1180 }
1181 impl ast::TypeParamsOwner for ImplBlock {}
1182 impl ast::AttrsOwner for ImplBlock {}
1183 impl ImplBlock {
1184     pub fn item_list(&self) -> Option<ItemList> {
1185         AstChildren::new(&self.syntax).next()
1186     }
1187 }
1188 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1189 pub enum ImplItem {
1190     FnDef(FnDef),
1191     TypeAliasDef(TypeAliasDef),
1192     ConstDef(ConstDef),
1193 }
1194 impl From<FnDef> for ImplItem {
1195     fn from(node: FnDef) -> ImplItem {
1196         ImplItem::FnDef(node)
1197     }
1198 }
1199 impl From<TypeAliasDef> for ImplItem {
1200     fn from(node: TypeAliasDef) -> ImplItem {
1201         ImplItem::TypeAliasDef(node)
1202     }
1203 }
1204 impl From<ConstDef> for ImplItem {
1205     fn from(node: ConstDef) -> ImplItem {
1206         ImplItem::ConstDef(node)
1207     }
1208 }
1209 impl AstNode for ImplItem {
1210     fn can_cast(kind: SyntaxKind) -> bool {
1211         match kind {
1212             FN_DEF | TYPE_ALIAS_DEF | CONST_DEF => true,
1213             _ => false,
1214         }
1215     }
1216     fn cast(syntax: SyntaxNode) -> Option<Self> {
1217         let res = match syntax.kind() {
1218             FN_DEF => ImplItem::FnDef(FnDef { syntax }),
1219             TYPE_ALIAS_DEF => ImplItem::TypeAliasDef(TypeAliasDef { syntax }),
1220             CONST_DEF => ImplItem::ConstDef(ConstDef { syntax }),
1221             _ => return None,
1222         };
1223         Some(res)
1224     }
1225     fn syntax(&self) -> &SyntaxNode {
1226         match self {
1227             ImplItem::FnDef(it) => &it.syntax,
1228             ImplItem::TypeAliasDef(it) => &it.syntax,
1229             ImplItem::ConstDef(it) => &it.syntax,
1230         }
1231     }
1232 }
1233 impl ImplItem {}
1234 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1235 pub struct ImplTraitType {
1236     pub(crate) syntax: SyntaxNode,
1237 }
1238 impl AstNode for ImplTraitType {
1239     fn can_cast(kind: SyntaxKind) -> bool {
1240         match kind {
1241             IMPL_TRAIT_TYPE => true,
1242             _ => false,
1243         }
1244     }
1245     fn cast(syntax: SyntaxNode) -> Option<Self> {
1246         if Self::can_cast(syntax.kind()) {
1247             Some(Self { syntax })
1248         } else {
1249             None
1250         }
1251     }
1252     fn syntax(&self) -> &SyntaxNode {
1253         &self.syntax
1254     }
1255 }
1256 impl ast::TypeBoundsOwner for ImplTraitType {}
1257 impl ImplTraitType {}
1258 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1259 pub struct IndexExpr {
1260     pub(crate) syntax: SyntaxNode,
1261 }
1262 impl AstNode for IndexExpr {
1263     fn can_cast(kind: SyntaxKind) -> bool {
1264         match kind {
1265             INDEX_EXPR => true,
1266             _ => false,
1267         }
1268     }
1269     fn cast(syntax: SyntaxNode) -> Option<Self> {
1270         if Self::can_cast(syntax.kind()) {
1271             Some(Self { syntax })
1272         } else {
1273             None
1274         }
1275     }
1276     fn syntax(&self) -> &SyntaxNode {
1277         &self.syntax
1278     }
1279 }
1280 impl IndexExpr {}
1281 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1282 pub struct ItemList {
1283     pub(crate) syntax: SyntaxNode,
1284 }
1285 impl AstNode for ItemList {
1286     fn can_cast(kind: SyntaxKind) -> bool {
1287         match kind {
1288             ITEM_LIST => true,
1289             _ => false,
1290         }
1291     }
1292     fn cast(syntax: SyntaxNode) -> Option<Self> {
1293         if Self::can_cast(syntax.kind()) {
1294             Some(Self { syntax })
1295         } else {
1296             None
1297         }
1298     }
1299     fn syntax(&self) -> &SyntaxNode {
1300         &self.syntax
1301     }
1302 }
1303 impl ast::FnDefOwner for ItemList {}
1304 impl ast::ModuleItemOwner for ItemList {}
1305 impl ItemList {
1306     pub fn impl_items(&self) -> AstChildren<ImplItem> {
1307         AstChildren::new(&self.syntax)
1308     }
1309 }
1310 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1311 pub struct Label {
1312     pub(crate) syntax: SyntaxNode,
1313 }
1314 impl AstNode for Label {
1315     fn can_cast(kind: SyntaxKind) -> bool {
1316         match kind {
1317             LABEL => true,
1318             _ => false,
1319         }
1320     }
1321     fn cast(syntax: SyntaxNode) -> Option<Self> {
1322         if Self::can_cast(syntax.kind()) {
1323             Some(Self { syntax })
1324         } else {
1325             None
1326         }
1327     }
1328     fn syntax(&self) -> &SyntaxNode {
1329         &self.syntax
1330     }
1331 }
1332 impl Label {}
1333 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1334 pub struct LambdaExpr {
1335     pub(crate) syntax: SyntaxNode,
1336 }
1337 impl AstNode for LambdaExpr {
1338     fn can_cast(kind: SyntaxKind) -> bool {
1339         match kind {
1340             LAMBDA_EXPR => true,
1341             _ => false,
1342         }
1343     }
1344     fn cast(syntax: SyntaxNode) -> Option<Self> {
1345         if Self::can_cast(syntax.kind()) {
1346             Some(Self { syntax })
1347         } else {
1348             None
1349         }
1350     }
1351     fn syntax(&self) -> &SyntaxNode {
1352         &self.syntax
1353     }
1354 }
1355 impl LambdaExpr {
1356     pub fn param_list(&self) -> Option<ParamList> {
1357         AstChildren::new(&self.syntax).next()
1358     }
1359     pub fn body(&self) -> Option<Expr> {
1360         AstChildren::new(&self.syntax).next()
1361     }
1362 }
1363 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1364 pub struct LetStmt {
1365     pub(crate) syntax: SyntaxNode,
1366 }
1367 impl AstNode for LetStmt {
1368     fn can_cast(kind: SyntaxKind) -> bool {
1369         match kind {
1370             LET_STMT => true,
1371             _ => false,
1372         }
1373     }
1374     fn cast(syntax: SyntaxNode) -> Option<Self> {
1375         if Self::can_cast(syntax.kind()) {
1376             Some(Self { syntax })
1377         } else {
1378             None
1379         }
1380     }
1381     fn syntax(&self) -> &SyntaxNode {
1382         &self.syntax
1383     }
1384 }
1385 impl ast::TypeAscriptionOwner for LetStmt {}
1386 impl LetStmt {
1387     pub fn pat(&self) -> Option<Pat> {
1388         AstChildren::new(&self.syntax).next()
1389     }
1390     pub fn initializer(&self) -> Option<Expr> {
1391         AstChildren::new(&self.syntax).next()
1392     }
1393 }
1394 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1395 pub struct LifetimeArg {
1396     pub(crate) syntax: SyntaxNode,
1397 }
1398 impl AstNode for LifetimeArg {
1399     fn can_cast(kind: SyntaxKind) -> bool {
1400         match kind {
1401             LIFETIME_ARG => true,
1402             _ => false,
1403         }
1404     }
1405     fn cast(syntax: SyntaxNode) -> Option<Self> {
1406         if Self::can_cast(syntax.kind()) {
1407             Some(Self { syntax })
1408         } else {
1409             None
1410         }
1411     }
1412     fn syntax(&self) -> &SyntaxNode {
1413         &self.syntax
1414     }
1415 }
1416 impl LifetimeArg {}
1417 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1418 pub struct LifetimeParam {
1419     pub(crate) syntax: SyntaxNode,
1420 }
1421 impl AstNode for LifetimeParam {
1422     fn can_cast(kind: SyntaxKind) -> bool {
1423         match kind {
1424             LIFETIME_PARAM => true,
1425             _ => false,
1426         }
1427     }
1428     fn cast(syntax: SyntaxNode) -> Option<Self> {
1429         if Self::can_cast(syntax.kind()) {
1430             Some(Self { syntax })
1431         } else {
1432             None
1433         }
1434     }
1435     fn syntax(&self) -> &SyntaxNode {
1436         &self.syntax
1437     }
1438 }
1439 impl ast::AttrsOwner for LifetimeParam {}
1440 impl LifetimeParam {}
1441 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1442 pub struct Literal {
1443     pub(crate) syntax: SyntaxNode,
1444 }
1445 impl AstNode for Literal {
1446     fn can_cast(kind: SyntaxKind) -> bool {
1447         match kind {
1448             LITERAL => true,
1449             _ => false,
1450         }
1451     }
1452     fn cast(syntax: SyntaxNode) -> Option<Self> {
1453         if Self::can_cast(syntax.kind()) {
1454             Some(Self { syntax })
1455         } else {
1456             None
1457         }
1458     }
1459     fn syntax(&self) -> &SyntaxNode {
1460         &self.syntax
1461     }
1462 }
1463 impl Literal {}
1464 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1465 pub struct LiteralPat {
1466     pub(crate) syntax: SyntaxNode,
1467 }
1468 impl AstNode for LiteralPat {
1469     fn can_cast(kind: SyntaxKind) -> bool {
1470         match kind {
1471             LITERAL_PAT => true,
1472             _ => false,
1473         }
1474     }
1475     fn cast(syntax: SyntaxNode) -> Option<Self> {
1476         if Self::can_cast(syntax.kind()) {
1477             Some(Self { syntax })
1478         } else {
1479             None
1480         }
1481     }
1482     fn syntax(&self) -> &SyntaxNode {
1483         &self.syntax
1484     }
1485 }
1486 impl LiteralPat {
1487     pub fn literal(&self) -> Option<Literal> {
1488         AstChildren::new(&self.syntax).next()
1489     }
1490 }
1491 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1492 pub struct LoopExpr {
1493     pub(crate) syntax: SyntaxNode,
1494 }
1495 impl AstNode for LoopExpr {
1496     fn can_cast(kind: SyntaxKind) -> bool {
1497         match kind {
1498             LOOP_EXPR => true,
1499             _ => false,
1500         }
1501     }
1502     fn cast(syntax: SyntaxNode) -> Option<Self> {
1503         if Self::can_cast(syntax.kind()) {
1504             Some(Self { syntax })
1505         } else {
1506             None
1507         }
1508     }
1509     fn syntax(&self) -> &SyntaxNode {
1510         &self.syntax
1511     }
1512 }
1513 impl ast::LoopBodyOwner for LoopExpr {}
1514 impl LoopExpr {}
1515 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1516 pub struct MacroCall {
1517     pub(crate) syntax: SyntaxNode,
1518 }
1519 impl AstNode for MacroCall {
1520     fn can_cast(kind: SyntaxKind) -> bool {
1521         match kind {
1522             MACRO_CALL => 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 ast::NameOwner for MacroCall {}
1538 impl ast::AttrsOwner for MacroCall {}
1539 impl ast::DocCommentsOwner for MacroCall {}
1540 impl MacroCall {
1541     pub fn token_tree(&self) -> Option<TokenTree> {
1542         AstChildren::new(&self.syntax).next()
1543     }
1544     pub fn path(&self) -> Option<Path> {
1545         AstChildren::new(&self.syntax).next()
1546     }
1547 }
1548 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1549 pub struct MacroItems {
1550     pub(crate) syntax: SyntaxNode,
1551 }
1552 impl AstNode for MacroItems {
1553     fn can_cast(kind: SyntaxKind) -> bool {
1554         match kind {
1555             MACRO_ITEMS => true,
1556             _ => false,
1557         }
1558     }
1559     fn cast(syntax: SyntaxNode) -> Option<Self> {
1560         if Self::can_cast(syntax.kind()) {
1561             Some(Self { syntax })
1562         } else {
1563             None
1564         }
1565     }
1566     fn syntax(&self) -> &SyntaxNode {
1567         &self.syntax
1568     }
1569 }
1570 impl ast::ModuleItemOwner for MacroItems {}
1571 impl ast::FnDefOwner for MacroItems {}
1572 impl MacroItems {}
1573 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1574 pub struct MacroStmts {
1575     pub(crate) syntax: SyntaxNode,
1576 }
1577 impl AstNode for MacroStmts {
1578     fn can_cast(kind: SyntaxKind) -> bool {
1579         match kind {
1580             MACRO_STMTS => true,
1581             _ => false,
1582         }
1583     }
1584     fn cast(syntax: SyntaxNode) -> Option<Self> {
1585         if Self::can_cast(syntax.kind()) {
1586             Some(Self { syntax })
1587         } else {
1588             None
1589         }
1590     }
1591     fn syntax(&self) -> &SyntaxNode {
1592         &self.syntax
1593     }
1594 }
1595 impl MacroStmts {
1596     pub fn statements(&self) -> AstChildren<Stmt> {
1597         AstChildren::new(&self.syntax)
1598     }
1599     pub fn expr(&self) -> Option<Expr> {
1600         AstChildren::new(&self.syntax).next()
1601     }
1602 }
1603 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1604 pub struct MatchArm {
1605     pub(crate) syntax: SyntaxNode,
1606 }
1607 impl AstNode for MatchArm {
1608     fn can_cast(kind: SyntaxKind) -> bool {
1609         match kind {
1610             MATCH_ARM => true,
1611             _ => false,
1612         }
1613     }
1614     fn cast(syntax: SyntaxNode) -> Option<Self> {
1615         if Self::can_cast(syntax.kind()) {
1616             Some(Self { syntax })
1617         } else {
1618             None
1619         }
1620     }
1621     fn syntax(&self) -> &SyntaxNode {
1622         &self.syntax
1623     }
1624 }
1625 impl ast::AttrsOwner for MatchArm {}
1626 impl MatchArm {
1627     pub fn pats(&self) -> AstChildren<Pat> {
1628         AstChildren::new(&self.syntax)
1629     }
1630     pub fn guard(&self) -> Option<MatchGuard> {
1631         AstChildren::new(&self.syntax).next()
1632     }
1633     pub fn expr(&self) -> Option<Expr> {
1634         AstChildren::new(&self.syntax).next()
1635     }
1636 }
1637 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1638 pub struct MatchArmList {
1639     pub(crate) syntax: SyntaxNode,
1640 }
1641 impl AstNode for MatchArmList {
1642     fn can_cast(kind: SyntaxKind) -> bool {
1643         match kind {
1644             MATCH_ARM_LIST => 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 ast::AttrsOwner for MatchArmList {}
1660 impl MatchArmList {
1661     pub fn arms(&self) -> AstChildren<MatchArm> {
1662         AstChildren::new(&self.syntax)
1663     }
1664 }
1665 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1666 pub struct MatchExpr {
1667     pub(crate) syntax: SyntaxNode,
1668 }
1669 impl AstNode for MatchExpr {
1670     fn can_cast(kind: SyntaxKind) -> bool {
1671         match kind {
1672             MATCH_EXPR => true,
1673             _ => false,
1674         }
1675     }
1676     fn cast(syntax: SyntaxNode) -> Option<Self> {
1677         if Self::can_cast(syntax.kind()) {
1678             Some(Self { syntax })
1679         } else {
1680             None
1681         }
1682     }
1683     fn syntax(&self) -> &SyntaxNode {
1684         &self.syntax
1685     }
1686 }
1687 impl MatchExpr {
1688     pub fn expr(&self) -> Option<Expr> {
1689         AstChildren::new(&self.syntax).next()
1690     }
1691     pub fn match_arm_list(&self) -> Option<MatchArmList> {
1692         AstChildren::new(&self.syntax).next()
1693     }
1694 }
1695 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1696 pub struct MatchGuard {
1697     pub(crate) syntax: SyntaxNode,
1698 }
1699 impl AstNode for MatchGuard {
1700     fn can_cast(kind: SyntaxKind) -> bool {
1701         match kind {
1702             MATCH_GUARD => true,
1703             _ => false,
1704         }
1705     }
1706     fn cast(syntax: SyntaxNode) -> Option<Self> {
1707         if Self::can_cast(syntax.kind()) {
1708             Some(Self { syntax })
1709         } else {
1710             None
1711         }
1712     }
1713     fn syntax(&self) -> &SyntaxNode {
1714         &self.syntax
1715     }
1716 }
1717 impl MatchGuard {
1718     pub fn expr(&self) -> Option<Expr> {
1719         AstChildren::new(&self.syntax).next()
1720     }
1721 }
1722 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1723 pub struct MethodCallExpr {
1724     pub(crate) syntax: SyntaxNode,
1725 }
1726 impl AstNode for MethodCallExpr {
1727     fn can_cast(kind: SyntaxKind) -> bool {
1728         match kind {
1729             METHOD_CALL_EXPR => true,
1730             _ => false,
1731         }
1732     }
1733     fn cast(syntax: SyntaxNode) -> Option<Self> {
1734         if Self::can_cast(syntax.kind()) {
1735             Some(Self { syntax })
1736         } else {
1737             None
1738         }
1739     }
1740     fn syntax(&self) -> &SyntaxNode {
1741         &self.syntax
1742     }
1743 }
1744 impl ast::ArgListOwner for MethodCallExpr {}
1745 impl MethodCallExpr {
1746     pub fn expr(&self) -> Option<Expr> {
1747         AstChildren::new(&self.syntax).next()
1748     }
1749     pub fn name_ref(&self) -> Option<NameRef> {
1750         AstChildren::new(&self.syntax).next()
1751     }
1752     pub fn type_arg_list(&self) -> Option<TypeArgList> {
1753         AstChildren::new(&self.syntax).next()
1754     }
1755 }
1756 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1757 pub struct Module {
1758     pub(crate) syntax: SyntaxNode,
1759 }
1760 impl AstNode for Module {
1761     fn can_cast(kind: SyntaxKind) -> bool {
1762         match kind {
1763             MODULE => true,
1764             _ => false,
1765         }
1766     }
1767     fn cast(syntax: SyntaxNode) -> Option<Self> {
1768         if Self::can_cast(syntax.kind()) {
1769             Some(Self { syntax })
1770         } else {
1771             None
1772         }
1773     }
1774     fn syntax(&self) -> &SyntaxNode {
1775         &self.syntax
1776     }
1777 }
1778 impl ast::VisibilityOwner for Module {}
1779 impl ast::NameOwner for Module {}
1780 impl ast::AttrsOwner for Module {}
1781 impl ast::DocCommentsOwner for Module {}
1782 impl Module {
1783     pub fn item_list(&self) -> Option<ItemList> {
1784         AstChildren::new(&self.syntax).next()
1785     }
1786 }
1787 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1788 pub enum ModuleItem {
1789     StructDef(StructDef),
1790     EnumDef(EnumDef),
1791     FnDef(FnDef),
1792     TraitDef(TraitDef),
1793     TypeAliasDef(TypeAliasDef),
1794     ImplBlock(ImplBlock),
1795     UseItem(UseItem),
1796     ExternCrateItem(ExternCrateItem),
1797     ConstDef(ConstDef),
1798     StaticDef(StaticDef),
1799     Module(Module),
1800 }
1801 impl From<StructDef> for ModuleItem {
1802     fn from(node: StructDef) -> ModuleItem {
1803         ModuleItem::StructDef(node)
1804     }
1805 }
1806 impl From<EnumDef> for ModuleItem {
1807     fn from(node: EnumDef) -> ModuleItem {
1808         ModuleItem::EnumDef(node)
1809     }
1810 }
1811 impl From<FnDef> for ModuleItem {
1812     fn from(node: FnDef) -> ModuleItem {
1813         ModuleItem::FnDef(node)
1814     }
1815 }
1816 impl From<TraitDef> for ModuleItem {
1817     fn from(node: TraitDef) -> ModuleItem {
1818         ModuleItem::TraitDef(node)
1819     }
1820 }
1821 impl From<TypeAliasDef> for ModuleItem {
1822     fn from(node: TypeAliasDef) -> ModuleItem {
1823         ModuleItem::TypeAliasDef(node)
1824     }
1825 }
1826 impl From<ImplBlock> for ModuleItem {
1827     fn from(node: ImplBlock) -> ModuleItem {
1828         ModuleItem::ImplBlock(node)
1829     }
1830 }
1831 impl From<UseItem> for ModuleItem {
1832     fn from(node: UseItem) -> ModuleItem {
1833         ModuleItem::UseItem(node)
1834     }
1835 }
1836 impl From<ExternCrateItem> for ModuleItem {
1837     fn from(node: ExternCrateItem) -> ModuleItem {
1838         ModuleItem::ExternCrateItem(node)
1839     }
1840 }
1841 impl From<ConstDef> for ModuleItem {
1842     fn from(node: ConstDef) -> ModuleItem {
1843         ModuleItem::ConstDef(node)
1844     }
1845 }
1846 impl From<StaticDef> for ModuleItem {
1847     fn from(node: StaticDef) -> ModuleItem {
1848         ModuleItem::StaticDef(node)
1849     }
1850 }
1851 impl From<Module> for ModuleItem {
1852     fn from(node: Module) -> ModuleItem {
1853         ModuleItem::Module(node)
1854     }
1855 }
1856 impl AstNode for ModuleItem {
1857     fn can_cast(kind: SyntaxKind) -> bool {
1858         match kind {
1859             STRUCT_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | IMPL_BLOCK | USE_ITEM
1860             | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE => true,
1861             _ => false,
1862         }
1863     }
1864     fn cast(syntax: SyntaxNode) -> Option<Self> {
1865         let res = match syntax.kind() {
1866             STRUCT_DEF => ModuleItem::StructDef(StructDef { syntax }),
1867             ENUM_DEF => ModuleItem::EnumDef(EnumDef { syntax }),
1868             FN_DEF => ModuleItem::FnDef(FnDef { syntax }),
1869             TRAIT_DEF => ModuleItem::TraitDef(TraitDef { syntax }),
1870             TYPE_ALIAS_DEF => ModuleItem::TypeAliasDef(TypeAliasDef { syntax }),
1871             IMPL_BLOCK => ModuleItem::ImplBlock(ImplBlock { syntax }),
1872             USE_ITEM => ModuleItem::UseItem(UseItem { syntax }),
1873             EXTERN_CRATE_ITEM => ModuleItem::ExternCrateItem(ExternCrateItem { syntax }),
1874             CONST_DEF => ModuleItem::ConstDef(ConstDef { syntax }),
1875             STATIC_DEF => ModuleItem::StaticDef(StaticDef { syntax }),
1876             MODULE => ModuleItem::Module(Module { syntax }),
1877             _ => return None,
1878         };
1879         Some(res)
1880     }
1881     fn syntax(&self) -> &SyntaxNode {
1882         match self {
1883             ModuleItem::StructDef(it) => &it.syntax,
1884             ModuleItem::EnumDef(it) => &it.syntax,
1885             ModuleItem::FnDef(it) => &it.syntax,
1886             ModuleItem::TraitDef(it) => &it.syntax,
1887             ModuleItem::TypeAliasDef(it) => &it.syntax,
1888             ModuleItem::ImplBlock(it) => &it.syntax,
1889             ModuleItem::UseItem(it) => &it.syntax,
1890             ModuleItem::ExternCrateItem(it) => &it.syntax,
1891             ModuleItem::ConstDef(it) => &it.syntax,
1892             ModuleItem::StaticDef(it) => &it.syntax,
1893             ModuleItem::Module(it) => &it.syntax,
1894         }
1895     }
1896 }
1897 impl ModuleItem {}
1898 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1899 pub struct Name {
1900     pub(crate) syntax: SyntaxNode,
1901 }
1902 impl AstNode for Name {
1903     fn can_cast(kind: SyntaxKind) -> bool {
1904         match kind {
1905             NAME => true,
1906             _ => false,
1907         }
1908     }
1909     fn cast(syntax: SyntaxNode) -> Option<Self> {
1910         if Self::can_cast(syntax.kind()) {
1911             Some(Self { syntax })
1912         } else {
1913             None
1914         }
1915     }
1916     fn syntax(&self) -> &SyntaxNode {
1917         &self.syntax
1918     }
1919 }
1920 impl Name {}
1921 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1922 pub struct NameRef {
1923     pub(crate) syntax: SyntaxNode,
1924 }
1925 impl AstNode for NameRef {
1926     fn can_cast(kind: SyntaxKind) -> bool {
1927         match kind {
1928             NAME_REF => true,
1929             _ => false,
1930         }
1931     }
1932     fn cast(syntax: SyntaxNode) -> Option<Self> {
1933         if Self::can_cast(syntax.kind()) {
1934             Some(Self { syntax })
1935         } else {
1936             None
1937         }
1938     }
1939     fn syntax(&self) -> &SyntaxNode {
1940         &self.syntax
1941     }
1942 }
1943 impl NameRef {}
1944 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1945 pub struct NamedField {
1946     pub(crate) syntax: SyntaxNode,
1947 }
1948 impl AstNode for NamedField {
1949     fn can_cast(kind: SyntaxKind) -> bool {
1950         match kind {
1951             NAMED_FIELD => true,
1952             _ => false,
1953         }
1954     }
1955     fn cast(syntax: SyntaxNode) -> Option<Self> {
1956         if Self::can_cast(syntax.kind()) {
1957             Some(Self { syntax })
1958         } else {
1959             None
1960         }
1961     }
1962     fn syntax(&self) -> &SyntaxNode {
1963         &self.syntax
1964     }
1965 }
1966 impl NamedField {
1967     pub fn name_ref(&self) -> Option<NameRef> {
1968         AstChildren::new(&self.syntax).next()
1969     }
1970     pub fn expr(&self) -> Option<Expr> {
1971         AstChildren::new(&self.syntax).next()
1972     }
1973 }
1974 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
1975 pub struct NamedFieldDef {
1976     pub(crate) syntax: SyntaxNode,
1977 }
1978 impl AstNode for NamedFieldDef {
1979     fn can_cast(kind: SyntaxKind) -> bool {
1980         match kind {
1981             NAMED_FIELD_DEF => true,
1982             _ => false,
1983         }
1984     }
1985     fn cast(syntax: SyntaxNode) -> Option<Self> {
1986         if Self::can_cast(syntax.kind()) {
1987             Some(Self { syntax })
1988         } else {
1989             None
1990         }
1991     }
1992     fn syntax(&self) -> &SyntaxNode {
1993         &self.syntax
1994     }
1995 }
1996 impl ast::VisibilityOwner for NamedFieldDef {}
1997 impl ast::NameOwner for NamedFieldDef {}
1998 impl ast::AttrsOwner for NamedFieldDef {}
1999 impl ast::DocCommentsOwner for NamedFieldDef {}
2000 impl ast::TypeAscriptionOwner for NamedFieldDef {}
2001 impl NamedFieldDef {}
2002 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2003 pub struct NamedFieldDefList {
2004     pub(crate) syntax: SyntaxNode,
2005 }
2006 impl AstNode for NamedFieldDefList {
2007     fn can_cast(kind: SyntaxKind) -> bool {
2008         match kind {
2009             NAMED_FIELD_DEF_LIST => true,
2010             _ => false,
2011         }
2012     }
2013     fn cast(syntax: SyntaxNode) -> Option<Self> {
2014         if Self::can_cast(syntax.kind()) {
2015             Some(Self { syntax })
2016         } else {
2017             None
2018         }
2019     }
2020     fn syntax(&self) -> &SyntaxNode {
2021         &self.syntax
2022     }
2023 }
2024 impl NamedFieldDefList {
2025     pub fn fields(&self) -> AstChildren<NamedFieldDef> {
2026         AstChildren::new(&self.syntax)
2027     }
2028 }
2029 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2030 pub struct NamedFieldList {
2031     pub(crate) syntax: SyntaxNode,
2032 }
2033 impl AstNode for NamedFieldList {
2034     fn can_cast(kind: SyntaxKind) -> bool {
2035         match kind {
2036             NAMED_FIELD_LIST => true,
2037             _ => false,
2038         }
2039     }
2040     fn cast(syntax: SyntaxNode) -> Option<Self> {
2041         if Self::can_cast(syntax.kind()) {
2042             Some(Self { syntax })
2043         } else {
2044             None
2045         }
2046     }
2047     fn syntax(&self) -> &SyntaxNode {
2048         &self.syntax
2049     }
2050 }
2051 impl NamedFieldList {
2052     pub fn fields(&self) -> AstChildren<NamedField> {
2053         AstChildren::new(&self.syntax)
2054     }
2055     pub fn spread(&self) -> Option<Expr> {
2056         AstChildren::new(&self.syntax).next()
2057     }
2058 }
2059 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2060 pub struct NeverType {
2061     pub(crate) syntax: SyntaxNode,
2062 }
2063 impl AstNode for NeverType {
2064     fn can_cast(kind: SyntaxKind) -> bool {
2065         match kind {
2066             NEVER_TYPE => true,
2067             _ => false,
2068         }
2069     }
2070     fn cast(syntax: SyntaxNode) -> Option<Self> {
2071         if Self::can_cast(syntax.kind()) {
2072             Some(Self { syntax })
2073         } else {
2074             None
2075         }
2076     }
2077     fn syntax(&self) -> &SyntaxNode {
2078         &self.syntax
2079     }
2080 }
2081 impl NeverType {}
2082 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2083 pub enum NominalDef {
2084     StructDef(StructDef),
2085     EnumDef(EnumDef),
2086 }
2087 impl From<StructDef> for NominalDef {
2088     fn from(node: StructDef) -> NominalDef {
2089         NominalDef::StructDef(node)
2090     }
2091 }
2092 impl From<EnumDef> for NominalDef {
2093     fn from(node: EnumDef) -> NominalDef {
2094         NominalDef::EnumDef(node)
2095     }
2096 }
2097 impl AstNode for NominalDef {
2098     fn can_cast(kind: SyntaxKind) -> bool {
2099         match kind {
2100             STRUCT_DEF | ENUM_DEF => true,
2101             _ => false,
2102         }
2103     }
2104     fn cast(syntax: SyntaxNode) -> Option<Self> {
2105         let res = match syntax.kind() {
2106             STRUCT_DEF => NominalDef::StructDef(StructDef { syntax }),
2107             ENUM_DEF => NominalDef::EnumDef(EnumDef { syntax }),
2108             _ => return None,
2109         };
2110         Some(res)
2111     }
2112     fn syntax(&self) -> &SyntaxNode {
2113         match self {
2114             NominalDef::StructDef(it) => &it.syntax,
2115             NominalDef::EnumDef(it) => &it.syntax,
2116         }
2117     }
2118 }
2119 impl ast::NameOwner for NominalDef {}
2120 impl ast::TypeParamsOwner for NominalDef {}
2121 impl ast::AttrsOwner for NominalDef {}
2122 impl NominalDef {}
2123 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2124 pub struct Param {
2125     pub(crate) syntax: SyntaxNode,
2126 }
2127 impl AstNode for Param {
2128     fn can_cast(kind: SyntaxKind) -> bool {
2129         match kind {
2130             PARAM => true,
2131             _ => false,
2132         }
2133     }
2134     fn cast(syntax: SyntaxNode) -> Option<Self> {
2135         if Self::can_cast(syntax.kind()) {
2136             Some(Self { syntax })
2137         } else {
2138             None
2139         }
2140     }
2141     fn syntax(&self) -> &SyntaxNode {
2142         &self.syntax
2143     }
2144 }
2145 impl ast::TypeAscriptionOwner for Param {}
2146 impl ast::AttrsOwner for Param {}
2147 impl Param {
2148     pub fn pat(&self) -> Option<Pat> {
2149         AstChildren::new(&self.syntax).next()
2150     }
2151 }
2152 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2153 pub struct ParamList {
2154     pub(crate) syntax: SyntaxNode,
2155 }
2156 impl AstNode for ParamList {
2157     fn can_cast(kind: SyntaxKind) -> bool {
2158         match kind {
2159             PARAM_LIST => true,
2160             _ => false,
2161         }
2162     }
2163     fn cast(syntax: SyntaxNode) -> Option<Self> {
2164         if Self::can_cast(syntax.kind()) {
2165             Some(Self { syntax })
2166         } else {
2167             None
2168         }
2169     }
2170     fn syntax(&self) -> &SyntaxNode {
2171         &self.syntax
2172     }
2173 }
2174 impl ParamList {
2175     pub fn params(&self) -> AstChildren<Param> {
2176         AstChildren::new(&self.syntax)
2177     }
2178     pub fn self_param(&self) -> Option<SelfParam> {
2179         AstChildren::new(&self.syntax).next()
2180     }
2181 }
2182 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2183 pub struct ParenExpr {
2184     pub(crate) syntax: SyntaxNode,
2185 }
2186 impl AstNode for ParenExpr {
2187     fn can_cast(kind: SyntaxKind) -> bool {
2188         match kind {
2189             PAREN_EXPR => true,
2190             _ => false,
2191         }
2192     }
2193     fn cast(syntax: SyntaxNode) -> Option<Self> {
2194         if Self::can_cast(syntax.kind()) {
2195             Some(Self { syntax })
2196         } else {
2197             None
2198         }
2199     }
2200     fn syntax(&self) -> &SyntaxNode {
2201         &self.syntax
2202     }
2203 }
2204 impl ParenExpr {
2205     pub fn expr(&self) -> Option<Expr> {
2206         AstChildren::new(&self.syntax).next()
2207     }
2208 }
2209 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2210 pub struct ParenType {
2211     pub(crate) syntax: SyntaxNode,
2212 }
2213 impl AstNode for ParenType {
2214     fn can_cast(kind: SyntaxKind) -> bool {
2215         match kind {
2216             PAREN_TYPE => true,
2217             _ => false,
2218         }
2219     }
2220     fn cast(syntax: SyntaxNode) -> Option<Self> {
2221         if Self::can_cast(syntax.kind()) {
2222             Some(Self { syntax })
2223         } else {
2224             None
2225         }
2226     }
2227     fn syntax(&self) -> &SyntaxNode {
2228         &self.syntax
2229     }
2230 }
2231 impl ParenType {
2232     pub fn type_ref(&self) -> Option<TypeRef> {
2233         AstChildren::new(&self.syntax).next()
2234     }
2235 }
2236 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2237 pub enum Pat {
2238     RefPat(RefPat),
2239     BindPat(BindPat),
2240     PlaceholderPat(PlaceholderPat),
2241     PathPat(PathPat),
2242     StructPat(StructPat),
2243     TupleStructPat(TupleStructPat),
2244     TuplePat(TuplePat),
2245     SlicePat(SlicePat),
2246     RangePat(RangePat),
2247     LiteralPat(LiteralPat),
2248 }
2249 impl From<RefPat> for Pat {
2250     fn from(node: RefPat) -> Pat {
2251         Pat::RefPat(node)
2252     }
2253 }
2254 impl From<BindPat> for Pat {
2255     fn from(node: BindPat) -> Pat {
2256         Pat::BindPat(node)
2257     }
2258 }
2259 impl From<PlaceholderPat> for Pat {
2260     fn from(node: PlaceholderPat) -> Pat {
2261         Pat::PlaceholderPat(node)
2262     }
2263 }
2264 impl From<PathPat> for Pat {
2265     fn from(node: PathPat) -> Pat {
2266         Pat::PathPat(node)
2267     }
2268 }
2269 impl From<StructPat> for Pat {
2270     fn from(node: StructPat) -> Pat {
2271         Pat::StructPat(node)
2272     }
2273 }
2274 impl From<TupleStructPat> for Pat {
2275     fn from(node: TupleStructPat) -> Pat {
2276         Pat::TupleStructPat(node)
2277     }
2278 }
2279 impl From<TuplePat> for Pat {
2280     fn from(node: TuplePat) -> Pat {
2281         Pat::TuplePat(node)
2282     }
2283 }
2284 impl From<SlicePat> for Pat {
2285     fn from(node: SlicePat) -> Pat {
2286         Pat::SlicePat(node)
2287     }
2288 }
2289 impl From<RangePat> for Pat {
2290     fn from(node: RangePat) -> Pat {
2291         Pat::RangePat(node)
2292     }
2293 }
2294 impl From<LiteralPat> for Pat {
2295     fn from(node: LiteralPat) -> Pat {
2296         Pat::LiteralPat(node)
2297     }
2298 }
2299 impl AstNode for Pat {
2300     fn can_cast(kind: SyntaxKind) -> bool {
2301         match kind {
2302             REF_PAT | BIND_PAT | PLACEHOLDER_PAT | PATH_PAT | STRUCT_PAT | TUPLE_STRUCT_PAT
2303             | TUPLE_PAT | SLICE_PAT | RANGE_PAT | LITERAL_PAT => true,
2304             _ => false,
2305         }
2306     }
2307     fn cast(syntax: SyntaxNode) -> Option<Self> {
2308         let res = match syntax.kind() {
2309             REF_PAT => Pat::RefPat(RefPat { syntax }),
2310             BIND_PAT => Pat::BindPat(BindPat { syntax }),
2311             PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }),
2312             PATH_PAT => Pat::PathPat(PathPat { syntax }),
2313             STRUCT_PAT => Pat::StructPat(StructPat { syntax }),
2314             TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }),
2315             TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }),
2316             SLICE_PAT => Pat::SlicePat(SlicePat { syntax }),
2317             RANGE_PAT => Pat::RangePat(RangePat { syntax }),
2318             LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }),
2319             _ => return None,
2320         };
2321         Some(res)
2322     }
2323     fn syntax(&self) -> &SyntaxNode {
2324         match self {
2325             Pat::RefPat(it) => &it.syntax,
2326             Pat::BindPat(it) => &it.syntax,
2327             Pat::PlaceholderPat(it) => &it.syntax,
2328             Pat::PathPat(it) => &it.syntax,
2329             Pat::StructPat(it) => &it.syntax,
2330             Pat::TupleStructPat(it) => &it.syntax,
2331             Pat::TuplePat(it) => &it.syntax,
2332             Pat::SlicePat(it) => &it.syntax,
2333             Pat::RangePat(it) => &it.syntax,
2334             Pat::LiteralPat(it) => &it.syntax,
2335         }
2336     }
2337 }
2338 impl Pat {}
2339 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2340 pub struct Path {
2341     pub(crate) syntax: SyntaxNode,
2342 }
2343 impl AstNode for Path {
2344     fn can_cast(kind: SyntaxKind) -> bool {
2345         match kind {
2346             PATH => true,
2347             _ => false,
2348         }
2349     }
2350     fn cast(syntax: SyntaxNode) -> Option<Self> {
2351         if Self::can_cast(syntax.kind()) {
2352             Some(Self { syntax })
2353         } else {
2354             None
2355         }
2356     }
2357     fn syntax(&self) -> &SyntaxNode {
2358         &self.syntax
2359     }
2360 }
2361 impl Path {
2362     pub fn segment(&self) -> Option<PathSegment> {
2363         AstChildren::new(&self.syntax).next()
2364     }
2365     pub fn qualifier(&self) -> Option<Path> {
2366         AstChildren::new(&self.syntax).next()
2367     }
2368 }
2369 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2370 pub struct PathExpr {
2371     pub(crate) syntax: SyntaxNode,
2372 }
2373 impl AstNode for PathExpr {
2374     fn can_cast(kind: SyntaxKind) -> bool {
2375         match kind {
2376             PATH_EXPR => true,
2377             _ => false,
2378         }
2379     }
2380     fn cast(syntax: SyntaxNode) -> Option<Self> {
2381         if Self::can_cast(syntax.kind()) {
2382             Some(Self { syntax })
2383         } else {
2384             None
2385         }
2386     }
2387     fn syntax(&self) -> &SyntaxNode {
2388         &self.syntax
2389     }
2390 }
2391 impl PathExpr {
2392     pub fn path(&self) -> Option<Path> {
2393         AstChildren::new(&self.syntax).next()
2394     }
2395 }
2396 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2397 pub struct PathPat {
2398     pub(crate) syntax: SyntaxNode,
2399 }
2400 impl AstNode for PathPat {
2401     fn can_cast(kind: SyntaxKind) -> bool {
2402         match kind {
2403             PATH_PAT => true,
2404             _ => false,
2405         }
2406     }
2407     fn cast(syntax: SyntaxNode) -> Option<Self> {
2408         if Self::can_cast(syntax.kind()) {
2409             Some(Self { syntax })
2410         } else {
2411             None
2412         }
2413     }
2414     fn syntax(&self) -> &SyntaxNode {
2415         &self.syntax
2416     }
2417 }
2418 impl PathPat {
2419     pub fn path(&self) -> Option<Path> {
2420         AstChildren::new(&self.syntax).next()
2421     }
2422 }
2423 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2424 pub struct PathSegment {
2425     pub(crate) syntax: SyntaxNode,
2426 }
2427 impl AstNode for PathSegment {
2428     fn can_cast(kind: SyntaxKind) -> bool {
2429         match kind {
2430             PATH_SEGMENT => true,
2431             _ => false,
2432         }
2433     }
2434     fn cast(syntax: SyntaxNode) -> Option<Self> {
2435         if Self::can_cast(syntax.kind()) {
2436             Some(Self { syntax })
2437         } else {
2438             None
2439         }
2440     }
2441     fn syntax(&self) -> &SyntaxNode {
2442         &self.syntax
2443     }
2444 }
2445 impl PathSegment {
2446     pub fn name_ref(&self) -> Option<NameRef> {
2447         AstChildren::new(&self.syntax).next()
2448     }
2449     pub fn type_arg_list(&self) -> Option<TypeArgList> {
2450         AstChildren::new(&self.syntax).next()
2451     }
2452 }
2453 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2454 pub struct PathType {
2455     pub(crate) syntax: SyntaxNode,
2456 }
2457 impl AstNode for PathType {
2458     fn can_cast(kind: SyntaxKind) -> bool {
2459         match kind {
2460             PATH_TYPE => 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 PathType {
2476     pub fn path(&self) -> Option<Path> {
2477         AstChildren::new(&self.syntax).next()
2478     }
2479 }
2480 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2481 pub struct PlaceholderPat {
2482     pub(crate) syntax: SyntaxNode,
2483 }
2484 impl AstNode for PlaceholderPat {
2485     fn can_cast(kind: SyntaxKind) -> bool {
2486         match kind {
2487             PLACEHOLDER_PAT => true,
2488             _ => false,
2489         }
2490     }
2491     fn cast(syntax: SyntaxNode) -> Option<Self> {
2492         if Self::can_cast(syntax.kind()) {
2493             Some(Self { syntax })
2494         } else {
2495             None
2496         }
2497     }
2498     fn syntax(&self) -> &SyntaxNode {
2499         &self.syntax
2500     }
2501 }
2502 impl PlaceholderPat {}
2503 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2504 pub struct PlaceholderType {
2505     pub(crate) syntax: SyntaxNode,
2506 }
2507 impl AstNode for PlaceholderType {
2508     fn can_cast(kind: SyntaxKind) -> bool {
2509         match kind {
2510             PLACEHOLDER_TYPE => true,
2511             _ => false,
2512         }
2513     }
2514     fn cast(syntax: SyntaxNode) -> Option<Self> {
2515         if Self::can_cast(syntax.kind()) {
2516             Some(Self { syntax })
2517         } else {
2518             None
2519         }
2520     }
2521     fn syntax(&self) -> &SyntaxNode {
2522         &self.syntax
2523     }
2524 }
2525 impl PlaceholderType {}
2526 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2527 pub struct PointerType {
2528     pub(crate) syntax: SyntaxNode,
2529 }
2530 impl AstNode for PointerType {
2531     fn can_cast(kind: SyntaxKind) -> bool {
2532         match kind {
2533             POINTER_TYPE => true,
2534             _ => false,
2535         }
2536     }
2537     fn cast(syntax: SyntaxNode) -> Option<Self> {
2538         if Self::can_cast(syntax.kind()) {
2539             Some(Self { syntax })
2540         } else {
2541             None
2542         }
2543     }
2544     fn syntax(&self) -> &SyntaxNode {
2545         &self.syntax
2546     }
2547 }
2548 impl PointerType {
2549     pub fn type_ref(&self) -> Option<TypeRef> {
2550         AstChildren::new(&self.syntax).next()
2551     }
2552 }
2553 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2554 pub struct PosFieldDef {
2555     pub(crate) syntax: SyntaxNode,
2556 }
2557 impl AstNode for PosFieldDef {
2558     fn can_cast(kind: SyntaxKind) -> bool {
2559         match kind {
2560             POS_FIELD_DEF => true,
2561             _ => false,
2562         }
2563     }
2564     fn cast(syntax: SyntaxNode) -> Option<Self> {
2565         if Self::can_cast(syntax.kind()) {
2566             Some(Self { syntax })
2567         } else {
2568             None
2569         }
2570     }
2571     fn syntax(&self) -> &SyntaxNode {
2572         &self.syntax
2573     }
2574 }
2575 impl ast::VisibilityOwner for PosFieldDef {}
2576 impl ast::AttrsOwner for PosFieldDef {}
2577 impl PosFieldDef {
2578     pub fn type_ref(&self) -> Option<TypeRef> {
2579         AstChildren::new(&self.syntax).next()
2580     }
2581 }
2582 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2583 pub struct PosFieldDefList {
2584     pub(crate) syntax: SyntaxNode,
2585 }
2586 impl AstNode for PosFieldDefList {
2587     fn can_cast(kind: SyntaxKind) -> bool {
2588         match kind {
2589             POS_FIELD_DEF_LIST => true,
2590             _ => false,
2591         }
2592     }
2593     fn cast(syntax: SyntaxNode) -> Option<Self> {
2594         if Self::can_cast(syntax.kind()) {
2595             Some(Self { syntax })
2596         } else {
2597             None
2598         }
2599     }
2600     fn syntax(&self) -> &SyntaxNode {
2601         &self.syntax
2602     }
2603 }
2604 impl PosFieldDefList {
2605     pub fn fields(&self) -> AstChildren<PosFieldDef> {
2606         AstChildren::new(&self.syntax)
2607     }
2608 }
2609 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2610 pub struct PrefixExpr {
2611     pub(crate) syntax: SyntaxNode,
2612 }
2613 impl AstNode for PrefixExpr {
2614     fn can_cast(kind: SyntaxKind) -> bool {
2615         match kind {
2616             PREFIX_EXPR => true,
2617             _ => false,
2618         }
2619     }
2620     fn cast(syntax: SyntaxNode) -> Option<Self> {
2621         if Self::can_cast(syntax.kind()) {
2622             Some(Self { syntax })
2623         } else {
2624             None
2625         }
2626     }
2627     fn syntax(&self) -> &SyntaxNode {
2628         &self.syntax
2629     }
2630 }
2631 impl PrefixExpr {
2632     pub fn expr(&self) -> Option<Expr> {
2633         AstChildren::new(&self.syntax).next()
2634     }
2635 }
2636 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2637 pub struct RangeExpr {
2638     pub(crate) syntax: SyntaxNode,
2639 }
2640 impl AstNode for RangeExpr {
2641     fn can_cast(kind: SyntaxKind) -> bool {
2642         match kind {
2643             RANGE_EXPR => true,
2644             _ => false,
2645         }
2646     }
2647     fn cast(syntax: SyntaxNode) -> Option<Self> {
2648         if Self::can_cast(syntax.kind()) {
2649             Some(Self { syntax })
2650         } else {
2651             None
2652         }
2653     }
2654     fn syntax(&self) -> &SyntaxNode {
2655         &self.syntax
2656     }
2657 }
2658 impl RangeExpr {}
2659 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2660 pub struct RangePat {
2661     pub(crate) syntax: SyntaxNode,
2662 }
2663 impl AstNode for RangePat {
2664     fn can_cast(kind: SyntaxKind) -> bool {
2665         match kind {
2666             RANGE_PAT => true,
2667             _ => false,
2668         }
2669     }
2670     fn cast(syntax: SyntaxNode) -> Option<Self> {
2671         if Self::can_cast(syntax.kind()) {
2672             Some(Self { syntax })
2673         } else {
2674             None
2675         }
2676     }
2677     fn syntax(&self) -> &SyntaxNode {
2678         &self.syntax
2679     }
2680 }
2681 impl RangePat {}
2682 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2683 pub struct RefExpr {
2684     pub(crate) syntax: SyntaxNode,
2685 }
2686 impl AstNode for RefExpr {
2687     fn can_cast(kind: SyntaxKind) -> bool {
2688         match kind {
2689             REF_EXPR => true,
2690             _ => false,
2691         }
2692     }
2693     fn cast(syntax: SyntaxNode) -> Option<Self> {
2694         if Self::can_cast(syntax.kind()) {
2695             Some(Self { syntax })
2696         } else {
2697             None
2698         }
2699     }
2700     fn syntax(&self) -> &SyntaxNode {
2701         &self.syntax
2702     }
2703 }
2704 impl RefExpr {
2705     pub fn expr(&self) -> Option<Expr> {
2706         AstChildren::new(&self.syntax).next()
2707     }
2708 }
2709 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2710 pub struct RefPat {
2711     pub(crate) syntax: SyntaxNode,
2712 }
2713 impl AstNode for RefPat {
2714     fn can_cast(kind: SyntaxKind) -> bool {
2715         match kind {
2716             REF_PAT => true,
2717             _ => false,
2718         }
2719     }
2720     fn cast(syntax: SyntaxNode) -> Option<Self> {
2721         if Self::can_cast(syntax.kind()) {
2722             Some(Self { syntax })
2723         } else {
2724             None
2725         }
2726     }
2727     fn syntax(&self) -> &SyntaxNode {
2728         &self.syntax
2729     }
2730 }
2731 impl RefPat {
2732     pub fn pat(&self) -> Option<Pat> {
2733         AstChildren::new(&self.syntax).next()
2734     }
2735 }
2736 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2737 pub struct ReferenceType {
2738     pub(crate) syntax: SyntaxNode,
2739 }
2740 impl AstNode for ReferenceType {
2741     fn can_cast(kind: SyntaxKind) -> bool {
2742         match kind {
2743             REFERENCE_TYPE => true,
2744             _ => false,
2745         }
2746     }
2747     fn cast(syntax: SyntaxNode) -> Option<Self> {
2748         if Self::can_cast(syntax.kind()) {
2749             Some(Self { syntax })
2750         } else {
2751             None
2752         }
2753     }
2754     fn syntax(&self) -> &SyntaxNode {
2755         &self.syntax
2756     }
2757 }
2758 impl ReferenceType {
2759     pub fn type_ref(&self) -> Option<TypeRef> {
2760         AstChildren::new(&self.syntax).next()
2761     }
2762 }
2763 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2764 pub struct RetType {
2765     pub(crate) syntax: SyntaxNode,
2766 }
2767 impl AstNode for RetType {
2768     fn can_cast(kind: SyntaxKind) -> bool {
2769         match kind {
2770             RET_TYPE => true,
2771             _ => false,
2772         }
2773     }
2774     fn cast(syntax: SyntaxNode) -> Option<Self> {
2775         if Self::can_cast(syntax.kind()) {
2776             Some(Self { syntax })
2777         } else {
2778             None
2779         }
2780     }
2781     fn syntax(&self) -> &SyntaxNode {
2782         &self.syntax
2783     }
2784 }
2785 impl RetType {
2786     pub fn type_ref(&self) -> Option<TypeRef> {
2787         AstChildren::new(&self.syntax).next()
2788     }
2789 }
2790 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2791 pub struct ReturnExpr {
2792     pub(crate) syntax: SyntaxNode,
2793 }
2794 impl AstNode for ReturnExpr {
2795     fn can_cast(kind: SyntaxKind) -> bool {
2796         match kind {
2797             RETURN_EXPR => true,
2798             _ => false,
2799         }
2800     }
2801     fn cast(syntax: SyntaxNode) -> Option<Self> {
2802         if Self::can_cast(syntax.kind()) {
2803             Some(Self { syntax })
2804         } else {
2805             None
2806         }
2807     }
2808     fn syntax(&self) -> &SyntaxNode {
2809         &self.syntax
2810     }
2811 }
2812 impl ReturnExpr {
2813     pub fn expr(&self) -> Option<Expr> {
2814         AstChildren::new(&self.syntax).next()
2815     }
2816 }
2817 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2818 pub struct SelfParam {
2819     pub(crate) syntax: SyntaxNode,
2820 }
2821 impl AstNode for SelfParam {
2822     fn can_cast(kind: SyntaxKind) -> bool {
2823         match kind {
2824             SELF_PARAM => true,
2825             _ => false,
2826         }
2827     }
2828     fn cast(syntax: SyntaxNode) -> Option<Self> {
2829         if Self::can_cast(syntax.kind()) {
2830             Some(Self { syntax })
2831         } else {
2832             None
2833         }
2834     }
2835     fn syntax(&self) -> &SyntaxNode {
2836         &self.syntax
2837     }
2838 }
2839 impl ast::TypeAscriptionOwner for SelfParam {}
2840 impl ast::AttrsOwner for SelfParam {}
2841 impl SelfParam {}
2842 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2843 pub struct SlicePat {
2844     pub(crate) syntax: SyntaxNode,
2845 }
2846 impl AstNode for SlicePat {
2847     fn can_cast(kind: SyntaxKind) -> bool {
2848         match kind {
2849             SLICE_PAT => true,
2850             _ => false,
2851         }
2852     }
2853     fn cast(syntax: SyntaxNode) -> Option<Self> {
2854         if Self::can_cast(syntax.kind()) {
2855             Some(Self { syntax })
2856         } else {
2857             None
2858         }
2859     }
2860     fn syntax(&self) -> &SyntaxNode {
2861         &self.syntax
2862     }
2863 }
2864 impl SlicePat {}
2865 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2866 pub struct SliceType {
2867     pub(crate) syntax: SyntaxNode,
2868 }
2869 impl AstNode for SliceType {
2870     fn can_cast(kind: SyntaxKind) -> bool {
2871         match kind {
2872             SLICE_TYPE => true,
2873             _ => false,
2874         }
2875     }
2876     fn cast(syntax: SyntaxNode) -> Option<Self> {
2877         if Self::can_cast(syntax.kind()) {
2878             Some(Self { syntax })
2879         } else {
2880             None
2881         }
2882     }
2883     fn syntax(&self) -> &SyntaxNode {
2884         &self.syntax
2885     }
2886 }
2887 impl SliceType {
2888     pub fn type_ref(&self) -> Option<TypeRef> {
2889         AstChildren::new(&self.syntax).next()
2890     }
2891 }
2892 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2893 pub struct SourceFile {
2894     pub(crate) syntax: SyntaxNode,
2895 }
2896 impl AstNode for SourceFile {
2897     fn can_cast(kind: SyntaxKind) -> bool {
2898         match kind {
2899             SOURCE_FILE => true,
2900             _ => false,
2901         }
2902     }
2903     fn cast(syntax: SyntaxNode) -> Option<Self> {
2904         if Self::can_cast(syntax.kind()) {
2905             Some(Self { syntax })
2906         } else {
2907             None
2908         }
2909     }
2910     fn syntax(&self) -> &SyntaxNode {
2911         &self.syntax
2912     }
2913 }
2914 impl ast::ModuleItemOwner for SourceFile {}
2915 impl ast::FnDefOwner for SourceFile {}
2916 impl SourceFile {
2917     pub fn modules(&self) -> AstChildren<Module> {
2918         AstChildren::new(&self.syntax)
2919     }
2920 }
2921 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2922 pub struct StaticDef {
2923     pub(crate) syntax: SyntaxNode,
2924 }
2925 impl AstNode for StaticDef {
2926     fn can_cast(kind: SyntaxKind) -> bool {
2927         match kind {
2928             STATIC_DEF => true,
2929             _ => false,
2930         }
2931     }
2932     fn cast(syntax: SyntaxNode) -> Option<Self> {
2933         if Self::can_cast(syntax.kind()) {
2934             Some(Self { syntax })
2935         } else {
2936             None
2937         }
2938     }
2939     fn syntax(&self) -> &SyntaxNode {
2940         &self.syntax
2941     }
2942 }
2943 impl ast::VisibilityOwner for StaticDef {}
2944 impl ast::NameOwner for StaticDef {}
2945 impl ast::TypeParamsOwner for StaticDef {}
2946 impl ast::AttrsOwner for StaticDef {}
2947 impl ast::DocCommentsOwner for StaticDef {}
2948 impl ast::TypeAscriptionOwner for StaticDef {}
2949 impl StaticDef {
2950     pub fn body(&self) -> Option<Expr> {
2951         AstChildren::new(&self.syntax).next()
2952     }
2953 }
2954 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2955 pub enum Stmt {
2956     ExprStmt(ExprStmt),
2957     LetStmt(LetStmt),
2958 }
2959 impl From<ExprStmt> for Stmt {
2960     fn from(node: ExprStmt) -> Stmt {
2961         Stmt::ExprStmt(node)
2962     }
2963 }
2964 impl From<LetStmt> for Stmt {
2965     fn from(node: LetStmt) -> Stmt {
2966         Stmt::LetStmt(node)
2967     }
2968 }
2969 impl AstNode for Stmt {
2970     fn can_cast(kind: SyntaxKind) -> bool {
2971         match kind {
2972             EXPR_STMT | LET_STMT => true,
2973             _ => false,
2974         }
2975     }
2976     fn cast(syntax: SyntaxNode) -> Option<Self> {
2977         let res = match syntax.kind() {
2978             EXPR_STMT => Stmt::ExprStmt(ExprStmt { syntax }),
2979             LET_STMT => Stmt::LetStmt(LetStmt { syntax }),
2980             _ => return None,
2981         };
2982         Some(res)
2983     }
2984     fn syntax(&self) -> &SyntaxNode {
2985         match self {
2986             Stmt::ExprStmt(it) => &it.syntax,
2987             Stmt::LetStmt(it) => &it.syntax,
2988         }
2989     }
2990 }
2991 impl Stmt {}
2992 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
2993 pub struct StructDef {
2994     pub(crate) syntax: SyntaxNode,
2995 }
2996 impl AstNode for StructDef {
2997     fn can_cast(kind: SyntaxKind) -> bool {
2998         match kind {
2999             STRUCT_DEF => true,
3000             _ => false,
3001         }
3002     }
3003     fn cast(syntax: SyntaxNode) -> Option<Self> {
3004         if Self::can_cast(syntax.kind()) {
3005             Some(Self { syntax })
3006         } else {
3007             None
3008         }
3009     }
3010     fn syntax(&self) -> &SyntaxNode {
3011         &self.syntax
3012     }
3013 }
3014 impl ast::VisibilityOwner for StructDef {}
3015 impl ast::NameOwner for StructDef {}
3016 impl ast::TypeParamsOwner for StructDef {}
3017 impl ast::AttrsOwner for StructDef {}
3018 impl ast::DocCommentsOwner for StructDef {}
3019 impl StructDef {}
3020 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3021 pub struct StructLit {
3022     pub(crate) syntax: SyntaxNode,
3023 }
3024 impl AstNode for StructLit {
3025     fn can_cast(kind: SyntaxKind) -> bool {
3026         match kind {
3027             STRUCT_LIT => true,
3028             _ => false,
3029         }
3030     }
3031     fn cast(syntax: SyntaxNode) -> Option<Self> {
3032         if Self::can_cast(syntax.kind()) {
3033             Some(Self { syntax })
3034         } else {
3035             None
3036         }
3037     }
3038     fn syntax(&self) -> &SyntaxNode {
3039         &self.syntax
3040     }
3041 }
3042 impl StructLit {
3043     pub fn path(&self) -> Option<Path> {
3044         AstChildren::new(&self.syntax).next()
3045     }
3046     pub fn named_field_list(&self) -> Option<NamedFieldList> {
3047         AstChildren::new(&self.syntax).next()
3048     }
3049 }
3050 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3051 pub struct StructPat {
3052     pub(crate) syntax: SyntaxNode,
3053 }
3054 impl AstNode for StructPat {
3055     fn can_cast(kind: SyntaxKind) -> bool {
3056         match kind {
3057             STRUCT_PAT => true,
3058             _ => false,
3059         }
3060     }
3061     fn cast(syntax: SyntaxNode) -> Option<Self> {
3062         if Self::can_cast(syntax.kind()) {
3063             Some(Self { syntax })
3064         } else {
3065             None
3066         }
3067     }
3068     fn syntax(&self) -> &SyntaxNode {
3069         &self.syntax
3070     }
3071 }
3072 impl StructPat {
3073     pub fn field_pat_list(&self) -> Option<FieldPatList> {
3074         AstChildren::new(&self.syntax).next()
3075     }
3076     pub fn path(&self) -> Option<Path> {
3077         AstChildren::new(&self.syntax).next()
3078     }
3079 }
3080 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3081 pub struct TokenTree {
3082     pub(crate) syntax: SyntaxNode,
3083 }
3084 impl AstNode for TokenTree {
3085     fn can_cast(kind: SyntaxKind) -> bool {
3086         match kind {
3087             TOKEN_TREE => 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 TokenTree {}
3103 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3104 pub struct TraitDef {
3105     pub(crate) syntax: SyntaxNode,
3106 }
3107 impl AstNode for TraitDef {
3108     fn can_cast(kind: SyntaxKind) -> bool {
3109         match kind {
3110             TRAIT_DEF => true,
3111             _ => false,
3112         }
3113     }
3114     fn cast(syntax: SyntaxNode) -> Option<Self> {
3115         if Self::can_cast(syntax.kind()) {
3116             Some(Self { syntax })
3117         } else {
3118             None
3119         }
3120     }
3121     fn syntax(&self) -> &SyntaxNode {
3122         &self.syntax
3123     }
3124 }
3125 impl ast::VisibilityOwner for TraitDef {}
3126 impl ast::NameOwner for TraitDef {}
3127 impl ast::AttrsOwner for TraitDef {}
3128 impl ast::DocCommentsOwner for TraitDef {}
3129 impl ast::TypeParamsOwner for TraitDef {}
3130 impl ast::TypeBoundsOwner for TraitDef {}
3131 impl TraitDef {
3132     pub fn item_list(&self) -> Option<ItemList> {
3133         AstChildren::new(&self.syntax).next()
3134     }
3135 }
3136 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3137 pub struct TryBlockExpr {
3138     pub(crate) syntax: SyntaxNode,
3139 }
3140 impl AstNode for TryBlockExpr {
3141     fn can_cast(kind: SyntaxKind) -> bool {
3142         match kind {
3143             TRY_BLOCK_EXPR => true,
3144             _ => false,
3145         }
3146     }
3147     fn cast(syntax: SyntaxNode) -> Option<Self> {
3148         if Self::can_cast(syntax.kind()) {
3149             Some(Self { syntax })
3150         } else {
3151             None
3152         }
3153     }
3154     fn syntax(&self) -> &SyntaxNode {
3155         &self.syntax
3156     }
3157 }
3158 impl ast::TryBlockBodyOwner for TryBlockExpr {}
3159 impl TryBlockExpr {}
3160 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3161 pub struct TryExpr {
3162     pub(crate) syntax: SyntaxNode,
3163 }
3164 impl AstNode for TryExpr {
3165     fn can_cast(kind: SyntaxKind) -> bool {
3166         match kind {
3167             TRY_EXPR => true,
3168             _ => false,
3169         }
3170     }
3171     fn cast(syntax: SyntaxNode) -> Option<Self> {
3172         if Self::can_cast(syntax.kind()) {
3173             Some(Self { syntax })
3174         } else {
3175             None
3176         }
3177     }
3178     fn syntax(&self) -> &SyntaxNode {
3179         &self.syntax
3180     }
3181 }
3182 impl TryExpr {
3183     pub fn expr(&self) -> Option<Expr> {
3184         AstChildren::new(&self.syntax).next()
3185     }
3186 }
3187 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
3188 pub struct TupleExpr {
3189     pub(crate) syntax: SyntaxNode,
3190 }
3191 impl AstNode for TupleExpr {
3192     fn can_cast(kind: SyntaxKind) -> bool {
3193         match kind {
3194             TUPLE_EXPR => 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 TupleExpr {
3210     pub fn exprs(&self) -> AstChildren<Expr> {
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 }