]> git.lizzy.rs Git - rust.git/blob - crates/ra_syntax/src/ast/generated.rs
Added local macro goto
[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 ast::DocCommentsOwner for MacroCall {}
1765 impl MacroCall {
1766     pub fn token_tree(&self) -> Option<&TokenTree> {
1767         super::child_opt(self)
1768     }
1769
1770     pub fn path(&self) -> Option<&Path> {
1771         super::child_opt(self)
1772     }
1773 }
1774
1775 // MacroItems
1776 #[derive(Debug, PartialEq, Eq, Hash)]
1777 #[repr(transparent)]
1778 pub struct MacroItems {
1779     pub(crate) syntax: SyntaxNode,
1780 }
1781 unsafe impl TransparentNewType for MacroItems {
1782     type Repr = rowan::SyntaxNode;
1783 }
1784
1785 impl AstNode for MacroItems {
1786     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1787         match syntax.kind() {
1788             MACRO_ITEMS => Some(MacroItems::from_repr(syntax.into_repr())),
1789             _ => None,
1790         }
1791     }
1792     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1793 }
1794
1795 impl ToOwned for MacroItems {
1796     type Owned = TreeArc<MacroItems>;
1797     fn to_owned(&self) -> TreeArc<MacroItems> { TreeArc::cast(self.syntax.to_owned()) }
1798 }
1799
1800
1801 impl ast::ModuleItemOwner for MacroItems {}
1802 impl ast::FnDefOwner for MacroItems {}
1803 impl MacroItems {}
1804
1805 // MacroStmts
1806 #[derive(Debug, PartialEq, Eq, Hash)]
1807 #[repr(transparent)]
1808 pub struct MacroStmts {
1809     pub(crate) syntax: SyntaxNode,
1810 }
1811 unsafe impl TransparentNewType for MacroStmts {
1812     type Repr = rowan::SyntaxNode;
1813 }
1814
1815 impl AstNode for MacroStmts {
1816     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1817         match syntax.kind() {
1818             MACRO_STMTS => Some(MacroStmts::from_repr(syntax.into_repr())),
1819             _ => None,
1820         }
1821     }
1822     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1823 }
1824
1825 impl ToOwned for MacroStmts {
1826     type Owned = TreeArc<MacroStmts>;
1827     fn to_owned(&self) -> TreeArc<MacroStmts> { TreeArc::cast(self.syntax.to_owned()) }
1828 }
1829
1830
1831 impl MacroStmts {
1832     pub fn statements(&self) -> impl Iterator<Item = &Stmt> {
1833         super::children(self)
1834     }
1835
1836     pub fn expr(&self) -> Option<&Expr> {
1837         super::child_opt(self)
1838     }
1839 }
1840
1841 // MatchArm
1842 #[derive(Debug, PartialEq, Eq, Hash)]
1843 #[repr(transparent)]
1844 pub struct MatchArm {
1845     pub(crate) syntax: SyntaxNode,
1846 }
1847 unsafe impl TransparentNewType for MatchArm {
1848     type Repr = rowan::SyntaxNode;
1849 }
1850
1851 impl AstNode for MatchArm {
1852     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1853         match syntax.kind() {
1854             MATCH_ARM => Some(MatchArm::from_repr(syntax.into_repr())),
1855             _ => None,
1856         }
1857     }
1858     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1859 }
1860
1861 impl ToOwned for MatchArm {
1862     type Owned = TreeArc<MatchArm>;
1863     fn to_owned(&self) -> TreeArc<MatchArm> { TreeArc::cast(self.syntax.to_owned()) }
1864 }
1865
1866
1867 impl ast::AttrsOwner for MatchArm {}
1868 impl MatchArm {
1869     pub fn pats(&self) -> impl Iterator<Item = &Pat> {
1870         super::children(self)
1871     }
1872
1873     pub fn guard(&self) -> Option<&MatchGuard> {
1874         super::child_opt(self)
1875     }
1876
1877     pub fn expr(&self) -> Option<&Expr> {
1878         super::child_opt(self)
1879     }
1880 }
1881
1882 // MatchArmList
1883 #[derive(Debug, PartialEq, Eq, Hash)]
1884 #[repr(transparent)]
1885 pub struct MatchArmList {
1886     pub(crate) syntax: SyntaxNode,
1887 }
1888 unsafe impl TransparentNewType for MatchArmList {
1889     type Repr = rowan::SyntaxNode;
1890 }
1891
1892 impl AstNode for MatchArmList {
1893     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1894         match syntax.kind() {
1895             MATCH_ARM_LIST => Some(MatchArmList::from_repr(syntax.into_repr())),
1896             _ => None,
1897         }
1898     }
1899     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1900 }
1901
1902 impl ToOwned for MatchArmList {
1903     type Owned = TreeArc<MatchArmList>;
1904     fn to_owned(&self) -> TreeArc<MatchArmList> { TreeArc::cast(self.syntax.to_owned()) }
1905 }
1906
1907
1908 impl ast::AttrsOwner for MatchArmList {}
1909 impl MatchArmList {
1910     pub fn arms(&self) -> impl Iterator<Item = &MatchArm> {
1911         super::children(self)
1912     }
1913 }
1914
1915 // MatchExpr
1916 #[derive(Debug, PartialEq, Eq, Hash)]
1917 #[repr(transparent)]
1918 pub struct MatchExpr {
1919     pub(crate) syntax: SyntaxNode,
1920 }
1921 unsafe impl TransparentNewType for MatchExpr {
1922     type Repr = rowan::SyntaxNode;
1923 }
1924
1925 impl AstNode for MatchExpr {
1926     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1927         match syntax.kind() {
1928             MATCH_EXPR => Some(MatchExpr::from_repr(syntax.into_repr())),
1929             _ => None,
1930         }
1931     }
1932     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1933 }
1934
1935 impl ToOwned for MatchExpr {
1936     type Owned = TreeArc<MatchExpr>;
1937     fn to_owned(&self) -> TreeArc<MatchExpr> { TreeArc::cast(self.syntax.to_owned()) }
1938 }
1939
1940
1941 impl MatchExpr {
1942     pub fn expr(&self) -> Option<&Expr> {
1943         super::child_opt(self)
1944     }
1945
1946     pub fn match_arm_list(&self) -> Option<&MatchArmList> {
1947         super::child_opt(self)
1948     }
1949 }
1950
1951 // MatchGuard
1952 #[derive(Debug, PartialEq, Eq, Hash)]
1953 #[repr(transparent)]
1954 pub struct MatchGuard {
1955     pub(crate) syntax: SyntaxNode,
1956 }
1957 unsafe impl TransparentNewType for MatchGuard {
1958     type Repr = rowan::SyntaxNode;
1959 }
1960
1961 impl AstNode for MatchGuard {
1962     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1963         match syntax.kind() {
1964             MATCH_GUARD => Some(MatchGuard::from_repr(syntax.into_repr())),
1965             _ => None,
1966         }
1967     }
1968     fn syntax(&self) -> &SyntaxNode { &self.syntax }
1969 }
1970
1971 impl ToOwned for MatchGuard {
1972     type Owned = TreeArc<MatchGuard>;
1973     fn to_owned(&self) -> TreeArc<MatchGuard> { TreeArc::cast(self.syntax.to_owned()) }
1974 }
1975
1976
1977 impl MatchGuard {
1978     pub fn expr(&self) -> Option<&Expr> {
1979         super::child_opt(self)
1980     }
1981 }
1982
1983 // MethodCallExpr
1984 #[derive(Debug, PartialEq, Eq, Hash)]
1985 #[repr(transparent)]
1986 pub struct MethodCallExpr {
1987     pub(crate) syntax: SyntaxNode,
1988 }
1989 unsafe impl TransparentNewType for MethodCallExpr {
1990     type Repr = rowan::SyntaxNode;
1991 }
1992
1993 impl AstNode for MethodCallExpr {
1994     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1995         match syntax.kind() {
1996             METHOD_CALL_EXPR => Some(MethodCallExpr::from_repr(syntax.into_repr())),
1997             _ => None,
1998         }
1999     }
2000     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2001 }
2002
2003 impl ToOwned for MethodCallExpr {
2004     type Owned = TreeArc<MethodCallExpr>;
2005     fn to_owned(&self) -> TreeArc<MethodCallExpr> { TreeArc::cast(self.syntax.to_owned()) }
2006 }
2007
2008
2009 impl ast::ArgListOwner for MethodCallExpr {}
2010 impl MethodCallExpr {
2011     pub fn expr(&self) -> Option<&Expr> {
2012         super::child_opt(self)
2013     }
2014
2015     pub fn name_ref(&self) -> Option<&NameRef> {
2016         super::child_opt(self)
2017     }
2018
2019     pub fn type_arg_list(&self) -> Option<&TypeArgList> {
2020         super::child_opt(self)
2021     }
2022 }
2023
2024 // Module
2025 #[derive(Debug, PartialEq, Eq, Hash)]
2026 #[repr(transparent)]
2027 pub struct Module {
2028     pub(crate) syntax: SyntaxNode,
2029 }
2030 unsafe impl TransparentNewType for Module {
2031     type Repr = rowan::SyntaxNode;
2032 }
2033
2034 impl AstNode for Module {
2035     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2036         match syntax.kind() {
2037             MODULE => Some(Module::from_repr(syntax.into_repr())),
2038             _ => None,
2039         }
2040     }
2041     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2042 }
2043
2044 impl ToOwned for Module {
2045     type Owned = TreeArc<Module>;
2046     fn to_owned(&self) -> TreeArc<Module> { TreeArc::cast(self.syntax.to_owned()) }
2047 }
2048
2049
2050 impl ast::VisibilityOwner for Module {}
2051 impl ast::NameOwner for Module {}
2052 impl ast::AttrsOwner for Module {}
2053 impl ast::DocCommentsOwner for Module {}
2054 impl Module {
2055     pub fn item_list(&self) -> Option<&ItemList> {
2056         super::child_opt(self)
2057     }
2058 }
2059
2060 // ModuleItem
2061 #[derive(Debug, PartialEq, Eq, Hash)]
2062 #[repr(transparent)]
2063 pub struct ModuleItem {
2064     pub(crate) syntax: SyntaxNode,
2065 }
2066 unsafe impl TransparentNewType for ModuleItem {
2067     type Repr = rowan::SyntaxNode;
2068 }
2069
2070 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2071 pub enum ModuleItemKind<'a> {
2072     StructDef(&'a StructDef),
2073     EnumDef(&'a EnumDef),
2074     FnDef(&'a FnDef),
2075     TraitDef(&'a TraitDef),
2076     TypeAliasDef(&'a TypeAliasDef),
2077     ImplBlock(&'a ImplBlock),
2078     UseItem(&'a UseItem),
2079     ExternCrateItem(&'a ExternCrateItem),
2080     ConstDef(&'a ConstDef),
2081     StaticDef(&'a StaticDef),
2082     Module(&'a Module),
2083 }
2084 impl<'a> From<&'a StructDef> for &'a ModuleItem {
2085     fn from(n: &'a StructDef) -> &'a ModuleItem {
2086         ModuleItem::cast(&n.syntax).unwrap()
2087     }
2088 }
2089 impl<'a> From<&'a EnumDef> for &'a ModuleItem {
2090     fn from(n: &'a EnumDef) -> &'a ModuleItem {
2091         ModuleItem::cast(&n.syntax).unwrap()
2092     }
2093 }
2094 impl<'a> From<&'a FnDef> for &'a ModuleItem {
2095     fn from(n: &'a FnDef) -> &'a ModuleItem {
2096         ModuleItem::cast(&n.syntax).unwrap()
2097     }
2098 }
2099 impl<'a> From<&'a TraitDef> for &'a ModuleItem {
2100     fn from(n: &'a TraitDef) -> &'a ModuleItem {
2101         ModuleItem::cast(&n.syntax).unwrap()
2102     }
2103 }
2104 impl<'a> From<&'a TypeAliasDef> for &'a ModuleItem {
2105     fn from(n: &'a TypeAliasDef) -> &'a ModuleItem {
2106         ModuleItem::cast(&n.syntax).unwrap()
2107     }
2108 }
2109 impl<'a> From<&'a ImplBlock> for &'a ModuleItem {
2110     fn from(n: &'a ImplBlock) -> &'a ModuleItem {
2111         ModuleItem::cast(&n.syntax).unwrap()
2112     }
2113 }
2114 impl<'a> From<&'a UseItem> for &'a ModuleItem {
2115     fn from(n: &'a UseItem) -> &'a ModuleItem {
2116         ModuleItem::cast(&n.syntax).unwrap()
2117     }
2118 }
2119 impl<'a> From<&'a ExternCrateItem> for &'a ModuleItem {
2120     fn from(n: &'a ExternCrateItem) -> &'a ModuleItem {
2121         ModuleItem::cast(&n.syntax).unwrap()
2122     }
2123 }
2124 impl<'a> From<&'a ConstDef> for &'a ModuleItem {
2125     fn from(n: &'a ConstDef) -> &'a ModuleItem {
2126         ModuleItem::cast(&n.syntax).unwrap()
2127     }
2128 }
2129 impl<'a> From<&'a StaticDef> for &'a ModuleItem {
2130     fn from(n: &'a StaticDef) -> &'a ModuleItem {
2131         ModuleItem::cast(&n.syntax).unwrap()
2132     }
2133 }
2134 impl<'a> From<&'a Module> for &'a ModuleItem {
2135     fn from(n: &'a Module) -> &'a ModuleItem {
2136         ModuleItem::cast(&n.syntax).unwrap()
2137     }
2138 }
2139
2140
2141 impl AstNode for ModuleItem {
2142     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2143         match syntax.kind() {
2144             | STRUCT_DEF
2145             | ENUM_DEF
2146             | FN_DEF
2147             | TRAIT_DEF
2148             | TYPE_ALIAS_DEF
2149             | IMPL_BLOCK
2150             | USE_ITEM
2151             | EXTERN_CRATE_ITEM
2152             | CONST_DEF
2153             | STATIC_DEF
2154             | MODULE => Some(ModuleItem::from_repr(syntax.into_repr())),
2155             _ => None,
2156         }
2157     }
2158     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2159 }
2160
2161 impl ToOwned for ModuleItem {
2162     type Owned = TreeArc<ModuleItem>;
2163     fn to_owned(&self) -> TreeArc<ModuleItem> { TreeArc::cast(self.syntax.to_owned()) }
2164 }
2165
2166 impl ModuleItem {
2167     pub fn kind(&self) -> ModuleItemKind {
2168         match self.syntax.kind() {
2169             STRUCT_DEF => ModuleItemKind::StructDef(StructDef::cast(&self.syntax).unwrap()),
2170             ENUM_DEF => ModuleItemKind::EnumDef(EnumDef::cast(&self.syntax).unwrap()),
2171             FN_DEF => ModuleItemKind::FnDef(FnDef::cast(&self.syntax).unwrap()),
2172             TRAIT_DEF => ModuleItemKind::TraitDef(TraitDef::cast(&self.syntax).unwrap()),
2173             TYPE_ALIAS_DEF => ModuleItemKind::TypeAliasDef(TypeAliasDef::cast(&self.syntax).unwrap()),
2174             IMPL_BLOCK => ModuleItemKind::ImplBlock(ImplBlock::cast(&self.syntax).unwrap()),
2175             USE_ITEM => ModuleItemKind::UseItem(UseItem::cast(&self.syntax).unwrap()),
2176             EXTERN_CRATE_ITEM => ModuleItemKind::ExternCrateItem(ExternCrateItem::cast(&self.syntax).unwrap()),
2177             CONST_DEF => ModuleItemKind::ConstDef(ConstDef::cast(&self.syntax).unwrap()),
2178             STATIC_DEF => ModuleItemKind::StaticDef(StaticDef::cast(&self.syntax).unwrap()),
2179             MODULE => ModuleItemKind::Module(Module::cast(&self.syntax).unwrap()),
2180             _ => unreachable!(),
2181         }
2182     }
2183 }
2184
2185 impl ModuleItem {}
2186
2187 // Name
2188 #[derive(Debug, PartialEq, Eq, Hash)]
2189 #[repr(transparent)]
2190 pub struct Name {
2191     pub(crate) syntax: SyntaxNode,
2192 }
2193 unsafe impl TransparentNewType for Name {
2194     type Repr = rowan::SyntaxNode;
2195 }
2196
2197 impl AstNode for Name {
2198     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2199         match syntax.kind() {
2200             NAME => Some(Name::from_repr(syntax.into_repr())),
2201             _ => None,
2202         }
2203     }
2204     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2205 }
2206
2207 impl ToOwned for Name {
2208     type Owned = TreeArc<Name>;
2209     fn to_owned(&self) -> TreeArc<Name> { TreeArc::cast(self.syntax.to_owned()) }
2210 }
2211
2212
2213 impl Name {}
2214
2215 // NameRef
2216 #[derive(Debug, PartialEq, Eq, Hash)]
2217 #[repr(transparent)]
2218 pub struct NameRef {
2219     pub(crate) syntax: SyntaxNode,
2220 }
2221 unsafe impl TransparentNewType for NameRef {
2222     type Repr = rowan::SyntaxNode;
2223 }
2224
2225 impl AstNode for NameRef {
2226     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2227         match syntax.kind() {
2228             NAME_REF => Some(NameRef::from_repr(syntax.into_repr())),
2229             _ => None,
2230         }
2231     }
2232     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2233 }
2234
2235 impl ToOwned for NameRef {
2236     type Owned = TreeArc<NameRef>;
2237     fn to_owned(&self) -> TreeArc<NameRef> { TreeArc::cast(self.syntax.to_owned()) }
2238 }
2239
2240
2241 impl NameRef {}
2242
2243 // NamedField
2244 #[derive(Debug, PartialEq, Eq, Hash)]
2245 #[repr(transparent)]
2246 pub struct NamedField {
2247     pub(crate) syntax: SyntaxNode,
2248 }
2249 unsafe impl TransparentNewType for NamedField {
2250     type Repr = rowan::SyntaxNode;
2251 }
2252
2253 impl AstNode for NamedField {
2254     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2255         match syntax.kind() {
2256             NAMED_FIELD => Some(NamedField::from_repr(syntax.into_repr())),
2257             _ => None,
2258         }
2259     }
2260     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2261 }
2262
2263 impl ToOwned for NamedField {
2264     type Owned = TreeArc<NamedField>;
2265     fn to_owned(&self) -> TreeArc<NamedField> { TreeArc::cast(self.syntax.to_owned()) }
2266 }
2267
2268
2269 impl NamedField {
2270     pub fn name_ref(&self) -> Option<&NameRef> {
2271         super::child_opt(self)
2272     }
2273
2274     pub fn expr(&self) -> Option<&Expr> {
2275         super::child_opt(self)
2276     }
2277 }
2278
2279 // NamedFieldDef
2280 #[derive(Debug, PartialEq, Eq, Hash)]
2281 #[repr(transparent)]
2282 pub struct NamedFieldDef {
2283     pub(crate) syntax: SyntaxNode,
2284 }
2285 unsafe impl TransparentNewType for NamedFieldDef {
2286     type Repr = rowan::SyntaxNode;
2287 }
2288
2289 impl AstNode for NamedFieldDef {
2290     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2291         match syntax.kind() {
2292             NAMED_FIELD_DEF => Some(NamedFieldDef::from_repr(syntax.into_repr())),
2293             _ => None,
2294         }
2295     }
2296     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2297 }
2298
2299 impl ToOwned for NamedFieldDef {
2300     type Owned = TreeArc<NamedFieldDef>;
2301     fn to_owned(&self) -> TreeArc<NamedFieldDef> { TreeArc::cast(self.syntax.to_owned()) }
2302 }
2303
2304
2305 impl ast::VisibilityOwner for NamedFieldDef {}
2306 impl ast::NameOwner for NamedFieldDef {}
2307 impl ast::AttrsOwner for NamedFieldDef {}
2308 impl ast::DocCommentsOwner for NamedFieldDef {}
2309 impl ast::TypeAscriptionOwner for NamedFieldDef {}
2310 impl NamedFieldDef {}
2311
2312 // NamedFieldDefList
2313 #[derive(Debug, PartialEq, Eq, Hash)]
2314 #[repr(transparent)]
2315 pub struct NamedFieldDefList {
2316     pub(crate) syntax: SyntaxNode,
2317 }
2318 unsafe impl TransparentNewType for NamedFieldDefList {
2319     type Repr = rowan::SyntaxNode;
2320 }
2321
2322 impl AstNode for NamedFieldDefList {
2323     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2324         match syntax.kind() {
2325             NAMED_FIELD_DEF_LIST => Some(NamedFieldDefList::from_repr(syntax.into_repr())),
2326             _ => None,
2327         }
2328     }
2329     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2330 }
2331
2332 impl ToOwned for NamedFieldDefList {
2333     type Owned = TreeArc<NamedFieldDefList>;
2334     fn to_owned(&self) -> TreeArc<NamedFieldDefList> { TreeArc::cast(self.syntax.to_owned()) }
2335 }
2336
2337
2338 impl NamedFieldDefList {
2339     pub fn fields(&self) -> impl Iterator<Item = &NamedFieldDef> {
2340         super::children(self)
2341     }
2342 }
2343
2344 // NamedFieldList
2345 #[derive(Debug, PartialEq, Eq, Hash)]
2346 #[repr(transparent)]
2347 pub struct NamedFieldList {
2348     pub(crate) syntax: SyntaxNode,
2349 }
2350 unsafe impl TransparentNewType for NamedFieldList {
2351     type Repr = rowan::SyntaxNode;
2352 }
2353
2354 impl AstNode for NamedFieldList {
2355     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2356         match syntax.kind() {
2357             NAMED_FIELD_LIST => Some(NamedFieldList::from_repr(syntax.into_repr())),
2358             _ => None,
2359         }
2360     }
2361     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2362 }
2363
2364 impl ToOwned for NamedFieldList {
2365     type Owned = TreeArc<NamedFieldList>;
2366     fn to_owned(&self) -> TreeArc<NamedFieldList> { TreeArc::cast(self.syntax.to_owned()) }
2367 }
2368
2369
2370 impl NamedFieldList {
2371     pub fn fields(&self) -> impl Iterator<Item = &NamedField> {
2372         super::children(self)
2373     }
2374 }
2375
2376 // NeverType
2377 #[derive(Debug, PartialEq, Eq, Hash)]
2378 #[repr(transparent)]
2379 pub struct NeverType {
2380     pub(crate) syntax: SyntaxNode,
2381 }
2382 unsafe impl TransparentNewType for NeverType {
2383     type Repr = rowan::SyntaxNode;
2384 }
2385
2386 impl AstNode for NeverType {
2387     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2388         match syntax.kind() {
2389             NEVER_TYPE => Some(NeverType::from_repr(syntax.into_repr())),
2390             _ => None,
2391         }
2392     }
2393     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2394 }
2395
2396 impl ToOwned for NeverType {
2397     type Owned = TreeArc<NeverType>;
2398     fn to_owned(&self) -> TreeArc<NeverType> { TreeArc::cast(self.syntax.to_owned()) }
2399 }
2400
2401
2402 impl NeverType {}
2403
2404 // NominalDef
2405 #[derive(Debug, PartialEq, Eq, Hash)]
2406 #[repr(transparent)]
2407 pub struct NominalDef {
2408     pub(crate) syntax: SyntaxNode,
2409 }
2410 unsafe impl TransparentNewType for NominalDef {
2411     type Repr = rowan::SyntaxNode;
2412 }
2413
2414 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2415 pub enum NominalDefKind<'a> {
2416     StructDef(&'a StructDef),
2417     EnumDef(&'a EnumDef),
2418 }
2419 impl<'a> From<&'a StructDef> for &'a NominalDef {
2420     fn from(n: &'a StructDef) -> &'a NominalDef {
2421         NominalDef::cast(&n.syntax).unwrap()
2422     }
2423 }
2424 impl<'a> From<&'a EnumDef> for &'a NominalDef {
2425     fn from(n: &'a EnumDef) -> &'a NominalDef {
2426         NominalDef::cast(&n.syntax).unwrap()
2427     }
2428 }
2429
2430
2431 impl AstNode for NominalDef {
2432     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2433         match syntax.kind() {
2434             | STRUCT_DEF
2435             | ENUM_DEF => Some(NominalDef::from_repr(syntax.into_repr())),
2436             _ => None,
2437         }
2438     }
2439     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2440 }
2441
2442 impl ToOwned for NominalDef {
2443     type Owned = TreeArc<NominalDef>;
2444     fn to_owned(&self) -> TreeArc<NominalDef> { TreeArc::cast(self.syntax.to_owned()) }
2445 }
2446
2447 impl NominalDef {
2448     pub fn kind(&self) -> NominalDefKind {
2449         match self.syntax.kind() {
2450             STRUCT_DEF => NominalDefKind::StructDef(StructDef::cast(&self.syntax).unwrap()),
2451             ENUM_DEF => NominalDefKind::EnumDef(EnumDef::cast(&self.syntax).unwrap()),
2452             _ => unreachable!(),
2453         }
2454     }
2455 }
2456
2457 impl ast::NameOwner for NominalDef {}
2458 impl ast::TypeParamsOwner for NominalDef {}
2459 impl ast::AttrsOwner for NominalDef {}
2460 impl NominalDef {}
2461
2462 // Param
2463 #[derive(Debug, PartialEq, Eq, Hash)]
2464 #[repr(transparent)]
2465 pub struct Param {
2466     pub(crate) syntax: SyntaxNode,
2467 }
2468 unsafe impl TransparentNewType for Param {
2469     type Repr = rowan::SyntaxNode;
2470 }
2471
2472 impl AstNode for Param {
2473     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2474         match syntax.kind() {
2475             PARAM => Some(Param::from_repr(syntax.into_repr())),
2476             _ => None,
2477         }
2478     }
2479     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2480 }
2481
2482 impl ToOwned for Param {
2483     type Owned = TreeArc<Param>;
2484     fn to_owned(&self) -> TreeArc<Param> { TreeArc::cast(self.syntax.to_owned()) }
2485 }
2486
2487
2488 impl ast::TypeAscriptionOwner for Param {}
2489 impl Param {
2490     pub fn pat(&self) -> Option<&Pat> {
2491         super::child_opt(self)
2492     }
2493 }
2494
2495 // ParamList
2496 #[derive(Debug, PartialEq, Eq, Hash)]
2497 #[repr(transparent)]
2498 pub struct ParamList {
2499     pub(crate) syntax: SyntaxNode,
2500 }
2501 unsafe impl TransparentNewType for ParamList {
2502     type Repr = rowan::SyntaxNode;
2503 }
2504
2505 impl AstNode for ParamList {
2506     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2507         match syntax.kind() {
2508             PARAM_LIST => Some(ParamList::from_repr(syntax.into_repr())),
2509             _ => None,
2510         }
2511     }
2512     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2513 }
2514
2515 impl ToOwned for ParamList {
2516     type Owned = TreeArc<ParamList>;
2517     fn to_owned(&self) -> TreeArc<ParamList> { TreeArc::cast(self.syntax.to_owned()) }
2518 }
2519
2520
2521 impl ParamList {
2522     pub fn params(&self) -> impl Iterator<Item = &Param> {
2523         super::children(self)
2524     }
2525
2526     pub fn self_param(&self) -> Option<&SelfParam> {
2527         super::child_opt(self)
2528     }
2529 }
2530
2531 // ParenExpr
2532 #[derive(Debug, PartialEq, Eq, Hash)]
2533 #[repr(transparent)]
2534 pub struct ParenExpr {
2535     pub(crate) syntax: SyntaxNode,
2536 }
2537 unsafe impl TransparentNewType for ParenExpr {
2538     type Repr = rowan::SyntaxNode;
2539 }
2540
2541 impl AstNode for ParenExpr {
2542     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2543         match syntax.kind() {
2544             PAREN_EXPR => Some(ParenExpr::from_repr(syntax.into_repr())),
2545             _ => None,
2546         }
2547     }
2548     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2549 }
2550
2551 impl ToOwned for ParenExpr {
2552     type Owned = TreeArc<ParenExpr>;
2553     fn to_owned(&self) -> TreeArc<ParenExpr> { TreeArc::cast(self.syntax.to_owned()) }
2554 }
2555
2556
2557 impl ParenExpr {
2558     pub fn expr(&self) -> Option<&Expr> {
2559         super::child_opt(self)
2560     }
2561 }
2562
2563 // ParenType
2564 #[derive(Debug, PartialEq, Eq, Hash)]
2565 #[repr(transparent)]
2566 pub struct ParenType {
2567     pub(crate) syntax: SyntaxNode,
2568 }
2569 unsafe impl TransparentNewType for ParenType {
2570     type Repr = rowan::SyntaxNode;
2571 }
2572
2573 impl AstNode for ParenType {
2574     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2575         match syntax.kind() {
2576             PAREN_TYPE => Some(ParenType::from_repr(syntax.into_repr())),
2577             _ => None,
2578         }
2579     }
2580     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2581 }
2582
2583 impl ToOwned for ParenType {
2584     type Owned = TreeArc<ParenType>;
2585     fn to_owned(&self) -> TreeArc<ParenType> { TreeArc::cast(self.syntax.to_owned()) }
2586 }
2587
2588
2589 impl ParenType {
2590     pub fn type_ref(&self) -> Option<&TypeRef> {
2591         super::child_opt(self)
2592     }
2593 }
2594
2595 // Pat
2596 #[derive(Debug, PartialEq, Eq, Hash)]
2597 #[repr(transparent)]
2598 pub struct Pat {
2599     pub(crate) syntax: SyntaxNode,
2600 }
2601 unsafe impl TransparentNewType for Pat {
2602     type Repr = rowan::SyntaxNode;
2603 }
2604
2605 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2606 pub enum PatKind<'a> {
2607     RefPat(&'a RefPat),
2608     BindPat(&'a BindPat),
2609     PlaceholderPat(&'a PlaceholderPat),
2610     PathPat(&'a PathPat),
2611     StructPat(&'a StructPat),
2612     TupleStructPat(&'a TupleStructPat),
2613     TuplePat(&'a TuplePat),
2614     SlicePat(&'a SlicePat),
2615     RangePat(&'a RangePat),
2616     LiteralPat(&'a LiteralPat),
2617 }
2618 impl<'a> From<&'a RefPat> for &'a Pat {
2619     fn from(n: &'a RefPat) -> &'a Pat {
2620         Pat::cast(&n.syntax).unwrap()
2621     }
2622 }
2623 impl<'a> From<&'a BindPat> for &'a Pat {
2624     fn from(n: &'a BindPat) -> &'a Pat {
2625         Pat::cast(&n.syntax).unwrap()
2626     }
2627 }
2628 impl<'a> From<&'a PlaceholderPat> for &'a Pat {
2629     fn from(n: &'a PlaceholderPat) -> &'a Pat {
2630         Pat::cast(&n.syntax).unwrap()
2631     }
2632 }
2633 impl<'a> From<&'a PathPat> for &'a Pat {
2634     fn from(n: &'a PathPat) -> &'a Pat {
2635         Pat::cast(&n.syntax).unwrap()
2636     }
2637 }
2638 impl<'a> From<&'a StructPat> for &'a Pat {
2639     fn from(n: &'a StructPat) -> &'a Pat {
2640         Pat::cast(&n.syntax).unwrap()
2641     }
2642 }
2643 impl<'a> From<&'a TupleStructPat> for &'a Pat {
2644     fn from(n: &'a TupleStructPat) -> &'a Pat {
2645         Pat::cast(&n.syntax).unwrap()
2646     }
2647 }
2648 impl<'a> From<&'a TuplePat> for &'a Pat {
2649     fn from(n: &'a TuplePat) -> &'a Pat {
2650         Pat::cast(&n.syntax).unwrap()
2651     }
2652 }
2653 impl<'a> From<&'a SlicePat> for &'a Pat {
2654     fn from(n: &'a SlicePat) -> &'a Pat {
2655         Pat::cast(&n.syntax).unwrap()
2656     }
2657 }
2658 impl<'a> From<&'a RangePat> for &'a Pat {
2659     fn from(n: &'a RangePat) -> &'a Pat {
2660         Pat::cast(&n.syntax).unwrap()
2661     }
2662 }
2663 impl<'a> From<&'a LiteralPat> for &'a Pat {
2664     fn from(n: &'a LiteralPat) -> &'a Pat {
2665         Pat::cast(&n.syntax).unwrap()
2666     }
2667 }
2668
2669
2670 impl AstNode for Pat {
2671     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2672         match syntax.kind() {
2673             | REF_PAT
2674             | BIND_PAT
2675             | PLACEHOLDER_PAT
2676             | PATH_PAT
2677             | STRUCT_PAT
2678             | TUPLE_STRUCT_PAT
2679             | TUPLE_PAT
2680             | SLICE_PAT
2681             | RANGE_PAT
2682             | LITERAL_PAT => Some(Pat::from_repr(syntax.into_repr())),
2683             _ => None,
2684         }
2685     }
2686     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2687 }
2688
2689 impl ToOwned for Pat {
2690     type Owned = TreeArc<Pat>;
2691     fn to_owned(&self) -> TreeArc<Pat> { TreeArc::cast(self.syntax.to_owned()) }
2692 }
2693
2694 impl Pat {
2695     pub fn kind(&self) -> PatKind {
2696         match self.syntax.kind() {
2697             REF_PAT => PatKind::RefPat(RefPat::cast(&self.syntax).unwrap()),
2698             BIND_PAT => PatKind::BindPat(BindPat::cast(&self.syntax).unwrap()),
2699             PLACEHOLDER_PAT => PatKind::PlaceholderPat(PlaceholderPat::cast(&self.syntax).unwrap()),
2700             PATH_PAT => PatKind::PathPat(PathPat::cast(&self.syntax).unwrap()),
2701             STRUCT_PAT => PatKind::StructPat(StructPat::cast(&self.syntax).unwrap()),
2702             TUPLE_STRUCT_PAT => PatKind::TupleStructPat(TupleStructPat::cast(&self.syntax).unwrap()),
2703             TUPLE_PAT => PatKind::TuplePat(TuplePat::cast(&self.syntax).unwrap()),
2704             SLICE_PAT => PatKind::SlicePat(SlicePat::cast(&self.syntax).unwrap()),
2705             RANGE_PAT => PatKind::RangePat(RangePat::cast(&self.syntax).unwrap()),
2706             LITERAL_PAT => PatKind::LiteralPat(LiteralPat::cast(&self.syntax).unwrap()),
2707             _ => unreachable!(),
2708         }
2709     }
2710 }
2711
2712 impl Pat {}
2713
2714 // Path
2715 #[derive(Debug, PartialEq, Eq, Hash)]
2716 #[repr(transparent)]
2717 pub struct Path {
2718     pub(crate) syntax: SyntaxNode,
2719 }
2720 unsafe impl TransparentNewType for Path {
2721     type Repr = rowan::SyntaxNode;
2722 }
2723
2724 impl AstNode for Path {
2725     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2726         match syntax.kind() {
2727             PATH => Some(Path::from_repr(syntax.into_repr())),
2728             _ => None,
2729         }
2730     }
2731     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2732 }
2733
2734 impl ToOwned for Path {
2735     type Owned = TreeArc<Path>;
2736     fn to_owned(&self) -> TreeArc<Path> { TreeArc::cast(self.syntax.to_owned()) }
2737 }
2738
2739
2740 impl Path {
2741     pub fn segment(&self) -> Option<&PathSegment> {
2742         super::child_opt(self)
2743     }
2744
2745     pub fn qualifier(&self) -> Option<&Path> {
2746         super::child_opt(self)
2747     }
2748 }
2749
2750 // PathExpr
2751 #[derive(Debug, PartialEq, Eq, Hash)]
2752 #[repr(transparent)]
2753 pub struct PathExpr {
2754     pub(crate) syntax: SyntaxNode,
2755 }
2756 unsafe impl TransparentNewType for PathExpr {
2757     type Repr = rowan::SyntaxNode;
2758 }
2759
2760 impl AstNode for PathExpr {
2761     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2762         match syntax.kind() {
2763             PATH_EXPR => Some(PathExpr::from_repr(syntax.into_repr())),
2764             _ => None,
2765         }
2766     }
2767     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2768 }
2769
2770 impl ToOwned for PathExpr {
2771     type Owned = TreeArc<PathExpr>;
2772     fn to_owned(&self) -> TreeArc<PathExpr> { TreeArc::cast(self.syntax.to_owned()) }
2773 }
2774
2775
2776 impl PathExpr {
2777     pub fn path(&self) -> Option<&Path> {
2778         super::child_opt(self)
2779     }
2780 }
2781
2782 // PathPat
2783 #[derive(Debug, PartialEq, Eq, Hash)]
2784 #[repr(transparent)]
2785 pub struct PathPat {
2786     pub(crate) syntax: SyntaxNode,
2787 }
2788 unsafe impl TransparentNewType for PathPat {
2789     type Repr = rowan::SyntaxNode;
2790 }
2791
2792 impl AstNode for PathPat {
2793     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2794         match syntax.kind() {
2795             PATH_PAT => Some(PathPat::from_repr(syntax.into_repr())),
2796             _ => None,
2797         }
2798     }
2799     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2800 }
2801
2802 impl ToOwned for PathPat {
2803     type Owned = TreeArc<PathPat>;
2804     fn to_owned(&self) -> TreeArc<PathPat> { TreeArc::cast(self.syntax.to_owned()) }
2805 }
2806
2807
2808 impl PathPat {
2809     pub fn path(&self) -> Option<&Path> {
2810         super::child_opt(self)
2811     }
2812 }
2813
2814 // PathSegment
2815 #[derive(Debug, PartialEq, Eq, Hash)]
2816 #[repr(transparent)]
2817 pub struct PathSegment {
2818     pub(crate) syntax: SyntaxNode,
2819 }
2820 unsafe impl TransparentNewType for PathSegment {
2821     type Repr = rowan::SyntaxNode;
2822 }
2823
2824 impl AstNode for PathSegment {
2825     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2826         match syntax.kind() {
2827             PATH_SEGMENT => Some(PathSegment::from_repr(syntax.into_repr())),
2828             _ => None,
2829         }
2830     }
2831     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2832 }
2833
2834 impl ToOwned for PathSegment {
2835     type Owned = TreeArc<PathSegment>;
2836     fn to_owned(&self) -> TreeArc<PathSegment> { TreeArc::cast(self.syntax.to_owned()) }
2837 }
2838
2839
2840 impl PathSegment {
2841     pub fn name_ref(&self) -> Option<&NameRef> {
2842         super::child_opt(self)
2843     }
2844
2845     pub fn type_arg_list(&self) -> Option<&TypeArgList> {
2846         super::child_opt(self)
2847     }
2848 }
2849
2850 // PathType
2851 #[derive(Debug, PartialEq, Eq, Hash)]
2852 #[repr(transparent)]
2853 pub struct PathType {
2854     pub(crate) syntax: SyntaxNode,
2855 }
2856 unsafe impl TransparentNewType for PathType {
2857     type Repr = rowan::SyntaxNode;
2858 }
2859
2860 impl AstNode for PathType {
2861     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2862         match syntax.kind() {
2863             PATH_TYPE => Some(PathType::from_repr(syntax.into_repr())),
2864             _ => None,
2865         }
2866     }
2867     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2868 }
2869
2870 impl ToOwned for PathType {
2871     type Owned = TreeArc<PathType>;
2872     fn to_owned(&self) -> TreeArc<PathType> { TreeArc::cast(self.syntax.to_owned()) }
2873 }
2874
2875
2876 impl PathType {
2877     pub fn path(&self) -> Option<&Path> {
2878         super::child_opt(self)
2879     }
2880 }
2881
2882 // PlaceholderPat
2883 #[derive(Debug, PartialEq, Eq, Hash)]
2884 #[repr(transparent)]
2885 pub struct PlaceholderPat {
2886     pub(crate) syntax: SyntaxNode,
2887 }
2888 unsafe impl TransparentNewType for PlaceholderPat {
2889     type Repr = rowan::SyntaxNode;
2890 }
2891
2892 impl AstNode for PlaceholderPat {
2893     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2894         match syntax.kind() {
2895             PLACEHOLDER_PAT => Some(PlaceholderPat::from_repr(syntax.into_repr())),
2896             _ => None,
2897         }
2898     }
2899     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2900 }
2901
2902 impl ToOwned for PlaceholderPat {
2903     type Owned = TreeArc<PlaceholderPat>;
2904     fn to_owned(&self) -> TreeArc<PlaceholderPat> { TreeArc::cast(self.syntax.to_owned()) }
2905 }
2906
2907
2908 impl PlaceholderPat {}
2909
2910 // PlaceholderType
2911 #[derive(Debug, PartialEq, Eq, Hash)]
2912 #[repr(transparent)]
2913 pub struct PlaceholderType {
2914     pub(crate) syntax: SyntaxNode,
2915 }
2916 unsafe impl TransparentNewType for PlaceholderType {
2917     type Repr = rowan::SyntaxNode;
2918 }
2919
2920 impl AstNode for PlaceholderType {
2921     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2922         match syntax.kind() {
2923             PLACEHOLDER_TYPE => Some(PlaceholderType::from_repr(syntax.into_repr())),
2924             _ => None,
2925         }
2926     }
2927     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2928 }
2929
2930 impl ToOwned for PlaceholderType {
2931     type Owned = TreeArc<PlaceholderType>;
2932     fn to_owned(&self) -> TreeArc<PlaceholderType> { TreeArc::cast(self.syntax.to_owned()) }
2933 }
2934
2935
2936 impl PlaceholderType {}
2937
2938 // PointerType
2939 #[derive(Debug, PartialEq, Eq, Hash)]
2940 #[repr(transparent)]
2941 pub struct PointerType {
2942     pub(crate) syntax: SyntaxNode,
2943 }
2944 unsafe impl TransparentNewType for PointerType {
2945     type Repr = rowan::SyntaxNode;
2946 }
2947
2948 impl AstNode for PointerType {
2949     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2950         match syntax.kind() {
2951             POINTER_TYPE => Some(PointerType::from_repr(syntax.into_repr())),
2952             _ => None,
2953         }
2954     }
2955     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2956 }
2957
2958 impl ToOwned for PointerType {
2959     type Owned = TreeArc<PointerType>;
2960     fn to_owned(&self) -> TreeArc<PointerType> { TreeArc::cast(self.syntax.to_owned()) }
2961 }
2962
2963
2964 impl PointerType {
2965     pub fn type_ref(&self) -> Option<&TypeRef> {
2966         super::child_opt(self)
2967     }
2968 }
2969
2970 // PosFieldDef
2971 #[derive(Debug, PartialEq, Eq, Hash)]
2972 #[repr(transparent)]
2973 pub struct PosFieldDef {
2974     pub(crate) syntax: SyntaxNode,
2975 }
2976 unsafe impl TransparentNewType for PosFieldDef {
2977     type Repr = rowan::SyntaxNode;
2978 }
2979
2980 impl AstNode for PosFieldDef {
2981     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2982         match syntax.kind() {
2983             POS_FIELD_DEF => Some(PosFieldDef::from_repr(syntax.into_repr())),
2984             _ => None,
2985         }
2986     }
2987     fn syntax(&self) -> &SyntaxNode { &self.syntax }
2988 }
2989
2990 impl ToOwned for PosFieldDef {
2991     type Owned = TreeArc<PosFieldDef>;
2992     fn to_owned(&self) -> TreeArc<PosFieldDef> { TreeArc::cast(self.syntax.to_owned()) }
2993 }
2994
2995
2996 impl ast::VisibilityOwner for PosFieldDef {}
2997 impl ast::AttrsOwner for PosFieldDef {}
2998 impl PosFieldDef {
2999     pub fn type_ref(&self) -> Option<&TypeRef> {
3000         super::child_opt(self)
3001     }
3002 }
3003
3004 // PosFieldDefList
3005 #[derive(Debug, PartialEq, Eq, Hash)]
3006 #[repr(transparent)]
3007 pub struct PosFieldDefList {
3008     pub(crate) syntax: SyntaxNode,
3009 }
3010 unsafe impl TransparentNewType for PosFieldDefList {
3011     type Repr = rowan::SyntaxNode;
3012 }
3013
3014 impl AstNode for PosFieldDefList {
3015     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3016         match syntax.kind() {
3017             POS_FIELD_DEF_LIST => Some(PosFieldDefList::from_repr(syntax.into_repr())),
3018             _ => None,
3019         }
3020     }
3021     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3022 }
3023
3024 impl ToOwned for PosFieldDefList {
3025     type Owned = TreeArc<PosFieldDefList>;
3026     fn to_owned(&self) -> TreeArc<PosFieldDefList> { TreeArc::cast(self.syntax.to_owned()) }
3027 }
3028
3029
3030 impl PosFieldDefList {
3031     pub fn fields(&self) -> impl Iterator<Item = &PosFieldDef> {
3032         super::children(self)
3033     }
3034 }
3035
3036 // PrefixExpr
3037 #[derive(Debug, PartialEq, Eq, Hash)]
3038 #[repr(transparent)]
3039 pub struct PrefixExpr {
3040     pub(crate) syntax: SyntaxNode,
3041 }
3042 unsafe impl TransparentNewType for PrefixExpr {
3043     type Repr = rowan::SyntaxNode;
3044 }
3045
3046 impl AstNode for PrefixExpr {
3047     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3048         match syntax.kind() {
3049             PREFIX_EXPR => Some(PrefixExpr::from_repr(syntax.into_repr())),
3050             _ => None,
3051         }
3052     }
3053     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3054 }
3055
3056 impl ToOwned for PrefixExpr {
3057     type Owned = TreeArc<PrefixExpr>;
3058     fn to_owned(&self) -> TreeArc<PrefixExpr> { TreeArc::cast(self.syntax.to_owned()) }
3059 }
3060
3061
3062 impl PrefixExpr {
3063     pub fn expr(&self) -> Option<&Expr> {
3064         super::child_opt(self)
3065     }
3066 }
3067
3068 // RangeExpr
3069 #[derive(Debug, PartialEq, Eq, Hash)]
3070 #[repr(transparent)]
3071 pub struct RangeExpr {
3072     pub(crate) syntax: SyntaxNode,
3073 }
3074 unsafe impl TransparentNewType for RangeExpr {
3075     type Repr = rowan::SyntaxNode;
3076 }
3077
3078 impl AstNode for RangeExpr {
3079     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3080         match syntax.kind() {
3081             RANGE_EXPR => Some(RangeExpr::from_repr(syntax.into_repr())),
3082             _ => None,
3083         }
3084     }
3085     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3086 }
3087
3088 impl ToOwned for RangeExpr {
3089     type Owned = TreeArc<RangeExpr>;
3090     fn to_owned(&self) -> TreeArc<RangeExpr> { TreeArc::cast(self.syntax.to_owned()) }
3091 }
3092
3093
3094 impl RangeExpr {}
3095
3096 // RangePat
3097 #[derive(Debug, PartialEq, Eq, Hash)]
3098 #[repr(transparent)]
3099 pub struct RangePat {
3100     pub(crate) syntax: SyntaxNode,
3101 }
3102 unsafe impl TransparentNewType for RangePat {
3103     type Repr = rowan::SyntaxNode;
3104 }
3105
3106 impl AstNode for RangePat {
3107     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3108         match syntax.kind() {
3109             RANGE_PAT => Some(RangePat::from_repr(syntax.into_repr())),
3110             _ => None,
3111         }
3112     }
3113     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3114 }
3115
3116 impl ToOwned for RangePat {
3117     type Owned = TreeArc<RangePat>;
3118     fn to_owned(&self) -> TreeArc<RangePat> { TreeArc::cast(self.syntax.to_owned()) }
3119 }
3120
3121
3122 impl RangePat {}
3123
3124 // RefExpr
3125 #[derive(Debug, PartialEq, Eq, Hash)]
3126 #[repr(transparent)]
3127 pub struct RefExpr {
3128     pub(crate) syntax: SyntaxNode,
3129 }
3130 unsafe impl TransparentNewType for RefExpr {
3131     type Repr = rowan::SyntaxNode;
3132 }
3133
3134 impl AstNode for RefExpr {
3135     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3136         match syntax.kind() {
3137             REF_EXPR => Some(RefExpr::from_repr(syntax.into_repr())),
3138             _ => None,
3139         }
3140     }
3141     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3142 }
3143
3144 impl ToOwned for RefExpr {
3145     type Owned = TreeArc<RefExpr>;
3146     fn to_owned(&self) -> TreeArc<RefExpr> { TreeArc::cast(self.syntax.to_owned()) }
3147 }
3148
3149
3150 impl RefExpr {
3151     pub fn expr(&self) -> Option<&Expr> {
3152         super::child_opt(self)
3153     }
3154 }
3155
3156 // RefPat
3157 #[derive(Debug, PartialEq, Eq, Hash)]
3158 #[repr(transparent)]
3159 pub struct RefPat {
3160     pub(crate) syntax: SyntaxNode,
3161 }
3162 unsafe impl TransparentNewType for RefPat {
3163     type Repr = rowan::SyntaxNode;
3164 }
3165
3166 impl AstNode for RefPat {
3167     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3168         match syntax.kind() {
3169             REF_PAT => Some(RefPat::from_repr(syntax.into_repr())),
3170             _ => None,
3171         }
3172     }
3173     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3174 }
3175
3176 impl ToOwned for RefPat {
3177     type Owned = TreeArc<RefPat>;
3178     fn to_owned(&self) -> TreeArc<RefPat> { TreeArc::cast(self.syntax.to_owned()) }
3179 }
3180
3181
3182 impl RefPat {
3183     pub fn pat(&self) -> Option<&Pat> {
3184         super::child_opt(self)
3185     }
3186 }
3187
3188 // ReferenceType
3189 #[derive(Debug, PartialEq, Eq, Hash)]
3190 #[repr(transparent)]
3191 pub struct ReferenceType {
3192     pub(crate) syntax: SyntaxNode,
3193 }
3194 unsafe impl TransparentNewType for ReferenceType {
3195     type Repr = rowan::SyntaxNode;
3196 }
3197
3198 impl AstNode for ReferenceType {
3199     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3200         match syntax.kind() {
3201             REFERENCE_TYPE => Some(ReferenceType::from_repr(syntax.into_repr())),
3202             _ => None,
3203         }
3204     }
3205     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3206 }
3207
3208 impl ToOwned for ReferenceType {
3209     type Owned = TreeArc<ReferenceType>;
3210     fn to_owned(&self) -> TreeArc<ReferenceType> { TreeArc::cast(self.syntax.to_owned()) }
3211 }
3212
3213
3214 impl ReferenceType {
3215     pub fn type_ref(&self) -> Option<&TypeRef> {
3216         super::child_opt(self)
3217     }
3218 }
3219
3220 // RetType
3221 #[derive(Debug, PartialEq, Eq, Hash)]
3222 #[repr(transparent)]
3223 pub struct RetType {
3224     pub(crate) syntax: SyntaxNode,
3225 }
3226 unsafe impl TransparentNewType for RetType {
3227     type Repr = rowan::SyntaxNode;
3228 }
3229
3230 impl AstNode for RetType {
3231     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3232         match syntax.kind() {
3233             RET_TYPE => Some(RetType::from_repr(syntax.into_repr())),
3234             _ => None,
3235         }
3236     }
3237     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3238 }
3239
3240 impl ToOwned for RetType {
3241     type Owned = TreeArc<RetType>;
3242     fn to_owned(&self) -> TreeArc<RetType> { TreeArc::cast(self.syntax.to_owned()) }
3243 }
3244
3245
3246 impl RetType {
3247     pub fn type_ref(&self) -> Option<&TypeRef> {
3248         super::child_opt(self)
3249     }
3250 }
3251
3252 // ReturnExpr
3253 #[derive(Debug, PartialEq, Eq, Hash)]
3254 #[repr(transparent)]
3255 pub struct ReturnExpr {
3256     pub(crate) syntax: SyntaxNode,
3257 }
3258 unsafe impl TransparentNewType for ReturnExpr {
3259     type Repr = rowan::SyntaxNode;
3260 }
3261
3262 impl AstNode for ReturnExpr {
3263     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3264         match syntax.kind() {
3265             RETURN_EXPR => Some(ReturnExpr::from_repr(syntax.into_repr())),
3266             _ => None,
3267         }
3268     }
3269     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3270 }
3271
3272 impl ToOwned for ReturnExpr {
3273     type Owned = TreeArc<ReturnExpr>;
3274     fn to_owned(&self) -> TreeArc<ReturnExpr> { TreeArc::cast(self.syntax.to_owned()) }
3275 }
3276
3277
3278 impl ReturnExpr {
3279     pub fn expr(&self) -> Option<&Expr> {
3280         super::child_opt(self)
3281     }
3282 }
3283
3284 // SelfParam
3285 #[derive(Debug, PartialEq, Eq, Hash)]
3286 #[repr(transparent)]
3287 pub struct SelfParam {
3288     pub(crate) syntax: SyntaxNode,
3289 }
3290 unsafe impl TransparentNewType for SelfParam {
3291     type Repr = rowan::SyntaxNode;
3292 }
3293
3294 impl AstNode for SelfParam {
3295     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3296         match syntax.kind() {
3297             SELF_PARAM => Some(SelfParam::from_repr(syntax.into_repr())),
3298             _ => None,
3299         }
3300     }
3301     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3302 }
3303
3304 impl ToOwned for SelfParam {
3305     type Owned = TreeArc<SelfParam>;
3306     fn to_owned(&self) -> TreeArc<SelfParam> { TreeArc::cast(self.syntax.to_owned()) }
3307 }
3308
3309
3310 impl ast::TypeAscriptionOwner for SelfParam {}
3311 impl SelfParam {}
3312
3313 // SlicePat
3314 #[derive(Debug, PartialEq, Eq, Hash)]
3315 #[repr(transparent)]
3316 pub struct SlicePat {
3317     pub(crate) syntax: SyntaxNode,
3318 }
3319 unsafe impl TransparentNewType for SlicePat {
3320     type Repr = rowan::SyntaxNode;
3321 }
3322
3323 impl AstNode for SlicePat {
3324     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3325         match syntax.kind() {
3326             SLICE_PAT => Some(SlicePat::from_repr(syntax.into_repr())),
3327             _ => None,
3328         }
3329     }
3330     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3331 }
3332
3333 impl ToOwned for SlicePat {
3334     type Owned = TreeArc<SlicePat>;
3335     fn to_owned(&self) -> TreeArc<SlicePat> { TreeArc::cast(self.syntax.to_owned()) }
3336 }
3337
3338
3339 impl SlicePat {}
3340
3341 // SliceType
3342 #[derive(Debug, PartialEq, Eq, Hash)]
3343 #[repr(transparent)]
3344 pub struct SliceType {
3345     pub(crate) syntax: SyntaxNode,
3346 }
3347 unsafe impl TransparentNewType for SliceType {
3348     type Repr = rowan::SyntaxNode;
3349 }
3350
3351 impl AstNode for SliceType {
3352     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3353         match syntax.kind() {
3354             SLICE_TYPE => Some(SliceType::from_repr(syntax.into_repr())),
3355             _ => None,
3356         }
3357     }
3358     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3359 }
3360
3361 impl ToOwned for SliceType {
3362     type Owned = TreeArc<SliceType>;
3363     fn to_owned(&self) -> TreeArc<SliceType> { TreeArc::cast(self.syntax.to_owned()) }
3364 }
3365
3366
3367 impl SliceType {
3368     pub fn type_ref(&self) -> Option<&TypeRef> {
3369         super::child_opt(self)
3370     }
3371 }
3372
3373 // SourceFile
3374 #[derive(Debug, PartialEq, Eq, Hash)]
3375 #[repr(transparent)]
3376 pub struct SourceFile {
3377     pub(crate) syntax: SyntaxNode,
3378 }
3379 unsafe impl TransparentNewType for SourceFile {
3380     type Repr = rowan::SyntaxNode;
3381 }
3382
3383 impl AstNode for SourceFile {
3384     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3385         match syntax.kind() {
3386             SOURCE_FILE => Some(SourceFile::from_repr(syntax.into_repr())),
3387             _ => None,
3388         }
3389     }
3390     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3391 }
3392
3393 impl ToOwned for SourceFile {
3394     type Owned = TreeArc<SourceFile>;
3395     fn to_owned(&self) -> TreeArc<SourceFile> { TreeArc::cast(self.syntax.to_owned()) }
3396 }
3397
3398
3399 impl ast::ModuleItemOwner for SourceFile {}
3400 impl ast::FnDefOwner for SourceFile {}
3401 impl SourceFile {
3402     pub fn modules(&self) -> impl Iterator<Item = &Module> {
3403         super::children(self)
3404     }
3405 }
3406
3407 // StaticDef
3408 #[derive(Debug, PartialEq, Eq, Hash)]
3409 #[repr(transparent)]
3410 pub struct StaticDef {
3411     pub(crate) syntax: SyntaxNode,
3412 }
3413 unsafe impl TransparentNewType for StaticDef {
3414     type Repr = rowan::SyntaxNode;
3415 }
3416
3417 impl AstNode for StaticDef {
3418     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3419         match syntax.kind() {
3420             STATIC_DEF => Some(StaticDef::from_repr(syntax.into_repr())),
3421             _ => None,
3422         }
3423     }
3424     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3425 }
3426
3427 impl ToOwned for StaticDef {
3428     type Owned = TreeArc<StaticDef>;
3429     fn to_owned(&self) -> TreeArc<StaticDef> { TreeArc::cast(self.syntax.to_owned()) }
3430 }
3431
3432
3433 impl ast::VisibilityOwner for StaticDef {}
3434 impl ast::NameOwner for StaticDef {}
3435 impl ast::TypeParamsOwner for StaticDef {}
3436 impl ast::AttrsOwner for StaticDef {}
3437 impl ast::DocCommentsOwner for StaticDef {}
3438 impl ast::TypeAscriptionOwner for StaticDef {}
3439 impl StaticDef {
3440     pub fn body(&self) -> Option<&Expr> {
3441         super::child_opt(self)
3442     }
3443 }
3444
3445 // Stmt
3446 #[derive(Debug, PartialEq, Eq, Hash)]
3447 #[repr(transparent)]
3448 pub struct Stmt {
3449     pub(crate) syntax: SyntaxNode,
3450 }
3451 unsafe impl TransparentNewType for Stmt {
3452     type Repr = rowan::SyntaxNode;
3453 }
3454
3455 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3456 pub enum StmtKind<'a> {
3457     ExprStmt(&'a ExprStmt),
3458     LetStmt(&'a LetStmt),
3459 }
3460 impl<'a> From<&'a ExprStmt> for &'a Stmt {
3461     fn from(n: &'a ExprStmt) -> &'a Stmt {
3462         Stmt::cast(&n.syntax).unwrap()
3463     }
3464 }
3465 impl<'a> From<&'a LetStmt> for &'a Stmt {
3466     fn from(n: &'a LetStmt) -> &'a Stmt {
3467         Stmt::cast(&n.syntax).unwrap()
3468     }
3469 }
3470
3471
3472 impl AstNode for Stmt {
3473     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3474         match syntax.kind() {
3475             | EXPR_STMT
3476             | LET_STMT => Some(Stmt::from_repr(syntax.into_repr())),
3477             _ => None,
3478         }
3479     }
3480     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3481 }
3482
3483 impl ToOwned for Stmt {
3484     type Owned = TreeArc<Stmt>;
3485     fn to_owned(&self) -> TreeArc<Stmt> { TreeArc::cast(self.syntax.to_owned()) }
3486 }
3487
3488 impl Stmt {
3489     pub fn kind(&self) -> StmtKind {
3490         match self.syntax.kind() {
3491             EXPR_STMT => StmtKind::ExprStmt(ExprStmt::cast(&self.syntax).unwrap()),
3492             LET_STMT => StmtKind::LetStmt(LetStmt::cast(&self.syntax).unwrap()),
3493             _ => unreachable!(),
3494         }
3495     }
3496 }
3497
3498 impl Stmt {}
3499
3500 // StructDef
3501 #[derive(Debug, PartialEq, Eq, Hash)]
3502 #[repr(transparent)]
3503 pub struct StructDef {
3504     pub(crate) syntax: SyntaxNode,
3505 }
3506 unsafe impl TransparentNewType for StructDef {
3507     type Repr = rowan::SyntaxNode;
3508 }
3509
3510 impl AstNode for StructDef {
3511     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3512         match syntax.kind() {
3513             STRUCT_DEF => Some(StructDef::from_repr(syntax.into_repr())),
3514             _ => None,
3515         }
3516     }
3517     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3518 }
3519
3520 impl ToOwned for StructDef {
3521     type Owned = TreeArc<StructDef>;
3522     fn to_owned(&self) -> TreeArc<StructDef> { TreeArc::cast(self.syntax.to_owned()) }
3523 }
3524
3525
3526 impl ast::VisibilityOwner for StructDef {}
3527 impl ast::NameOwner for StructDef {}
3528 impl ast::TypeParamsOwner for StructDef {}
3529 impl ast::AttrsOwner for StructDef {}
3530 impl ast::DocCommentsOwner for StructDef {}
3531 impl StructDef {}
3532
3533 // StructLit
3534 #[derive(Debug, PartialEq, Eq, Hash)]
3535 #[repr(transparent)]
3536 pub struct StructLit {
3537     pub(crate) syntax: SyntaxNode,
3538 }
3539 unsafe impl TransparentNewType for StructLit {
3540     type Repr = rowan::SyntaxNode;
3541 }
3542
3543 impl AstNode for StructLit {
3544     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3545         match syntax.kind() {
3546             STRUCT_LIT => Some(StructLit::from_repr(syntax.into_repr())),
3547             _ => None,
3548         }
3549     }
3550     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3551 }
3552
3553 impl ToOwned for StructLit {
3554     type Owned = TreeArc<StructLit>;
3555     fn to_owned(&self) -> TreeArc<StructLit> { TreeArc::cast(self.syntax.to_owned()) }
3556 }
3557
3558
3559 impl StructLit {
3560     pub fn path(&self) -> Option<&Path> {
3561         super::child_opt(self)
3562     }
3563
3564     pub fn named_field_list(&self) -> Option<&NamedFieldList> {
3565         super::child_opt(self)
3566     }
3567
3568     pub fn spread(&self) -> Option<&Expr> {
3569         super::child_opt(self)
3570     }
3571 }
3572
3573 // StructPat
3574 #[derive(Debug, PartialEq, Eq, Hash)]
3575 #[repr(transparent)]
3576 pub struct StructPat {
3577     pub(crate) syntax: SyntaxNode,
3578 }
3579 unsafe impl TransparentNewType for StructPat {
3580     type Repr = rowan::SyntaxNode;
3581 }
3582
3583 impl AstNode for StructPat {
3584     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3585         match syntax.kind() {
3586             STRUCT_PAT => Some(StructPat::from_repr(syntax.into_repr())),
3587             _ => None,
3588         }
3589     }
3590     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3591 }
3592
3593 impl ToOwned for StructPat {
3594     type Owned = TreeArc<StructPat>;
3595     fn to_owned(&self) -> TreeArc<StructPat> { TreeArc::cast(self.syntax.to_owned()) }
3596 }
3597
3598
3599 impl StructPat {
3600     pub fn field_pat_list(&self) -> Option<&FieldPatList> {
3601         super::child_opt(self)
3602     }
3603
3604     pub fn path(&self) -> Option<&Path> {
3605         super::child_opt(self)
3606     }
3607 }
3608
3609 // TokenTree
3610 #[derive(Debug, PartialEq, Eq, Hash)]
3611 #[repr(transparent)]
3612 pub struct TokenTree {
3613     pub(crate) syntax: SyntaxNode,
3614 }
3615 unsafe impl TransparentNewType for TokenTree {
3616     type Repr = rowan::SyntaxNode;
3617 }
3618
3619 impl AstNode for TokenTree {
3620     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3621         match syntax.kind() {
3622             TOKEN_TREE => Some(TokenTree::from_repr(syntax.into_repr())),
3623             _ => None,
3624         }
3625     }
3626     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3627 }
3628
3629 impl ToOwned for TokenTree {
3630     type Owned = TreeArc<TokenTree>;
3631     fn to_owned(&self) -> TreeArc<TokenTree> { TreeArc::cast(self.syntax.to_owned()) }
3632 }
3633
3634
3635 impl TokenTree {}
3636
3637 // TraitDef
3638 #[derive(Debug, PartialEq, Eq, Hash)]
3639 #[repr(transparent)]
3640 pub struct TraitDef {
3641     pub(crate) syntax: SyntaxNode,
3642 }
3643 unsafe impl TransparentNewType for TraitDef {
3644     type Repr = rowan::SyntaxNode;
3645 }
3646
3647 impl AstNode for TraitDef {
3648     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3649         match syntax.kind() {
3650             TRAIT_DEF => Some(TraitDef::from_repr(syntax.into_repr())),
3651             _ => None,
3652         }
3653     }
3654     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3655 }
3656
3657 impl ToOwned for TraitDef {
3658     type Owned = TreeArc<TraitDef>;
3659     fn to_owned(&self) -> TreeArc<TraitDef> { TreeArc::cast(self.syntax.to_owned()) }
3660 }
3661
3662
3663 impl ast::VisibilityOwner for TraitDef {}
3664 impl ast::NameOwner for TraitDef {}
3665 impl ast::AttrsOwner for TraitDef {}
3666 impl ast::DocCommentsOwner for TraitDef {}
3667 impl ast::TypeParamsOwner for TraitDef {}
3668 impl ast::TypeBoundsOwner for TraitDef {}
3669 impl TraitDef {
3670     pub fn item_list(&self) -> Option<&ItemList> {
3671         super::child_opt(self)
3672     }
3673 }
3674
3675 // TryExpr
3676 #[derive(Debug, PartialEq, Eq, Hash)]
3677 #[repr(transparent)]
3678 pub struct TryExpr {
3679     pub(crate) syntax: SyntaxNode,
3680 }
3681 unsafe impl TransparentNewType for TryExpr {
3682     type Repr = rowan::SyntaxNode;
3683 }
3684
3685 impl AstNode for TryExpr {
3686     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3687         match syntax.kind() {
3688             TRY_EXPR => Some(TryExpr::from_repr(syntax.into_repr())),
3689             _ => None,
3690         }
3691     }
3692     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3693 }
3694
3695 impl ToOwned for TryExpr {
3696     type Owned = TreeArc<TryExpr>;
3697     fn to_owned(&self) -> TreeArc<TryExpr> { TreeArc::cast(self.syntax.to_owned()) }
3698 }
3699
3700
3701 impl TryExpr {
3702     pub fn expr(&self) -> Option<&Expr> {
3703         super::child_opt(self)
3704     }
3705 }
3706
3707 // TupleExpr
3708 #[derive(Debug, PartialEq, Eq, Hash)]
3709 #[repr(transparent)]
3710 pub struct TupleExpr {
3711     pub(crate) syntax: SyntaxNode,
3712 }
3713 unsafe impl TransparentNewType for TupleExpr {
3714     type Repr = rowan::SyntaxNode;
3715 }
3716
3717 impl AstNode for TupleExpr {
3718     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3719         match syntax.kind() {
3720             TUPLE_EXPR => Some(TupleExpr::from_repr(syntax.into_repr())),
3721             _ => None,
3722         }
3723     }
3724     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3725 }
3726
3727 impl ToOwned for TupleExpr {
3728     type Owned = TreeArc<TupleExpr>;
3729     fn to_owned(&self) -> TreeArc<TupleExpr> { TreeArc::cast(self.syntax.to_owned()) }
3730 }
3731
3732
3733 impl TupleExpr {
3734     pub fn exprs(&self) -> impl Iterator<Item = &Expr> {
3735         super::children(self)
3736     }
3737 }
3738
3739 // TuplePat
3740 #[derive(Debug, PartialEq, Eq, Hash)]
3741 #[repr(transparent)]
3742 pub struct TuplePat {
3743     pub(crate) syntax: SyntaxNode,
3744 }
3745 unsafe impl TransparentNewType for TuplePat {
3746     type Repr = rowan::SyntaxNode;
3747 }
3748
3749 impl AstNode for TuplePat {
3750     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3751         match syntax.kind() {
3752             TUPLE_PAT => Some(TuplePat::from_repr(syntax.into_repr())),
3753             _ => None,
3754         }
3755     }
3756     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3757 }
3758
3759 impl ToOwned for TuplePat {
3760     type Owned = TreeArc<TuplePat>;
3761     fn to_owned(&self) -> TreeArc<TuplePat> { TreeArc::cast(self.syntax.to_owned()) }
3762 }
3763
3764
3765 impl TuplePat {
3766     pub fn args(&self) -> impl Iterator<Item = &Pat> {
3767         super::children(self)
3768     }
3769 }
3770
3771 // TupleStructPat
3772 #[derive(Debug, PartialEq, Eq, Hash)]
3773 #[repr(transparent)]
3774 pub struct TupleStructPat {
3775     pub(crate) syntax: SyntaxNode,
3776 }
3777 unsafe impl TransparentNewType for TupleStructPat {
3778     type Repr = rowan::SyntaxNode;
3779 }
3780
3781 impl AstNode for TupleStructPat {
3782     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3783         match syntax.kind() {
3784             TUPLE_STRUCT_PAT => Some(TupleStructPat::from_repr(syntax.into_repr())),
3785             _ => None,
3786         }
3787     }
3788     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3789 }
3790
3791 impl ToOwned for TupleStructPat {
3792     type Owned = TreeArc<TupleStructPat>;
3793     fn to_owned(&self) -> TreeArc<TupleStructPat> { TreeArc::cast(self.syntax.to_owned()) }
3794 }
3795
3796
3797 impl TupleStructPat {
3798     pub fn args(&self) -> impl Iterator<Item = &Pat> {
3799         super::children(self)
3800     }
3801
3802     pub fn path(&self) -> Option<&Path> {
3803         super::child_opt(self)
3804     }
3805 }
3806
3807 // TupleType
3808 #[derive(Debug, PartialEq, Eq, Hash)]
3809 #[repr(transparent)]
3810 pub struct TupleType {
3811     pub(crate) syntax: SyntaxNode,
3812 }
3813 unsafe impl TransparentNewType for TupleType {
3814     type Repr = rowan::SyntaxNode;
3815 }
3816
3817 impl AstNode for TupleType {
3818     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3819         match syntax.kind() {
3820             TUPLE_TYPE => Some(TupleType::from_repr(syntax.into_repr())),
3821             _ => None,
3822         }
3823     }
3824     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3825 }
3826
3827 impl ToOwned for TupleType {
3828     type Owned = TreeArc<TupleType>;
3829     fn to_owned(&self) -> TreeArc<TupleType> { TreeArc::cast(self.syntax.to_owned()) }
3830 }
3831
3832
3833 impl TupleType {
3834     pub fn fields(&self) -> impl Iterator<Item = &TypeRef> {
3835         super::children(self)
3836     }
3837 }
3838
3839 // TypeAliasDef
3840 #[derive(Debug, PartialEq, Eq, Hash)]
3841 #[repr(transparent)]
3842 pub struct TypeAliasDef {
3843     pub(crate) syntax: SyntaxNode,
3844 }
3845 unsafe impl TransparentNewType for TypeAliasDef {
3846     type Repr = rowan::SyntaxNode;
3847 }
3848
3849 impl AstNode for TypeAliasDef {
3850     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3851         match syntax.kind() {
3852             TYPE_ALIAS_DEF => Some(TypeAliasDef::from_repr(syntax.into_repr())),
3853             _ => None,
3854         }
3855     }
3856     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3857 }
3858
3859 impl ToOwned for TypeAliasDef {
3860     type Owned = TreeArc<TypeAliasDef>;
3861     fn to_owned(&self) -> TreeArc<TypeAliasDef> { TreeArc::cast(self.syntax.to_owned()) }
3862 }
3863
3864
3865 impl ast::VisibilityOwner for TypeAliasDef {}
3866 impl ast::NameOwner for TypeAliasDef {}
3867 impl ast::TypeParamsOwner for TypeAliasDef {}
3868 impl ast::AttrsOwner for TypeAliasDef {}
3869 impl ast::DocCommentsOwner for TypeAliasDef {}
3870 impl ast::TypeBoundsOwner for TypeAliasDef {}
3871 impl TypeAliasDef {
3872     pub fn type_ref(&self) -> Option<&TypeRef> {
3873         super::child_opt(self)
3874     }
3875 }
3876
3877 // TypeArg
3878 #[derive(Debug, PartialEq, Eq, Hash)]
3879 #[repr(transparent)]
3880 pub struct TypeArg {
3881     pub(crate) syntax: SyntaxNode,
3882 }
3883 unsafe impl TransparentNewType for TypeArg {
3884     type Repr = rowan::SyntaxNode;
3885 }
3886
3887 impl AstNode for TypeArg {
3888     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3889         match syntax.kind() {
3890             TYPE_ARG => Some(TypeArg::from_repr(syntax.into_repr())),
3891             _ => None,
3892         }
3893     }
3894     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3895 }
3896
3897 impl ToOwned for TypeArg {
3898     type Owned = TreeArc<TypeArg>;
3899     fn to_owned(&self) -> TreeArc<TypeArg> { TreeArc::cast(self.syntax.to_owned()) }
3900 }
3901
3902
3903 impl TypeArg {
3904     pub fn type_ref(&self) -> Option<&TypeRef> {
3905         super::child_opt(self)
3906     }
3907 }
3908
3909 // TypeArgList
3910 #[derive(Debug, PartialEq, Eq, Hash)]
3911 #[repr(transparent)]
3912 pub struct TypeArgList {
3913     pub(crate) syntax: SyntaxNode,
3914 }
3915 unsafe impl TransparentNewType for TypeArgList {
3916     type Repr = rowan::SyntaxNode;
3917 }
3918
3919 impl AstNode for TypeArgList {
3920     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3921         match syntax.kind() {
3922             TYPE_ARG_LIST => Some(TypeArgList::from_repr(syntax.into_repr())),
3923             _ => None,
3924         }
3925     }
3926     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3927 }
3928
3929 impl ToOwned for TypeArgList {
3930     type Owned = TreeArc<TypeArgList>;
3931     fn to_owned(&self) -> TreeArc<TypeArgList> { TreeArc::cast(self.syntax.to_owned()) }
3932 }
3933
3934
3935 impl TypeArgList {
3936     pub fn type_args(&self) -> impl Iterator<Item = &TypeArg> {
3937         super::children(self)
3938     }
3939
3940     pub fn lifetime_args(&self) -> impl Iterator<Item = &LifetimeArg> {
3941         super::children(self)
3942     }
3943
3944     pub fn assoc_type_args(&self) -> impl Iterator<Item = &AssocTypeArg> {
3945         super::children(self)
3946     }
3947 }
3948
3949 // TypeBound
3950 #[derive(Debug, PartialEq, Eq, Hash)]
3951 #[repr(transparent)]
3952 pub struct TypeBound {
3953     pub(crate) syntax: SyntaxNode,
3954 }
3955 unsafe impl TransparentNewType for TypeBound {
3956     type Repr = rowan::SyntaxNode;
3957 }
3958
3959 impl AstNode for TypeBound {
3960     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3961         match syntax.kind() {
3962             TYPE_BOUND => Some(TypeBound::from_repr(syntax.into_repr())),
3963             _ => None,
3964         }
3965     }
3966     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3967 }
3968
3969 impl ToOwned for TypeBound {
3970     type Owned = TreeArc<TypeBound>;
3971     fn to_owned(&self) -> TreeArc<TypeBound> { TreeArc::cast(self.syntax.to_owned()) }
3972 }
3973
3974
3975 impl TypeBound {
3976     pub fn type_ref(&self) -> Option<&TypeRef> {
3977         super::child_opt(self)
3978     }
3979 }
3980
3981 // TypeBoundList
3982 #[derive(Debug, PartialEq, Eq, Hash)]
3983 #[repr(transparent)]
3984 pub struct TypeBoundList {
3985     pub(crate) syntax: SyntaxNode,
3986 }
3987 unsafe impl TransparentNewType for TypeBoundList {
3988     type Repr = rowan::SyntaxNode;
3989 }
3990
3991 impl AstNode for TypeBoundList {
3992     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
3993         match syntax.kind() {
3994             TYPE_BOUND_LIST => Some(TypeBoundList::from_repr(syntax.into_repr())),
3995             _ => None,
3996         }
3997     }
3998     fn syntax(&self) -> &SyntaxNode { &self.syntax }
3999 }
4000
4001 impl ToOwned for TypeBoundList {
4002     type Owned = TreeArc<TypeBoundList>;
4003     fn to_owned(&self) -> TreeArc<TypeBoundList> { TreeArc::cast(self.syntax.to_owned()) }
4004 }
4005
4006
4007 impl TypeBoundList {
4008     pub fn bounds(&self) -> impl Iterator<Item = &TypeBound> {
4009         super::children(self)
4010     }
4011 }
4012
4013 // TypeParam
4014 #[derive(Debug, PartialEq, Eq, Hash)]
4015 #[repr(transparent)]
4016 pub struct TypeParam {
4017     pub(crate) syntax: SyntaxNode,
4018 }
4019 unsafe impl TransparentNewType for TypeParam {
4020     type Repr = rowan::SyntaxNode;
4021 }
4022
4023 impl AstNode for TypeParam {
4024     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4025         match syntax.kind() {
4026             TYPE_PARAM => Some(TypeParam::from_repr(syntax.into_repr())),
4027             _ => None,
4028         }
4029     }
4030     fn syntax(&self) -> &SyntaxNode { &self.syntax }
4031 }
4032
4033 impl ToOwned for TypeParam {
4034     type Owned = TreeArc<TypeParam>;
4035     fn to_owned(&self) -> TreeArc<TypeParam> { TreeArc::cast(self.syntax.to_owned()) }
4036 }
4037
4038
4039 impl ast::NameOwner for TypeParam {}
4040 impl ast::AttrsOwner for TypeParam {}
4041 impl ast::TypeBoundsOwner for TypeParam {}
4042 impl TypeParam {}
4043
4044 // TypeParamList
4045 #[derive(Debug, PartialEq, Eq, Hash)]
4046 #[repr(transparent)]
4047 pub struct TypeParamList {
4048     pub(crate) syntax: SyntaxNode,
4049 }
4050 unsafe impl TransparentNewType for TypeParamList {
4051     type Repr = rowan::SyntaxNode;
4052 }
4053
4054 impl AstNode for TypeParamList {
4055     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4056         match syntax.kind() {
4057             TYPE_PARAM_LIST => Some(TypeParamList::from_repr(syntax.into_repr())),
4058             _ => None,
4059         }
4060     }
4061     fn syntax(&self) -> &SyntaxNode { &self.syntax }
4062 }
4063
4064 impl ToOwned for TypeParamList {
4065     type Owned = TreeArc<TypeParamList>;
4066     fn to_owned(&self) -> TreeArc<TypeParamList> { TreeArc::cast(self.syntax.to_owned()) }
4067 }
4068
4069
4070 impl TypeParamList {
4071     pub fn type_params(&self) -> impl Iterator<Item = &TypeParam> {
4072         super::children(self)
4073     }
4074
4075     pub fn lifetime_params(&self) -> impl Iterator<Item = &LifetimeParam> {
4076         super::children(self)
4077     }
4078 }
4079
4080 // TypeRef
4081 #[derive(Debug, PartialEq, Eq, Hash)]
4082 #[repr(transparent)]
4083 pub struct TypeRef {
4084     pub(crate) syntax: SyntaxNode,
4085 }
4086 unsafe impl TransparentNewType for TypeRef {
4087     type Repr = rowan::SyntaxNode;
4088 }
4089
4090 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4091 pub enum TypeRefKind<'a> {
4092     ParenType(&'a ParenType),
4093     TupleType(&'a TupleType),
4094     NeverType(&'a NeverType),
4095     PathType(&'a PathType),
4096     PointerType(&'a PointerType),
4097     ArrayType(&'a ArrayType),
4098     SliceType(&'a SliceType),
4099     ReferenceType(&'a ReferenceType),
4100     PlaceholderType(&'a PlaceholderType),
4101     FnPointerType(&'a FnPointerType),
4102     ForType(&'a ForType),
4103     ImplTraitType(&'a ImplTraitType),
4104     DynTraitType(&'a DynTraitType),
4105 }
4106 impl<'a> From<&'a ParenType> for &'a TypeRef {
4107     fn from(n: &'a ParenType) -> &'a TypeRef {
4108         TypeRef::cast(&n.syntax).unwrap()
4109     }
4110 }
4111 impl<'a> From<&'a TupleType> for &'a TypeRef {
4112     fn from(n: &'a TupleType) -> &'a TypeRef {
4113         TypeRef::cast(&n.syntax).unwrap()
4114     }
4115 }
4116 impl<'a> From<&'a NeverType> for &'a TypeRef {
4117     fn from(n: &'a NeverType) -> &'a TypeRef {
4118         TypeRef::cast(&n.syntax).unwrap()
4119     }
4120 }
4121 impl<'a> From<&'a PathType> for &'a TypeRef {
4122     fn from(n: &'a PathType) -> &'a TypeRef {
4123         TypeRef::cast(&n.syntax).unwrap()
4124     }
4125 }
4126 impl<'a> From<&'a PointerType> for &'a TypeRef {
4127     fn from(n: &'a PointerType) -> &'a TypeRef {
4128         TypeRef::cast(&n.syntax).unwrap()
4129     }
4130 }
4131 impl<'a> From<&'a ArrayType> for &'a TypeRef {
4132     fn from(n: &'a ArrayType) -> &'a TypeRef {
4133         TypeRef::cast(&n.syntax).unwrap()
4134     }
4135 }
4136 impl<'a> From<&'a SliceType> for &'a TypeRef {
4137     fn from(n: &'a SliceType) -> &'a TypeRef {
4138         TypeRef::cast(&n.syntax).unwrap()
4139     }
4140 }
4141 impl<'a> From<&'a ReferenceType> for &'a TypeRef {
4142     fn from(n: &'a ReferenceType) -> &'a TypeRef {
4143         TypeRef::cast(&n.syntax).unwrap()
4144     }
4145 }
4146 impl<'a> From<&'a PlaceholderType> for &'a TypeRef {
4147     fn from(n: &'a PlaceholderType) -> &'a TypeRef {
4148         TypeRef::cast(&n.syntax).unwrap()
4149     }
4150 }
4151 impl<'a> From<&'a FnPointerType> for &'a TypeRef {
4152     fn from(n: &'a FnPointerType) -> &'a TypeRef {
4153         TypeRef::cast(&n.syntax).unwrap()
4154     }
4155 }
4156 impl<'a> From<&'a ForType> for &'a TypeRef {
4157     fn from(n: &'a ForType) -> &'a TypeRef {
4158         TypeRef::cast(&n.syntax).unwrap()
4159     }
4160 }
4161 impl<'a> From<&'a ImplTraitType> for &'a TypeRef {
4162     fn from(n: &'a ImplTraitType) -> &'a TypeRef {
4163         TypeRef::cast(&n.syntax).unwrap()
4164     }
4165 }
4166 impl<'a> From<&'a DynTraitType> for &'a TypeRef {
4167     fn from(n: &'a DynTraitType) -> &'a TypeRef {
4168         TypeRef::cast(&n.syntax).unwrap()
4169     }
4170 }
4171
4172
4173 impl AstNode for TypeRef {
4174     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4175         match syntax.kind() {
4176             | PAREN_TYPE
4177             | TUPLE_TYPE
4178             | NEVER_TYPE
4179             | PATH_TYPE
4180             | POINTER_TYPE
4181             | ARRAY_TYPE
4182             | SLICE_TYPE
4183             | REFERENCE_TYPE
4184             | PLACEHOLDER_TYPE
4185             | FN_POINTER_TYPE
4186             | FOR_TYPE
4187             | IMPL_TRAIT_TYPE
4188             | DYN_TRAIT_TYPE => Some(TypeRef::from_repr(syntax.into_repr())),
4189             _ => None,
4190         }
4191     }
4192     fn syntax(&self) -> &SyntaxNode { &self.syntax }
4193 }
4194
4195 impl ToOwned for TypeRef {
4196     type Owned = TreeArc<TypeRef>;
4197     fn to_owned(&self) -> TreeArc<TypeRef> { TreeArc::cast(self.syntax.to_owned()) }
4198 }
4199
4200 impl TypeRef {
4201     pub fn kind(&self) -> TypeRefKind {
4202         match self.syntax.kind() {
4203             PAREN_TYPE => TypeRefKind::ParenType(ParenType::cast(&self.syntax).unwrap()),
4204             TUPLE_TYPE => TypeRefKind::TupleType(TupleType::cast(&self.syntax).unwrap()),
4205             NEVER_TYPE => TypeRefKind::NeverType(NeverType::cast(&self.syntax).unwrap()),
4206             PATH_TYPE => TypeRefKind::PathType(PathType::cast(&self.syntax).unwrap()),
4207             POINTER_TYPE => TypeRefKind::PointerType(PointerType::cast(&self.syntax).unwrap()),
4208             ARRAY_TYPE => TypeRefKind::ArrayType(ArrayType::cast(&self.syntax).unwrap()),
4209             SLICE_TYPE => TypeRefKind::SliceType(SliceType::cast(&self.syntax).unwrap()),
4210             REFERENCE_TYPE => TypeRefKind::ReferenceType(ReferenceType::cast(&self.syntax).unwrap()),
4211             PLACEHOLDER_TYPE => TypeRefKind::PlaceholderType(PlaceholderType::cast(&self.syntax).unwrap()),
4212             FN_POINTER_TYPE => TypeRefKind::FnPointerType(FnPointerType::cast(&self.syntax).unwrap()),
4213             FOR_TYPE => TypeRefKind::ForType(ForType::cast(&self.syntax).unwrap()),
4214             IMPL_TRAIT_TYPE => TypeRefKind::ImplTraitType(ImplTraitType::cast(&self.syntax).unwrap()),
4215             DYN_TRAIT_TYPE => TypeRefKind::DynTraitType(DynTraitType::cast(&self.syntax).unwrap()),
4216             _ => unreachable!(),
4217         }
4218     }
4219 }
4220
4221 impl TypeRef {}
4222
4223 // UseItem
4224 #[derive(Debug, PartialEq, Eq, Hash)]
4225 #[repr(transparent)]
4226 pub struct UseItem {
4227     pub(crate) syntax: SyntaxNode,
4228 }
4229 unsafe impl TransparentNewType for UseItem {
4230     type Repr = rowan::SyntaxNode;
4231 }
4232
4233 impl AstNode for UseItem {
4234     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4235         match syntax.kind() {
4236             USE_ITEM => Some(UseItem::from_repr(syntax.into_repr())),
4237             _ => None,
4238         }
4239     }
4240     fn syntax(&self) -> &SyntaxNode { &self.syntax }
4241 }
4242
4243 impl ToOwned for UseItem {
4244     type Owned = TreeArc<UseItem>;
4245     fn to_owned(&self) -> TreeArc<UseItem> { TreeArc::cast(self.syntax.to_owned()) }
4246 }
4247
4248
4249 impl ast::AttrsOwner for UseItem {}
4250 impl UseItem {
4251     pub fn use_tree(&self) -> Option<&UseTree> {
4252         super::child_opt(self)
4253     }
4254 }
4255
4256 // UseTree
4257 #[derive(Debug, PartialEq, Eq, Hash)]
4258 #[repr(transparent)]
4259 pub struct UseTree {
4260     pub(crate) syntax: SyntaxNode,
4261 }
4262 unsafe impl TransparentNewType for UseTree {
4263     type Repr = rowan::SyntaxNode;
4264 }
4265
4266 impl AstNode for UseTree {
4267     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4268         match syntax.kind() {
4269             USE_TREE => Some(UseTree::from_repr(syntax.into_repr())),
4270             _ => None,
4271         }
4272     }
4273     fn syntax(&self) -> &SyntaxNode { &self.syntax }
4274 }
4275
4276 impl ToOwned for UseTree {
4277     type Owned = TreeArc<UseTree>;
4278     fn to_owned(&self) -> TreeArc<UseTree> { TreeArc::cast(self.syntax.to_owned()) }
4279 }
4280
4281
4282 impl UseTree {
4283     pub fn path(&self) -> Option<&Path> {
4284         super::child_opt(self)
4285     }
4286
4287     pub fn use_tree_list(&self) -> Option<&UseTreeList> {
4288         super::child_opt(self)
4289     }
4290
4291     pub fn alias(&self) -> Option<&Alias> {
4292         super::child_opt(self)
4293     }
4294 }
4295
4296 // UseTreeList
4297 #[derive(Debug, PartialEq, Eq, Hash)]
4298 #[repr(transparent)]
4299 pub struct UseTreeList {
4300     pub(crate) syntax: SyntaxNode,
4301 }
4302 unsafe impl TransparentNewType for UseTreeList {
4303     type Repr = rowan::SyntaxNode;
4304 }
4305
4306 impl AstNode for UseTreeList {
4307     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4308         match syntax.kind() {
4309             USE_TREE_LIST => Some(UseTreeList::from_repr(syntax.into_repr())),
4310             _ => None,
4311         }
4312     }
4313     fn syntax(&self) -> &SyntaxNode { &self.syntax }
4314 }
4315
4316 impl ToOwned for UseTreeList {
4317     type Owned = TreeArc<UseTreeList>;
4318     fn to_owned(&self) -> TreeArc<UseTreeList> { TreeArc::cast(self.syntax.to_owned()) }
4319 }
4320
4321
4322 impl UseTreeList {
4323     pub fn use_trees(&self) -> impl Iterator<Item = &UseTree> {
4324         super::children(self)
4325     }
4326 }
4327
4328 // Visibility
4329 #[derive(Debug, PartialEq, Eq, Hash)]
4330 #[repr(transparent)]
4331 pub struct Visibility {
4332     pub(crate) syntax: SyntaxNode,
4333 }
4334 unsafe impl TransparentNewType for Visibility {
4335     type Repr = rowan::SyntaxNode;
4336 }
4337
4338 impl AstNode for Visibility {
4339     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4340         match syntax.kind() {
4341             VISIBILITY => Some(Visibility::from_repr(syntax.into_repr())),
4342             _ => None,
4343         }
4344     }
4345     fn syntax(&self) -> &SyntaxNode { &self.syntax }
4346 }
4347
4348 impl ToOwned for Visibility {
4349     type Owned = TreeArc<Visibility>;
4350     fn to_owned(&self) -> TreeArc<Visibility> { TreeArc::cast(self.syntax.to_owned()) }
4351 }
4352
4353
4354 impl Visibility {}
4355
4356 // WhereClause
4357 #[derive(Debug, PartialEq, Eq, Hash)]
4358 #[repr(transparent)]
4359 pub struct WhereClause {
4360     pub(crate) syntax: SyntaxNode,
4361 }
4362 unsafe impl TransparentNewType for WhereClause {
4363     type Repr = rowan::SyntaxNode;
4364 }
4365
4366 impl AstNode for WhereClause {
4367     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4368         match syntax.kind() {
4369             WHERE_CLAUSE => Some(WhereClause::from_repr(syntax.into_repr())),
4370             _ => None,
4371         }
4372     }
4373     fn syntax(&self) -> &SyntaxNode { &self.syntax }
4374 }
4375
4376 impl ToOwned for WhereClause {
4377     type Owned = TreeArc<WhereClause>;
4378     fn to_owned(&self) -> TreeArc<WhereClause> { TreeArc::cast(self.syntax.to_owned()) }
4379 }
4380
4381
4382 impl WhereClause {
4383     pub fn predicates(&self) -> impl Iterator<Item = &WherePred> {
4384         super::children(self)
4385     }
4386 }
4387
4388 // WherePred
4389 #[derive(Debug, PartialEq, Eq, Hash)]
4390 #[repr(transparent)]
4391 pub struct WherePred {
4392     pub(crate) syntax: SyntaxNode,
4393 }
4394 unsafe impl TransparentNewType for WherePred {
4395     type Repr = rowan::SyntaxNode;
4396 }
4397
4398 impl AstNode for WherePred {
4399     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4400         match syntax.kind() {
4401             WHERE_PRED => Some(WherePred::from_repr(syntax.into_repr())),
4402             _ => None,
4403         }
4404     }
4405     fn syntax(&self) -> &SyntaxNode { &self.syntax }
4406 }
4407
4408 impl ToOwned for WherePred {
4409     type Owned = TreeArc<WherePred>;
4410     fn to_owned(&self) -> TreeArc<WherePred> { TreeArc::cast(self.syntax.to_owned()) }
4411 }
4412
4413
4414 impl ast::TypeBoundsOwner for WherePred {}
4415 impl WherePred {
4416     pub fn type_ref(&self) -> Option<&TypeRef> {
4417         super::child_opt(self)
4418     }
4419 }
4420
4421 // WhileExpr
4422 #[derive(Debug, PartialEq, Eq, Hash)]
4423 #[repr(transparent)]
4424 pub struct WhileExpr {
4425     pub(crate) syntax: SyntaxNode,
4426 }
4427 unsafe impl TransparentNewType for WhileExpr {
4428     type Repr = rowan::SyntaxNode;
4429 }
4430
4431 impl AstNode for WhileExpr {
4432     fn cast(syntax: &SyntaxNode) -> Option<&Self> {
4433         match syntax.kind() {
4434             WHILE_EXPR => Some(WhileExpr::from_repr(syntax.into_repr())),
4435             _ => None,
4436         }
4437     }
4438     fn syntax(&self) -> &SyntaxNode { &self.syntax }
4439 }
4440
4441 impl ToOwned for WhileExpr {
4442     type Owned = TreeArc<WhileExpr>;
4443     fn to_owned(&self) -> TreeArc<WhileExpr> { TreeArc::cast(self.syntax.to_owned()) }
4444 }
4445
4446
4447 impl ast::LoopBodyOwner for WhileExpr {}
4448 impl WhileExpr {
4449     pub fn condition(&self) -> Option<&Condition> {
4450         super::child_opt(self)
4451     }
4452 }
4453