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