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