aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-11-06 19:08:00 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-11-06 19:08:00 +0000
commit3928255b6f919ca0a0a93393ab7fa3d0ce6df681 (patch)
treefd67f18d5a631a1cbcb84cbe3455713943253fb8 /crates/ra_syntax
parent21797bf0efdeafde4148fe02ba4bd11171737872 (diff)
parent7f88fe8790014f4c879ec49de4bfdb823043e16a (diff)
Merge #209
209: Owned nodes r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/ast/generated.rs3017
-rw-r--r--crates/ra_syntax/src/ast/generated.rs.tera38
-rw-r--r--crates/ra_syntax/src/ast/mod.rs4
3 files changed, 1253 insertions, 1806 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index 75769a4e9..420d9090c 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -1,35 +1,27 @@
1// This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-syntax` is run 1// This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-syntax` is run
2// Do not edit manually 2// Do not edit manually
3 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
4#![cfg_attr(rustfmt, rustfmt_skip)] 10#![cfg_attr(rustfmt, rustfmt_skip)]
5 11
6use crate::{ 12use crate::{
7 ast, 13 ast,
8 SyntaxNode, SyntaxNodeRef, AstNode, 14 SyntaxNode, SyntaxNodeRef, AstNode,
15 yellow::{TreeRoot, RaTypes, OwnedRoot, RefRoot},
9 SyntaxKind::*, 16 SyntaxKind::*,
10}; 17};
11 18
12// ArgList 19// ArgList
13
14#[derive(Debug, Clone)]
15pub struct ArgListNode(SyntaxNode);
16
17impl ArgListNode {
18 pub fn ast(&self) -> ArgList {
19 ArgList::cast(self.0.borrowed()).unwrap()
20 }
21}
22
23impl<'a> From<ArgList<'a>> for ArgListNode {
24 fn from(ast: ArgList<'a>) -> ArgListNode {
25 let syntax = ast.syntax().owned();
26 ArgListNode(syntax)
27 }
28}
29#[derive(Debug, Clone, Copy)] 20#[derive(Debug, Clone, Copy)]
30pub struct ArgList<'a> { 21pub struct ArgListNode<R: TreeRoot<RaTypes> = OwnedRoot> {
31 syntax: SyntaxNodeRef<'a>, 22 syntax: SyntaxNode<R>,
32} 23}
24pub type ArgList<'a> = ArgListNode<RefRoot<'a>>;
33 25
34impl<'a> AstNode<'a> for ArgList<'a> { 26impl<'a> AstNode<'a> for ArgList<'a> {
35 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 27 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -41,33 +33,28 @@ impl<'a> AstNode<'a> for ArgList<'a> {
41 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 33 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
42} 34}
43 35
44impl<'a> ArgList<'a> { 36impl<R: TreeRoot<RaTypes>> ArgListNode<R> {
45 pub fn args(self) -> impl Iterator<Item = Expr<'a>> + 'a { 37 pub fn borrowed(&self) -> ArgList {
46 super::children(self) 38 ArgListNode { syntax: self.syntax.borrowed() }
39 }
40 pub fn owned(&self) -> ArgListNode {
41 ArgListNode { syntax: self.syntax.owned() }
47 } 42 }
48} 43}
49 44
50// ArrayExpr
51 45
52#[derive(Debug, Clone)] 46impl<'a> ArgList<'a> {
53pub struct ArrayExprNode(SyntaxNode); 47 pub fn args(self) -> impl Iterator<Item = Expr<'a>> + 'a {
54 48 super::children(self)
55impl ArrayExprNode {
56 pub fn ast(&self) -> ArrayExpr {
57 ArrayExpr::cast(self.0.borrowed()).unwrap()
58 } 49 }
59} 50}
60 51
61impl<'a> From<ArrayExpr<'a>> for ArrayExprNode { 52// ArrayExpr
62 fn from(ast: ArrayExpr<'a>) -> ArrayExprNode {
63 let syntax = ast.syntax().owned();
64 ArrayExprNode(syntax)
65 }
66}
67#[derive(Debug, Clone, Copy)] 53#[derive(Debug, Clone, Copy)]
68pub struct ArrayExpr<'a> { 54pub struct ArrayExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
69 syntax: SyntaxNodeRef<'a>, 55 syntax: SyntaxNode<R>,
70} 56}
57pub type ArrayExpr<'a> = ArrayExprNode<RefRoot<'a>>;
71 58
72impl<'a> AstNode<'a> for ArrayExpr<'a> { 59impl<'a> AstNode<'a> for ArrayExpr<'a> {
73 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 60 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -79,29 +66,24 @@ impl<'a> AstNode<'a> for ArrayExpr<'a> {
79 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 66 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
80} 67}
81 68
82impl<'a> ArrayExpr<'a> {} 69impl<R: TreeRoot<RaTypes>> ArrayExprNode<R> {
83 70 pub fn borrowed(&self) -> ArrayExpr {
84// ArrayType 71 ArrayExprNode { syntax: self.syntax.borrowed() }
85
86#[derive(Debug, Clone)]
87pub struct ArrayTypeNode(SyntaxNode);
88
89impl ArrayTypeNode {
90 pub fn ast(&self) -> ArrayType {
91 ArrayType::cast(self.0.borrowed()).unwrap()
92 } 72 }
93} 73 pub fn owned(&self) -> ArrayExprNode {
94 74 ArrayExprNode { syntax: self.syntax.owned() }
95impl<'a> From<ArrayType<'a>> for ArrayTypeNode {
96 fn from(ast: ArrayType<'a>) -> ArrayTypeNode {
97 let syntax = ast.syntax().owned();
98 ArrayTypeNode(syntax)
99 } 75 }
100} 76}
77
78
79impl<'a> ArrayExpr<'a> {}
80
81// ArrayType
101#[derive(Debug, Clone, Copy)] 82#[derive(Debug, Clone, Copy)]
102pub struct ArrayType<'a> { 83pub struct ArrayTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
103 syntax: SyntaxNodeRef<'a>, 84 syntax: SyntaxNode<R>,
104} 85}
86pub type ArrayType<'a> = ArrayTypeNode<RefRoot<'a>>;
105 87
106impl<'a> AstNode<'a> for ArrayType<'a> { 88impl<'a> AstNode<'a> for ArrayType<'a> {
107 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 89 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -113,29 +95,24 @@ impl<'a> AstNode<'a> for ArrayType<'a> {
113 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 95 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
114} 96}
115 97
116impl<'a> ArrayType<'a> {} 98impl<R: TreeRoot<RaTypes>> ArrayTypeNode<R> {
117 99 pub fn borrowed(&self) -> ArrayType {
118// Attr 100 ArrayTypeNode { syntax: self.syntax.borrowed() }
119
120#[derive(Debug, Clone)]
121pub struct AttrNode(SyntaxNode);
122
123impl AttrNode {
124 pub fn ast(&self) -> Attr {
125 Attr::cast(self.0.borrowed()).unwrap()
126 } 101 }
127} 102 pub fn owned(&self) -> ArrayTypeNode {
128 103 ArrayTypeNode { syntax: self.syntax.owned() }
129impl<'a> From<Attr<'a>> for AttrNode {
130 fn from(ast: Attr<'a>) -> AttrNode {
131 let syntax = ast.syntax().owned();
132 AttrNode(syntax)
133 } 104 }
134} 105}
106
107
108impl<'a> ArrayType<'a> {}
109
110// Attr
135#[derive(Debug, Clone, Copy)] 111#[derive(Debug, Clone, Copy)]
136pub struct Attr<'a> { 112pub struct AttrNode<R: TreeRoot<RaTypes> = OwnedRoot> {
137 syntax: SyntaxNodeRef<'a>, 113 syntax: SyntaxNode<R>,
138} 114}
115pub type Attr<'a> = AttrNode<RefRoot<'a>>;
139 116
140impl<'a> AstNode<'a> for Attr<'a> { 117impl<'a> AstNode<'a> for Attr<'a> {
141 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 118 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -147,33 +124,28 @@ impl<'a> AstNode<'a> for Attr<'a> {
147 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 124 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
148} 125}
149 126
150impl<'a> Attr<'a> { 127impl<R: TreeRoot<RaTypes>> AttrNode<R> {
151 pub fn value(self) -> Option<TokenTree<'a>> { 128 pub fn borrowed(&self) -> Attr {
152 super::child_opt(self) 129 AttrNode { syntax: self.syntax.borrowed() }
130 }
131 pub fn owned(&self) -> AttrNode {
132 AttrNode { syntax: self.syntax.owned() }
153 } 133 }
154} 134}
155 135
156// BinExpr
157
158#[derive(Debug, Clone)]
159pub struct BinExprNode(SyntaxNode);
160 136
161impl BinExprNode { 137impl<'a> Attr<'a> {
162 pub fn ast(&self) -> BinExpr { 138 pub fn value(self) -> Option<TokenTree<'a>> {
163 BinExpr::cast(self.0.borrowed()).unwrap() 139 super::child_opt(self)
164 } 140 }
165} 141}
166 142
167impl<'a> From<BinExpr<'a>> for BinExprNode { 143// BinExpr
168 fn from(ast: BinExpr<'a>) -> BinExprNode {
169 let syntax = ast.syntax().owned();
170 BinExprNode(syntax)
171 }
172}
173#[derive(Debug, Clone, Copy)] 144#[derive(Debug, Clone, Copy)]
174pub struct BinExpr<'a> { 145pub struct BinExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
175 syntax: SyntaxNodeRef<'a>, 146 syntax: SyntaxNode<R>,
176} 147}
148pub type BinExpr<'a> = BinExprNode<RefRoot<'a>>;
177 149
178impl<'a> AstNode<'a> for BinExpr<'a> { 150impl<'a> AstNode<'a> for BinExpr<'a> {
179 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 151 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -185,29 +157,24 @@ impl<'a> AstNode<'a> for BinExpr<'a> {
185 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 157 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
186} 158}
187 159
188impl<'a> BinExpr<'a> {} 160impl<R: TreeRoot<RaTypes>> BinExprNode<R> {
189 161 pub fn borrowed(&self) -> BinExpr {
190// BindPat 162 BinExprNode { syntax: self.syntax.borrowed() }
191
192#[derive(Debug, Clone)]
193pub struct BindPatNode(SyntaxNode);
194
195impl BindPatNode {
196 pub fn ast(&self) -> BindPat {
197 BindPat::cast(self.0.borrowed()).unwrap()
198 } 163 }
199} 164 pub fn owned(&self) -> BinExprNode {
200 165 BinExprNode { syntax: self.syntax.owned() }
201impl<'a> From<BindPat<'a>> for BindPatNode {
202 fn from(ast: BindPat<'a>) -> BindPatNode {
203 let syntax = ast.syntax().owned();
204 BindPatNode(syntax)
205 } 166 }
206} 167}
168
169
170impl<'a> BinExpr<'a> {}
171
172// BindPat
207#[derive(Debug, Clone, Copy)] 173#[derive(Debug, Clone, Copy)]
208pub struct BindPat<'a> { 174pub struct BindPatNode<R: TreeRoot<RaTypes> = OwnedRoot> {
209 syntax: SyntaxNodeRef<'a>, 175 syntax: SyntaxNode<R>,
210} 176}
177pub type BindPat<'a> = BindPatNode<RefRoot<'a>>;
211 178
212impl<'a> AstNode<'a> for BindPat<'a> { 179impl<'a> AstNode<'a> for BindPat<'a> {
213 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 180 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -219,30 +186,25 @@ impl<'a> AstNode<'a> for BindPat<'a> {
219 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 186 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
220} 187}
221 188
189impl<R: TreeRoot<RaTypes>> BindPatNode<R> {
190 pub fn borrowed(&self) -> BindPat {
191 BindPatNode { syntax: self.syntax.borrowed() }
192 }
193 pub fn owned(&self) -> BindPatNode {
194 BindPatNode { syntax: self.syntax.owned() }
195 }
196}
197
198
222impl<'a> ast::NameOwner<'a> for BindPat<'a> {} 199impl<'a> ast::NameOwner<'a> for BindPat<'a> {}
223impl<'a> BindPat<'a> {} 200impl<'a> BindPat<'a> {}
224 201
225// Block 202// Block
226
227#[derive(Debug, Clone)]
228pub struct BlockNode(SyntaxNode);
229
230impl BlockNode {
231 pub fn ast(&self) -> Block {
232 Block::cast(self.0.borrowed()).unwrap()
233 }
234}
235
236impl<'a> From<Block<'a>> for BlockNode {
237 fn from(ast: Block<'a>) -> BlockNode {
238 let syntax = ast.syntax().owned();
239 BlockNode(syntax)
240 }
241}
242#[derive(Debug, Clone, Copy)] 203#[derive(Debug, Clone, Copy)]
243pub struct Block<'a> { 204pub struct BlockNode<R: TreeRoot<RaTypes> = OwnedRoot> {
244 syntax: SyntaxNodeRef<'a>, 205 syntax: SyntaxNode<R>,
245} 206}
207pub type Block<'a> = BlockNode<RefRoot<'a>>;
246 208
247impl<'a> AstNode<'a> for Block<'a> { 209impl<'a> AstNode<'a> for Block<'a> {
248 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 210 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -254,6 +216,16 @@ impl<'a> AstNode<'a> for Block<'a> {
254 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 216 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
255} 217}
256 218
219impl<R: TreeRoot<RaTypes>> BlockNode<R> {
220 pub fn borrowed(&self) -> Block {
221 BlockNode { syntax: self.syntax.borrowed() }
222 }
223 pub fn owned(&self) -> BlockNode {
224 BlockNode { syntax: self.syntax.owned() }
225 }
226}
227
228
257impl<'a> Block<'a> { 229impl<'a> Block<'a> {
258 pub fn statements(self) -> impl Iterator<Item = Stmt<'a>> + 'a { 230 pub fn statements(self) -> impl Iterator<Item = Stmt<'a>> + 'a {
259 super::children(self) 231 super::children(self)
@@ -265,26 +237,11 @@ impl<'a> Block<'a> {
265} 237}
266 238
267// BlockExpr 239// BlockExpr
268
269#[derive(Debug, Clone)]
270pub struct BlockExprNode(SyntaxNode);
271
272impl BlockExprNode {
273 pub fn ast(&self) -> BlockExpr {
274 BlockExpr::cast(self.0.borrowed()).unwrap()
275 }
276}
277
278impl<'a> From<BlockExpr<'a>> for BlockExprNode {
279 fn from(ast: BlockExpr<'a>) -> BlockExprNode {
280 let syntax = ast.syntax().owned();
281 BlockExprNode(syntax)
282 }
283}
284#[derive(Debug, Clone, Copy)] 240#[derive(Debug, Clone, Copy)]
285pub struct BlockExpr<'a> { 241pub struct BlockExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
286 syntax: SyntaxNodeRef<'a>, 242 syntax: SyntaxNode<R>,
287} 243}
244pub type BlockExpr<'a> = BlockExprNode<RefRoot<'a>>;
288 245
289impl<'a> AstNode<'a> for BlockExpr<'a> { 246impl<'a> AstNode<'a> for BlockExpr<'a> {
290 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 247 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -296,33 +253,28 @@ impl<'a> AstNode<'a> for BlockExpr<'a> {
296 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 253 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
297} 254}
298 255
299impl<'a> BlockExpr<'a> { 256impl<R: TreeRoot<RaTypes>> BlockExprNode<R> {
300 pub fn block(self) -> Option<Block<'a>> { 257 pub fn borrowed(&self) -> BlockExpr {
301 super::child_opt(self) 258 BlockExprNode { syntax: self.syntax.borrowed() }
259 }
260 pub fn owned(&self) -> BlockExprNode {
261 BlockExprNode { syntax: self.syntax.owned() }
302 } 262 }
303} 263}
304 264
305// BreakExpr
306
307#[derive(Debug, Clone)]
308pub struct BreakExprNode(SyntaxNode);
309 265
310impl BreakExprNode { 266impl<'a> BlockExpr<'a> {
311 pub fn ast(&self) -> BreakExpr { 267 pub fn block(self) -> Option<Block<'a>> {
312 BreakExpr::cast(self.0.borrowed()).unwrap() 268 super::child_opt(self)
313 } 269 }
314} 270}
315 271
316impl<'a> From<BreakExpr<'a>> for BreakExprNode { 272// BreakExpr
317 fn from(ast: BreakExpr<'a>) -> BreakExprNode {
318 let syntax = ast.syntax().owned();
319 BreakExprNode(syntax)
320 }
321}
322#[derive(Debug, Clone, Copy)] 273#[derive(Debug, Clone, Copy)]
323pub struct BreakExpr<'a> { 274pub struct BreakExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
324 syntax: SyntaxNodeRef<'a>, 275 syntax: SyntaxNode<R>,
325} 276}
277pub type BreakExpr<'a> = BreakExprNode<RefRoot<'a>>;
326 278
327impl<'a> AstNode<'a> for BreakExpr<'a> { 279impl<'a> AstNode<'a> for BreakExpr<'a> {
328 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 280 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -334,29 +286,24 @@ impl<'a> AstNode<'a> for BreakExpr<'a> {
334 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 286 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
335} 287}
336 288
337impl<'a> BreakExpr<'a> {} 289impl<R: TreeRoot<RaTypes>> BreakExprNode<R> {
338 290 pub fn borrowed(&self) -> BreakExpr {
339// CallExpr 291 BreakExprNode { syntax: self.syntax.borrowed() }
340
341#[derive(Debug, Clone)]
342pub struct CallExprNode(SyntaxNode);
343
344impl CallExprNode {
345 pub fn ast(&self) -> CallExpr {
346 CallExpr::cast(self.0.borrowed()).unwrap()
347 } 292 }
348} 293 pub fn owned(&self) -> BreakExprNode {
349 294 BreakExprNode { syntax: self.syntax.owned() }
350impl<'a> From<CallExpr<'a>> for CallExprNode {
351 fn from(ast: CallExpr<'a>) -> CallExprNode {
352 let syntax = ast.syntax().owned();
353 CallExprNode(syntax)
354 } 295 }
355} 296}
297
298
299impl<'a> BreakExpr<'a> {}
300
301// CallExpr
356#[derive(Debug, Clone, Copy)] 302#[derive(Debug, Clone, Copy)]
357pub struct CallExpr<'a> { 303pub struct CallExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
358 syntax: SyntaxNodeRef<'a>, 304 syntax: SyntaxNode<R>,
359} 305}
306pub type CallExpr<'a> = CallExprNode<RefRoot<'a>>;
360 307
361impl<'a> AstNode<'a> for CallExpr<'a> { 308impl<'a> AstNode<'a> for CallExpr<'a> {
362 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 309 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -368,6 +315,16 @@ impl<'a> AstNode<'a> for CallExpr<'a> {
368 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 315 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
369} 316}
370 317
318impl<R: TreeRoot<RaTypes>> CallExprNode<R> {
319 pub fn borrowed(&self) -> CallExpr {
320 CallExprNode { syntax: self.syntax.borrowed() }
321 }
322 pub fn owned(&self) -> CallExprNode {
323 CallExprNode { syntax: self.syntax.owned() }
324 }
325}
326
327
371impl<'a> ast::ArgListOwner<'a> for CallExpr<'a> {} 328impl<'a> ast::ArgListOwner<'a> for CallExpr<'a> {}
372impl<'a> CallExpr<'a> { 329impl<'a> CallExpr<'a> {
373 pub fn expr(self) -> Option<Expr<'a>> { 330 pub fn expr(self) -> Option<Expr<'a>> {
@@ -376,26 +333,11 @@ impl<'a> CallExpr<'a> {
376} 333}
377 334
378// CastExpr 335// CastExpr
379
380#[derive(Debug, Clone)]
381pub struct CastExprNode(SyntaxNode);
382
383impl CastExprNode {
384 pub fn ast(&self) -> CastExpr {
385 CastExpr::cast(self.0.borrowed()).unwrap()
386 }
387}
388
389impl<'a> From<CastExpr<'a>> for CastExprNode {
390 fn from(ast: CastExpr<'a>) -> CastExprNode {
391 let syntax = ast.syntax().owned();
392 CastExprNode(syntax)
393 }
394}
395#[derive(Debug, Clone, Copy)] 336#[derive(Debug, Clone, Copy)]
396pub struct CastExpr<'a> { 337pub struct CastExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
397 syntax: SyntaxNodeRef<'a>, 338 syntax: SyntaxNode<R>,
398} 339}
340pub type CastExpr<'a> = CastExprNode<RefRoot<'a>>;
399 341
400impl<'a> AstNode<'a> for CastExpr<'a> { 342impl<'a> AstNode<'a> for CastExpr<'a> {
401 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 343 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -407,29 +349,24 @@ impl<'a> AstNode<'a> for CastExpr<'a> {
407 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 349 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
408} 350}
409 351
410impl<'a> CastExpr<'a> {} 352impl<R: TreeRoot<RaTypes>> CastExprNode<R> {
411 353 pub fn borrowed(&self) -> CastExpr {
412// Char 354 CastExprNode { syntax: self.syntax.borrowed() }
413
414#[derive(Debug, Clone)]
415pub struct CharNode(SyntaxNode);
416
417impl CharNode {
418 pub fn ast(&self) -> Char {
419 Char::cast(self.0.borrowed()).unwrap()
420 } 355 }
421} 356 pub fn owned(&self) -> CastExprNode {
422 357 CastExprNode { syntax: self.syntax.owned() }
423impl<'a> From<Char<'a>> for CharNode {
424 fn from(ast: Char<'a>) -> CharNode {
425 let syntax = ast.syntax().owned();
426 CharNode(syntax)
427 } 358 }
428} 359}
360
361
362impl<'a> CastExpr<'a> {}
363
364// Char
429#[derive(Debug, Clone, Copy)] 365#[derive(Debug, Clone, Copy)]
430pub struct Char<'a> { 366pub struct CharNode<R: TreeRoot<RaTypes> = OwnedRoot> {
431 syntax: SyntaxNodeRef<'a>, 367 syntax: SyntaxNode<R>,
432} 368}
369pub type Char<'a> = CharNode<RefRoot<'a>>;
433 370
434impl<'a> AstNode<'a> for Char<'a> { 371impl<'a> AstNode<'a> for Char<'a> {
435 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 372 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -441,29 +378,24 @@ impl<'a> AstNode<'a> for Char<'a> {
441 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 378 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
442} 379}
443 380
444impl<'a> Char<'a> {} 381impl<R: TreeRoot<RaTypes>> CharNode<R> {
445 382 pub fn borrowed(&self) -> Char {
446// Comment 383 CharNode { syntax: self.syntax.borrowed() }
447
448#[derive(Debug, Clone)]
449pub struct CommentNode(SyntaxNode);
450
451impl CommentNode {
452 pub fn ast(&self) -> Comment {
453 Comment::cast(self.0.borrowed()).unwrap()
454 } 384 }
455} 385 pub fn owned(&self) -> CharNode {
456 386 CharNode { syntax: self.syntax.owned() }
457impl<'a> From<Comment<'a>> for CommentNode {
458 fn from(ast: Comment<'a>) -> CommentNode {
459 let syntax = ast.syntax().owned();
460 CommentNode(syntax)
461 } 387 }
462} 388}
389
390
391impl<'a> Char<'a> {}
392
393// Comment
463#[derive(Debug, Clone, Copy)] 394#[derive(Debug, Clone, Copy)]
464pub struct Comment<'a> { 395pub struct CommentNode<R: TreeRoot<RaTypes> = OwnedRoot> {
465 syntax: SyntaxNodeRef<'a>, 396 syntax: SyntaxNode<R>,
466} 397}
398pub type Comment<'a> = CommentNode<RefRoot<'a>>;
467 399
468impl<'a> AstNode<'a> for Comment<'a> { 400impl<'a> AstNode<'a> for Comment<'a> {
469 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 401 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -475,29 +407,24 @@ impl<'a> AstNode<'a> for Comment<'a> {
475 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 407 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
476} 408}
477 409
478impl<'a> Comment<'a> {} 410impl<R: TreeRoot<RaTypes>> CommentNode<R> {
479 411 pub fn borrowed(&self) -> Comment {
480// Condition 412 CommentNode { syntax: self.syntax.borrowed() }
481
482#[derive(Debug, Clone)]
483pub struct ConditionNode(SyntaxNode);
484
485impl ConditionNode {
486 pub fn ast(&self) -> Condition {
487 Condition::cast(self.0.borrowed()).unwrap()
488 } 413 }
489} 414 pub fn owned(&self) -> CommentNode {
490 415 CommentNode { syntax: self.syntax.owned() }
491impl<'a> From<Condition<'a>> for ConditionNode {
492 fn from(ast: Condition<'a>) -> ConditionNode {
493 let syntax = ast.syntax().owned();
494 ConditionNode(syntax)
495 } 416 }
496} 417}
418
419
420impl<'a> Comment<'a> {}
421
422// Condition
497#[derive(Debug, Clone, Copy)] 423#[derive(Debug, Clone, Copy)]
498pub struct Condition<'a> { 424pub struct ConditionNode<R: TreeRoot<RaTypes> = OwnedRoot> {
499 syntax: SyntaxNodeRef<'a>, 425 syntax: SyntaxNode<R>,
500} 426}
427pub type Condition<'a> = ConditionNode<RefRoot<'a>>;
501 428
502impl<'a> AstNode<'a> for Condition<'a> { 429impl<'a> AstNode<'a> for Condition<'a> {
503 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 430 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -509,6 +436,16 @@ impl<'a> AstNode<'a> for Condition<'a> {
509 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 436 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
510} 437}
511 438
439impl<R: TreeRoot<RaTypes>> ConditionNode<R> {
440 pub fn borrowed(&self) -> Condition {
441 ConditionNode { syntax: self.syntax.borrowed() }
442 }
443 pub fn owned(&self) -> ConditionNode {
444 ConditionNode { syntax: self.syntax.owned() }
445 }
446}
447
448
512impl<'a> Condition<'a> { 449impl<'a> Condition<'a> {
513 pub fn pat(self) -> Option<Pat<'a>> { 450 pub fn pat(self) -> Option<Pat<'a>> {
514 super::child_opt(self) 451 super::child_opt(self)
@@ -520,26 +457,11 @@ impl<'a> Condition<'a> {
520} 457}
521 458
522// ConstDef 459// ConstDef
523
524#[derive(Debug, Clone)]
525pub struct ConstDefNode(SyntaxNode);
526
527impl ConstDefNode {
528 pub fn ast(&self) -> ConstDef {
529 ConstDef::cast(self.0.borrowed()).unwrap()
530 }
531}
532
533impl<'a> From<ConstDef<'a>> for ConstDefNode {
534 fn from(ast: ConstDef<'a>) -> ConstDefNode {
535 let syntax = ast.syntax().owned();
536 ConstDefNode(syntax)
537 }
538}
539#[derive(Debug, Clone, Copy)] 460#[derive(Debug, Clone, Copy)]
540pub struct ConstDef<'a> { 461pub struct ConstDefNode<R: TreeRoot<RaTypes> = OwnedRoot> {
541 syntax: SyntaxNodeRef<'a>, 462 syntax: SyntaxNode<R>,
542} 463}
464pub type ConstDef<'a> = ConstDefNode<RefRoot<'a>>;
543 465
544impl<'a> AstNode<'a> for ConstDef<'a> { 466impl<'a> AstNode<'a> for ConstDef<'a> {
545 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 467 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -551,32 +473,27 @@ impl<'a> AstNode<'a> for ConstDef<'a> {
551 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 473 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
552} 474}
553 475
476impl<R: TreeRoot<RaTypes>> ConstDefNode<R> {
477 pub fn borrowed(&self) -> ConstDef {
478 ConstDefNode { syntax: self.syntax.borrowed() }
479 }
480 pub fn owned(&self) -> ConstDefNode {
481 ConstDefNode { syntax: self.syntax.owned() }
482 }
483}
484
485
554impl<'a> ast::NameOwner<'a> for ConstDef<'a> {} 486impl<'a> ast::NameOwner<'a> for ConstDef<'a> {}
555impl<'a> ast::TypeParamsOwner<'a> for ConstDef<'a> {} 487impl<'a> ast::TypeParamsOwner<'a> for ConstDef<'a> {}
556impl<'a> ast::AttrsOwner<'a> for ConstDef<'a> {} 488impl<'a> ast::AttrsOwner<'a> for ConstDef<'a> {}
557impl<'a> ConstDef<'a> {} 489impl<'a> ConstDef<'a> {}
558 490
559// ContinueExpr 491// ContinueExpr
560
561#[derive(Debug, Clone)]
562pub struct ContinueExprNode(SyntaxNode);
563
564impl ContinueExprNode {
565 pub fn ast(&self) -> ContinueExpr {
566 ContinueExpr::cast(self.0.borrowed()).unwrap()
567 }
568}
569
570impl<'a> From<ContinueExpr<'a>> for ContinueExprNode {
571 fn from(ast: ContinueExpr<'a>) -> ContinueExprNode {
572 let syntax = ast.syntax().owned();
573 ContinueExprNode(syntax)
574 }
575}
576#[derive(Debug, Clone, Copy)] 492#[derive(Debug, Clone, Copy)]
577pub struct ContinueExpr<'a> { 493pub struct ContinueExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
578 syntax: SyntaxNodeRef<'a>, 494 syntax: SyntaxNode<R>,
579} 495}
496pub type ContinueExpr<'a> = ContinueExprNode<RefRoot<'a>>;
580 497
581impl<'a> AstNode<'a> for ContinueExpr<'a> { 498impl<'a> AstNode<'a> for ContinueExpr<'a> {
582 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 499 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -588,29 +505,24 @@ impl<'a> AstNode<'a> for ContinueExpr<'a> {
588 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 505 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
589} 506}
590 507
591impl<'a> ContinueExpr<'a> {} 508impl<R: TreeRoot<RaTypes>> ContinueExprNode<R> {
592 509 pub fn borrowed(&self) -> ContinueExpr {
593// DynTraitType 510 ContinueExprNode { syntax: self.syntax.borrowed() }
594
595#[derive(Debug, Clone)]
596pub struct DynTraitTypeNode(SyntaxNode);
597
598impl DynTraitTypeNode {
599 pub fn ast(&self) -> DynTraitType {
600 DynTraitType::cast(self.0.borrowed()).unwrap()
601 } 511 }
602} 512 pub fn owned(&self) -> ContinueExprNode {
603 513 ContinueExprNode { syntax: self.syntax.owned() }
604impl<'a> From<DynTraitType<'a>> for DynTraitTypeNode {
605 fn from(ast: DynTraitType<'a>) -> DynTraitTypeNode {
606 let syntax = ast.syntax().owned();
607 DynTraitTypeNode(syntax)
608 } 514 }
609} 515}
516
517
518impl<'a> ContinueExpr<'a> {}
519
520// DynTraitType
610#[derive(Debug, Clone, Copy)] 521#[derive(Debug, Clone, Copy)]
611pub struct DynTraitType<'a> { 522pub struct DynTraitTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
612 syntax: SyntaxNodeRef<'a>, 523 syntax: SyntaxNode<R>,
613} 524}
525pub type DynTraitType<'a> = DynTraitTypeNode<RefRoot<'a>>;
614 526
615impl<'a> AstNode<'a> for DynTraitType<'a> { 527impl<'a> AstNode<'a> for DynTraitType<'a> {
616 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 528 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -622,29 +534,24 @@ impl<'a> AstNode<'a> for DynTraitType<'a> {
622 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 534 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
623} 535}
624 536
625impl<'a> DynTraitType<'a> {} 537impl<R: TreeRoot<RaTypes>> DynTraitTypeNode<R> {
626 538 pub fn borrowed(&self) -> DynTraitType {
627// EnumDef 539 DynTraitTypeNode { syntax: self.syntax.borrowed() }
628
629#[derive(Debug, Clone)]
630pub struct EnumDefNode(SyntaxNode);
631
632impl EnumDefNode {
633 pub fn ast(&self) -> EnumDef {
634 EnumDef::cast(self.0.borrowed()).unwrap()
635 } 540 }
636} 541 pub fn owned(&self) -> DynTraitTypeNode {
637 542 DynTraitTypeNode { syntax: self.syntax.owned() }
638impl<'a> From<EnumDef<'a>> for EnumDefNode {
639 fn from(ast: EnumDef<'a>) -> EnumDefNode {
640 let syntax = ast.syntax().owned();
641 EnumDefNode(syntax)
642 } 543 }
643} 544}
545
546
547impl<'a> DynTraitType<'a> {}
548
549// EnumDef
644#[derive(Debug, Clone, Copy)] 550#[derive(Debug, Clone, Copy)]
645pub struct EnumDef<'a> { 551pub struct EnumDefNode<R: TreeRoot<RaTypes> = OwnedRoot> {
646 syntax: SyntaxNodeRef<'a>, 552 syntax: SyntaxNode<R>,
647} 553}
554pub type EnumDef<'a> = EnumDefNode<RefRoot<'a>>;
648 555
649impl<'a> AstNode<'a> for EnumDef<'a> { 556impl<'a> AstNode<'a> for EnumDef<'a> {
650 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 557 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -656,28 +563,22 @@ impl<'a> AstNode<'a> for EnumDef<'a> {
656 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 563 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
657} 564}
658 565
566impl<R: TreeRoot<RaTypes>> EnumDefNode<R> {
567 pub fn borrowed(&self) -> EnumDef {
568 EnumDefNode { syntax: self.syntax.borrowed() }
569 }
570 pub fn owned(&self) -> EnumDefNode {
571 EnumDefNode { syntax: self.syntax.owned() }
572 }
573}
574
575
659impl<'a> ast::NameOwner<'a> for EnumDef<'a> {} 576impl<'a> ast::NameOwner<'a> for EnumDef<'a> {}
660impl<'a> ast::TypeParamsOwner<'a> for EnumDef<'a> {} 577impl<'a> ast::TypeParamsOwner<'a> for EnumDef<'a> {}
661impl<'a> ast::AttrsOwner<'a> for EnumDef<'a> {} 578impl<'a> ast::AttrsOwner<'a> for EnumDef<'a> {}
662impl<'a> EnumDef<'a> {} 579impl<'a> EnumDef<'a> {}
663 580
664// Expr 581// Expr
665
666#[derive(Debug, Clone)]
667pub struct ExprNode(SyntaxNode);
668
669impl ExprNode {
670 pub fn ast(&self) -> Expr {
671 Expr::cast(self.0.borrowed()).unwrap()
672 }
673}
674
675impl<'a> From<Expr<'a>> for ExprNode {
676 fn from(ast: Expr<'a>) -> ExprNode {
677 let syntax = ast.syntax().owned();
678 ExprNode(syntax)
679 }
680}
681#[derive(Debug, Clone, Copy)] 582#[derive(Debug, Clone, Copy)]
682pub enum Expr<'a> { 583pub enum Expr<'a> {
683 TupleExpr(TupleExpr<'a>), 584 TupleExpr(TupleExpr<'a>),
@@ -793,26 +694,11 @@ impl<'a> AstNode<'a> for Expr<'a> {
793impl<'a> Expr<'a> {} 694impl<'a> Expr<'a> {}
794 695
795// ExprStmt 696// ExprStmt
796
797#[derive(Debug, Clone)]
798pub struct ExprStmtNode(SyntaxNode);
799
800impl ExprStmtNode {
801 pub fn ast(&self) -> ExprStmt {
802 ExprStmt::cast(self.0.borrowed()).unwrap()
803 }
804}
805
806impl<'a> From<ExprStmt<'a>> for ExprStmtNode {
807 fn from(ast: ExprStmt<'a>) -> ExprStmtNode {
808 let syntax = ast.syntax().owned();
809 ExprStmtNode(syntax)
810 }
811}
812#[derive(Debug, Clone, Copy)] 697#[derive(Debug, Clone, Copy)]
813pub struct ExprStmt<'a> { 698pub struct ExprStmtNode<R: TreeRoot<RaTypes> = OwnedRoot> {
814 syntax: SyntaxNodeRef<'a>, 699 syntax: SyntaxNode<R>,
815} 700}
701pub type ExprStmt<'a> = ExprStmtNode<RefRoot<'a>>;
816 702
817impl<'a> AstNode<'a> for ExprStmt<'a> { 703impl<'a> AstNode<'a> for ExprStmt<'a> {
818 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 704 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -824,33 +710,28 @@ impl<'a> AstNode<'a> for ExprStmt<'a> {
824 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 710 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
825} 711}
826 712
827impl<'a> ExprStmt<'a> { 713impl<R: TreeRoot<RaTypes>> ExprStmtNode<R> {
828 pub fn expr(self) -> Option<Expr<'a>> { 714 pub fn borrowed(&self) -> ExprStmt {
829 super::child_opt(self) 715 ExprStmtNode { syntax: self.syntax.borrowed() }
716 }
717 pub fn owned(&self) -> ExprStmtNode {
718 ExprStmtNode { syntax: self.syntax.owned() }
830 } 719 }
831} 720}
832 721
833// ExternCrateItem
834
835#[derive(Debug, Clone)]
836pub struct ExternCrateItemNode(SyntaxNode);
837 722
838impl ExternCrateItemNode { 723impl<'a> ExprStmt<'a> {
839 pub fn ast(&self) -> ExternCrateItem { 724 pub fn expr(self) -> Option<Expr<'a>> {
840 ExternCrateItem::cast(self.0.borrowed()).unwrap() 725 super::child_opt(self)
841 } 726 }
842} 727}
843 728
844impl<'a> From<ExternCrateItem<'a>> for ExternCrateItemNode { 729// ExternCrateItem
845 fn from(ast: ExternCrateItem<'a>) -> ExternCrateItemNode {
846 let syntax = ast.syntax().owned();
847 ExternCrateItemNode(syntax)
848 }
849}
850#[derive(Debug, Clone, Copy)] 730#[derive(Debug, Clone, Copy)]
851pub struct ExternCrateItem<'a> { 731pub struct ExternCrateItemNode<R: TreeRoot<RaTypes> = OwnedRoot> {
852 syntax: SyntaxNodeRef<'a>, 732 syntax: SyntaxNode<R>,
853} 733}
734pub type ExternCrateItem<'a> = ExternCrateItemNode<RefRoot<'a>>;
854 735
855impl<'a> AstNode<'a> for ExternCrateItem<'a> { 736impl<'a> AstNode<'a> for ExternCrateItem<'a> {
856 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 737 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -862,29 +743,24 @@ impl<'a> AstNode<'a> for ExternCrateItem<'a> {
862 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 743 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
863} 744}
864 745
865impl<'a> ExternCrateItem<'a> {} 746impl<R: TreeRoot<RaTypes>> ExternCrateItemNode<R> {
866 747 pub fn borrowed(&self) -> ExternCrateItem {
867// FieldExpr 748 ExternCrateItemNode { syntax: self.syntax.borrowed() }
868
869#[derive(Debug, Clone)]
870pub struct FieldExprNode(SyntaxNode);
871
872impl FieldExprNode {
873 pub fn ast(&self) -> FieldExpr {
874 FieldExpr::cast(self.0.borrowed()).unwrap()
875 } 749 }
876} 750 pub fn owned(&self) -> ExternCrateItemNode {
877 751 ExternCrateItemNode { syntax: self.syntax.owned() }
878impl<'a> From<FieldExpr<'a>> for FieldExprNode {
879 fn from(ast: FieldExpr<'a>) -> FieldExprNode {
880 let syntax = ast.syntax().owned();
881 FieldExprNode(syntax)
882 } 752 }
883} 753}
754
755
756impl<'a> ExternCrateItem<'a> {}
757
758// FieldExpr
884#[derive(Debug, Clone, Copy)] 759#[derive(Debug, Clone, Copy)]
885pub struct FieldExpr<'a> { 760pub struct FieldExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
886 syntax: SyntaxNodeRef<'a>, 761 syntax: SyntaxNode<R>,
887} 762}
763pub type FieldExpr<'a> = FieldExprNode<RefRoot<'a>>;
888 764
889impl<'a> AstNode<'a> for FieldExpr<'a> { 765impl<'a> AstNode<'a> for FieldExpr<'a> {
890 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 766 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -896,29 +772,24 @@ impl<'a> AstNode<'a> for FieldExpr<'a> {
896 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 772 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
897} 773}
898 774
899impl<'a> FieldExpr<'a> {} 775impl<R: TreeRoot<RaTypes>> FieldExprNode<R> {
900 776 pub fn borrowed(&self) -> FieldExpr {
901// FieldPatList 777 FieldExprNode { syntax: self.syntax.borrowed() }
902
903#[derive(Debug, Clone)]
904pub struct FieldPatListNode(SyntaxNode);
905
906impl FieldPatListNode {
907 pub fn ast(&self) -> FieldPatList {
908 FieldPatList::cast(self.0.borrowed()).unwrap()
909 } 778 }
910} 779 pub fn owned(&self) -> FieldExprNode {
911 780 FieldExprNode { syntax: self.syntax.owned() }
912impl<'a> From<FieldPatList<'a>> for FieldPatListNode {
913 fn from(ast: FieldPatList<'a>) -> FieldPatListNode {
914 let syntax = ast.syntax().owned();
915 FieldPatListNode(syntax)
916 } 781 }
917} 782}
783
784
785impl<'a> FieldExpr<'a> {}
786
787// FieldPatList
918#[derive(Debug, Clone, Copy)] 788#[derive(Debug, Clone, Copy)]
919pub struct FieldPatList<'a> { 789pub struct FieldPatListNode<R: TreeRoot<RaTypes> = OwnedRoot> {
920 syntax: SyntaxNodeRef<'a>, 790 syntax: SyntaxNode<R>,
921} 791}
792pub type FieldPatList<'a> = FieldPatListNode<RefRoot<'a>>;
922 793
923impl<'a> AstNode<'a> for FieldPatList<'a> { 794impl<'a> AstNode<'a> for FieldPatList<'a> {
924 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 795 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -930,29 +801,24 @@ impl<'a> AstNode<'a> for FieldPatList<'a> {
930 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 801 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
931} 802}
932 803
933impl<'a> FieldPatList<'a> {} 804impl<R: TreeRoot<RaTypes>> FieldPatListNode<R> {
934 805 pub fn borrowed(&self) -> FieldPatList {
935// FnDef 806 FieldPatListNode { syntax: self.syntax.borrowed() }
936
937#[derive(Debug, Clone)]
938pub struct FnDefNode(SyntaxNode);
939
940impl FnDefNode {
941 pub fn ast(&self) -> FnDef {
942 FnDef::cast(self.0.borrowed()).unwrap()
943 } 807 }
944} 808 pub fn owned(&self) -> FieldPatListNode {
945 809 FieldPatListNode { syntax: self.syntax.owned() }
946impl<'a> From<FnDef<'a>> for FnDefNode {
947 fn from(ast: FnDef<'a>) -> FnDefNode {
948 let syntax = ast.syntax().owned();
949 FnDefNode(syntax)
950 } 810 }
951} 811}
812
813
814impl<'a> FieldPatList<'a> {}
815
816// FnDef
952#[derive(Debug, Clone, Copy)] 817#[derive(Debug, Clone, Copy)]
953pub struct FnDef<'a> { 818pub struct FnDefNode<R: TreeRoot<RaTypes> = OwnedRoot> {
954 syntax: SyntaxNodeRef<'a>, 819 syntax: SyntaxNode<R>,
955} 820}
821pub type FnDef<'a> = FnDefNode<RefRoot<'a>>;
956 822
957impl<'a> AstNode<'a> for FnDef<'a> { 823impl<'a> AstNode<'a> for FnDef<'a> {
958 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 824 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -964,6 +830,16 @@ impl<'a> AstNode<'a> for FnDef<'a> {
964 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 830 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
965} 831}
966 832
833impl<R: TreeRoot<RaTypes>> FnDefNode<R> {
834 pub fn borrowed(&self) -> FnDef {
835 FnDefNode { syntax: self.syntax.borrowed() }
836 }
837 pub fn owned(&self) -> FnDefNode {
838 FnDefNode { syntax: self.syntax.owned() }
839 }
840}
841
842
967impl<'a> ast::NameOwner<'a> for FnDef<'a> {} 843impl<'a> ast::NameOwner<'a> for FnDef<'a> {}
968impl<'a> ast::TypeParamsOwner<'a> for FnDef<'a> {} 844impl<'a> ast::TypeParamsOwner<'a> for FnDef<'a> {}
969impl<'a> ast::AttrsOwner<'a> for FnDef<'a> {} 845impl<'a> ast::AttrsOwner<'a> for FnDef<'a> {}
@@ -983,26 +859,11 @@ impl<'a> FnDef<'a> {
983} 859}
984 860
985// FnPointerType 861// FnPointerType
986
987#[derive(Debug, Clone)]
988pub struct FnPointerTypeNode(SyntaxNode);
989
990impl FnPointerTypeNode {
991 pub fn ast(&self) -> FnPointerType {
992 FnPointerType::cast(self.0.borrowed()).unwrap()
993 }
994}
995
996impl<'a> From<FnPointerType<'a>> for FnPointerTypeNode {
997 fn from(ast: FnPointerType<'a>) -> FnPointerTypeNode {
998 let syntax = ast.syntax().owned();
999 FnPointerTypeNode(syntax)
1000 }
1001}
1002#[derive(Debug, Clone, Copy)] 862#[derive(Debug, Clone, Copy)]
1003pub struct FnPointerType<'a> { 863pub struct FnPointerTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1004 syntax: SyntaxNodeRef<'a>, 864 syntax: SyntaxNode<R>,
1005} 865}
866pub type FnPointerType<'a> = FnPointerTypeNode<RefRoot<'a>>;
1006 867
1007impl<'a> AstNode<'a> for FnPointerType<'a> { 868impl<'a> AstNode<'a> for FnPointerType<'a> {
1008 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 869 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1014,29 +875,24 @@ impl<'a> AstNode<'a> for FnPointerType<'a> {
1014 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 875 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1015} 876}
1016 877
1017impl<'a> FnPointerType<'a> {} 878impl<R: TreeRoot<RaTypes>> FnPointerTypeNode<R> {
1018 879 pub fn borrowed(&self) -> FnPointerType {
1019// ForExpr 880 FnPointerTypeNode { syntax: self.syntax.borrowed() }
1020
1021#[derive(Debug, Clone)]
1022pub struct ForExprNode(SyntaxNode);
1023
1024impl ForExprNode {
1025 pub fn ast(&self) -> ForExpr {
1026 ForExpr::cast(self.0.borrowed()).unwrap()
1027 } 881 }
1028} 882 pub fn owned(&self) -> FnPointerTypeNode {
1029 883 FnPointerTypeNode { syntax: self.syntax.owned() }
1030impl<'a> From<ForExpr<'a>> for ForExprNode {
1031 fn from(ast: ForExpr<'a>) -> ForExprNode {
1032 let syntax = ast.syntax().owned();
1033 ForExprNode(syntax)
1034 } 884 }
1035} 885}
886
887
888impl<'a> FnPointerType<'a> {}
889
890// ForExpr
1036#[derive(Debug, Clone, Copy)] 891#[derive(Debug, Clone, Copy)]
1037pub struct ForExpr<'a> { 892pub struct ForExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1038 syntax: SyntaxNodeRef<'a>, 893 syntax: SyntaxNode<R>,
1039} 894}
895pub type ForExpr<'a> = ForExprNode<RefRoot<'a>>;
1040 896
1041impl<'a> AstNode<'a> for ForExpr<'a> { 897impl<'a> AstNode<'a> for ForExpr<'a> {
1042 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 898 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1048,6 +904,16 @@ impl<'a> AstNode<'a> for ForExpr<'a> {
1048 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 904 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1049} 905}
1050 906
907impl<R: TreeRoot<RaTypes>> ForExprNode<R> {
908 pub fn borrowed(&self) -> ForExpr {
909 ForExprNode { syntax: self.syntax.borrowed() }
910 }
911 pub fn owned(&self) -> ForExprNode {
912 ForExprNode { syntax: self.syntax.owned() }
913 }
914}
915
916
1051impl<'a> ast::LoopBodyOwner<'a> for ForExpr<'a> {} 917impl<'a> ast::LoopBodyOwner<'a> for ForExpr<'a> {}
1052impl<'a> ForExpr<'a> { 918impl<'a> ForExpr<'a> {
1053 pub fn pat(self) -> Option<Pat<'a>> { 919 pub fn pat(self) -> Option<Pat<'a>> {
@@ -1060,26 +926,11 @@ impl<'a> ForExpr<'a> {
1060} 926}
1061 927
1062// ForType 928// ForType
1063
1064#[derive(Debug, Clone)]
1065pub struct ForTypeNode(SyntaxNode);
1066
1067impl ForTypeNode {
1068 pub fn ast(&self) -> ForType {
1069 ForType::cast(self.0.borrowed()).unwrap()
1070 }
1071}
1072
1073impl<'a> From<ForType<'a>> for ForTypeNode {
1074 fn from(ast: ForType<'a>) -> ForTypeNode {
1075 let syntax = ast.syntax().owned();
1076 ForTypeNode(syntax)
1077 }
1078}
1079#[derive(Debug, Clone, Copy)] 929#[derive(Debug, Clone, Copy)]
1080pub struct ForType<'a> { 930pub struct ForTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1081 syntax: SyntaxNodeRef<'a>, 931 syntax: SyntaxNode<R>,
1082} 932}
933pub type ForType<'a> = ForTypeNode<RefRoot<'a>>;
1083 934
1084impl<'a> AstNode<'a> for ForType<'a> { 935impl<'a> AstNode<'a> for ForType<'a> {
1085 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 936 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1091,29 +942,24 @@ impl<'a> AstNode<'a> for ForType<'a> {
1091 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 942 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1092} 943}
1093 944
1094impl<'a> ForType<'a> {} 945impl<R: TreeRoot<RaTypes>> ForTypeNode<R> {
1095 946 pub fn borrowed(&self) -> ForType {
1096// IfExpr 947 ForTypeNode { syntax: self.syntax.borrowed() }
1097
1098#[derive(Debug, Clone)]
1099pub struct IfExprNode(SyntaxNode);
1100
1101impl IfExprNode {
1102 pub fn ast(&self) -> IfExpr {
1103 IfExpr::cast(self.0.borrowed()).unwrap()
1104 } 948 }
1105} 949 pub fn owned(&self) -> ForTypeNode {
1106 950 ForTypeNode { syntax: self.syntax.owned() }
1107impl<'a> From<IfExpr<'a>> for IfExprNode {
1108 fn from(ast: IfExpr<'a>) -> IfExprNode {
1109 let syntax = ast.syntax().owned();
1110 IfExprNode(syntax)
1111 } 951 }
1112} 952}
953
954
955impl<'a> ForType<'a> {}
956
957// IfExpr
1113#[derive(Debug, Clone, Copy)] 958#[derive(Debug, Clone, Copy)]
1114pub struct IfExpr<'a> { 959pub struct IfExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1115 syntax: SyntaxNodeRef<'a>, 960 syntax: SyntaxNode<R>,
1116} 961}
962pub type IfExpr<'a> = IfExprNode<RefRoot<'a>>;
1117 963
1118impl<'a> AstNode<'a> for IfExpr<'a> { 964impl<'a> AstNode<'a> for IfExpr<'a> {
1119 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 965 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1125,33 +971,28 @@ impl<'a> AstNode<'a> for IfExpr<'a> {
1125 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 971 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1126} 972}
1127 973
1128impl<'a> IfExpr<'a> { 974impl<R: TreeRoot<RaTypes>> IfExprNode<R> {
1129 pub fn condition(self) -> Option<Condition<'a>> { 975 pub fn borrowed(&self) -> IfExpr {
1130 super::child_opt(self) 976 IfExprNode { syntax: self.syntax.borrowed() }
977 }
978 pub fn owned(&self) -> IfExprNode {
979 IfExprNode { syntax: self.syntax.owned() }
1131 } 980 }
1132} 981}
1133 982
1134// ImplItem
1135
1136#[derive(Debug, Clone)]
1137pub struct ImplItemNode(SyntaxNode);
1138 983
1139impl ImplItemNode { 984impl<'a> IfExpr<'a> {
1140 pub fn ast(&self) -> ImplItem { 985 pub fn condition(self) -> Option<Condition<'a>> {
1141 ImplItem::cast(self.0.borrowed()).unwrap() 986 super::child_opt(self)
1142 } 987 }
1143} 988}
1144 989
1145impl<'a> From<ImplItem<'a>> for ImplItemNode { 990// ImplItem
1146 fn from(ast: ImplItem<'a>) -> ImplItemNode {
1147 let syntax = ast.syntax().owned();
1148 ImplItemNode(syntax)
1149 }
1150}
1151#[derive(Debug, Clone, Copy)] 991#[derive(Debug, Clone, Copy)]
1152pub struct ImplItem<'a> { 992pub struct ImplItemNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1153 syntax: SyntaxNodeRef<'a>, 993 syntax: SyntaxNode<R>,
1154} 994}
995pub type ImplItem<'a> = ImplItemNode<RefRoot<'a>>;
1155 996
1156impl<'a> AstNode<'a> for ImplItem<'a> { 997impl<'a> AstNode<'a> for ImplItem<'a> {
1157 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 998 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1163,29 +1004,24 @@ impl<'a> AstNode<'a> for ImplItem<'a> {
1163 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1004 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1164} 1005}
1165 1006
1166impl<'a> ImplItem<'a> {} 1007impl<R: TreeRoot<RaTypes>> ImplItemNode<R> {
1167 1008 pub fn borrowed(&self) -> ImplItem {
1168// ImplTraitType 1009 ImplItemNode { syntax: self.syntax.borrowed() }
1169
1170#[derive(Debug, Clone)]
1171pub struct ImplTraitTypeNode(SyntaxNode);
1172
1173impl ImplTraitTypeNode {
1174 pub fn ast(&self) -> ImplTraitType {
1175 ImplTraitType::cast(self.0.borrowed()).unwrap()
1176 } 1010 }
1177} 1011 pub fn owned(&self) -> ImplItemNode {
1178 1012 ImplItemNode { syntax: self.syntax.owned() }
1179impl<'a> From<ImplTraitType<'a>> for ImplTraitTypeNode {
1180 fn from(ast: ImplTraitType<'a>) -> ImplTraitTypeNode {
1181 let syntax = ast.syntax().owned();
1182 ImplTraitTypeNode(syntax)
1183 } 1013 }
1184} 1014}
1015
1016
1017impl<'a> ImplItem<'a> {}
1018
1019// ImplTraitType
1185#[derive(Debug, Clone, Copy)] 1020#[derive(Debug, Clone, Copy)]
1186pub struct ImplTraitType<'a> { 1021pub struct ImplTraitTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1187 syntax: SyntaxNodeRef<'a>, 1022 syntax: SyntaxNode<R>,
1188} 1023}
1024pub type ImplTraitType<'a> = ImplTraitTypeNode<RefRoot<'a>>;
1189 1025
1190impl<'a> AstNode<'a> for ImplTraitType<'a> { 1026impl<'a> AstNode<'a> for ImplTraitType<'a> {
1191 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1027 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1197,29 +1033,24 @@ impl<'a> AstNode<'a> for ImplTraitType<'a> {
1197 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1033 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1198} 1034}
1199 1035
1200impl<'a> ImplTraitType<'a> {} 1036impl<R: TreeRoot<RaTypes>> ImplTraitTypeNode<R> {
1201 1037 pub fn borrowed(&self) -> ImplTraitType {
1202// IndexExpr 1038 ImplTraitTypeNode { syntax: self.syntax.borrowed() }
1203
1204#[derive(Debug, Clone)]
1205pub struct IndexExprNode(SyntaxNode);
1206
1207impl IndexExprNode {
1208 pub fn ast(&self) -> IndexExpr {
1209 IndexExpr::cast(self.0.borrowed()).unwrap()
1210 } 1039 }
1211} 1040 pub fn owned(&self) -> ImplTraitTypeNode {
1212 1041 ImplTraitTypeNode { syntax: self.syntax.owned() }
1213impl<'a> From<IndexExpr<'a>> for IndexExprNode {
1214 fn from(ast: IndexExpr<'a>) -> IndexExprNode {
1215 let syntax = ast.syntax().owned();
1216 IndexExprNode(syntax)
1217 } 1042 }
1218} 1043}
1044
1045
1046impl<'a> ImplTraitType<'a> {}
1047
1048// IndexExpr
1219#[derive(Debug, Clone, Copy)] 1049#[derive(Debug, Clone, Copy)]
1220pub struct IndexExpr<'a> { 1050pub struct IndexExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1221 syntax: SyntaxNodeRef<'a>, 1051 syntax: SyntaxNode<R>,
1222} 1052}
1053pub type IndexExpr<'a> = IndexExprNode<RefRoot<'a>>;
1223 1054
1224impl<'a> AstNode<'a> for IndexExpr<'a> { 1055impl<'a> AstNode<'a> for IndexExpr<'a> {
1225 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1056 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1231,29 +1062,24 @@ impl<'a> AstNode<'a> for IndexExpr<'a> {
1231 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1062 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1232} 1063}
1233 1064
1234impl<'a> IndexExpr<'a> {} 1065impl<R: TreeRoot<RaTypes>> IndexExprNode<R> {
1235 1066 pub fn borrowed(&self) -> IndexExpr {
1236// ItemList 1067 IndexExprNode { syntax: self.syntax.borrowed() }
1237
1238#[derive(Debug, Clone)]
1239pub struct ItemListNode(SyntaxNode);
1240
1241impl ItemListNode {
1242 pub fn ast(&self) -> ItemList {
1243 ItemList::cast(self.0.borrowed()).unwrap()
1244 } 1068 }
1245} 1069 pub fn owned(&self) -> IndexExprNode {
1246 1070 IndexExprNode { syntax: self.syntax.owned() }
1247impl<'a> From<ItemList<'a>> for ItemListNode {
1248 fn from(ast: ItemList<'a>) -> ItemListNode {
1249 let syntax = ast.syntax().owned();
1250 ItemListNode(syntax)
1251 } 1071 }
1252} 1072}
1073
1074
1075impl<'a> IndexExpr<'a> {}
1076
1077// ItemList
1253#[derive(Debug, Clone, Copy)] 1078#[derive(Debug, Clone, Copy)]
1254pub struct ItemList<'a> { 1079pub struct ItemListNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1255 syntax: SyntaxNodeRef<'a>, 1080 syntax: SyntaxNode<R>,
1256} 1081}
1082pub type ItemList<'a> = ItemListNode<RefRoot<'a>>;
1257 1083
1258impl<'a> AstNode<'a> for ItemList<'a> { 1084impl<'a> AstNode<'a> for ItemList<'a> {
1259 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1085 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1265,31 +1091,26 @@ impl<'a> AstNode<'a> for ItemList<'a> {
1265 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1091 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1266} 1092}
1267 1093
1094impl<R: TreeRoot<RaTypes>> ItemListNode<R> {
1095 pub fn borrowed(&self) -> ItemList {
1096 ItemListNode { syntax: self.syntax.borrowed() }
1097 }
1098 pub fn owned(&self) -> ItemListNode {
1099 ItemListNode { syntax: self.syntax.owned() }
1100 }
1101}
1102
1103
1268impl<'a> ast::FnDefOwner<'a> for ItemList<'a> {} 1104impl<'a> ast::FnDefOwner<'a> for ItemList<'a> {}
1269impl<'a> ast::ModuleItemOwner<'a> for ItemList<'a> {} 1105impl<'a> ast::ModuleItemOwner<'a> for ItemList<'a> {}
1270impl<'a> ItemList<'a> {} 1106impl<'a> ItemList<'a> {}
1271 1107
1272// Label 1108// Label
1273
1274#[derive(Debug, Clone)]
1275pub struct LabelNode(SyntaxNode);
1276
1277impl LabelNode {
1278 pub fn ast(&self) -> Label {
1279 Label::cast(self.0.borrowed()).unwrap()
1280 }
1281}
1282
1283impl<'a> From<Label<'a>> for LabelNode {
1284 fn from(ast: Label<'a>) -> LabelNode {
1285 let syntax = ast.syntax().owned();
1286 LabelNode(syntax)
1287 }
1288}
1289#[derive(Debug, Clone, Copy)] 1109#[derive(Debug, Clone, Copy)]
1290pub struct Label<'a> { 1110pub struct LabelNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1291 syntax: SyntaxNodeRef<'a>, 1111 syntax: SyntaxNode<R>,
1292} 1112}
1113pub type Label<'a> = LabelNode<RefRoot<'a>>;
1293 1114
1294impl<'a> AstNode<'a> for Label<'a> { 1115impl<'a> AstNode<'a> for Label<'a> {
1295 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1116 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1301,29 +1122,24 @@ impl<'a> AstNode<'a> for Label<'a> {
1301 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1122 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1302} 1123}
1303 1124
1304impl<'a> Label<'a> {} 1125impl<R: TreeRoot<RaTypes>> LabelNode<R> {
1305 1126 pub fn borrowed(&self) -> Label {
1306// LambdaExpr 1127 LabelNode { syntax: self.syntax.borrowed() }
1307
1308#[derive(Debug, Clone)]
1309pub struct LambdaExprNode(SyntaxNode);
1310
1311impl LambdaExprNode {
1312 pub fn ast(&self) -> LambdaExpr {
1313 LambdaExpr::cast(self.0.borrowed()).unwrap()
1314 } 1128 }
1315} 1129 pub fn owned(&self) -> LabelNode {
1316 1130 LabelNode { syntax: self.syntax.owned() }
1317impl<'a> From<LambdaExpr<'a>> for LambdaExprNode {
1318 fn from(ast: LambdaExpr<'a>) -> LambdaExprNode {
1319 let syntax = ast.syntax().owned();
1320 LambdaExprNode(syntax)
1321 } 1131 }
1322} 1132}
1133
1134
1135impl<'a> Label<'a> {}
1136
1137// LambdaExpr
1323#[derive(Debug, Clone, Copy)] 1138#[derive(Debug, Clone, Copy)]
1324pub struct LambdaExpr<'a> { 1139pub struct LambdaExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1325 syntax: SyntaxNodeRef<'a>, 1140 syntax: SyntaxNode<R>,
1326} 1141}
1142pub type LambdaExpr<'a> = LambdaExprNode<RefRoot<'a>>;
1327 1143
1328impl<'a> AstNode<'a> for LambdaExpr<'a> { 1144impl<'a> AstNode<'a> for LambdaExpr<'a> {
1329 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1145 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1335,6 +1151,16 @@ impl<'a> AstNode<'a> for LambdaExpr<'a> {
1335 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1151 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1336} 1152}
1337 1153
1154impl<R: TreeRoot<RaTypes>> LambdaExprNode<R> {
1155 pub fn borrowed(&self) -> LambdaExpr {
1156 LambdaExprNode { syntax: self.syntax.borrowed() }
1157 }
1158 pub fn owned(&self) -> LambdaExprNode {
1159 LambdaExprNode { syntax: self.syntax.owned() }
1160 }
1161}
1162
1163
1338impl<'a> LambdaExpr<'a> { 1164impl<'a> LambdaExpr<'a> {
1339 pub fn param_list(self) -> Option<ParamList<'a>> { 1165 pub fn param_list(self) -> Option<ParamList<'a>> {
1340 super::child_opt(self) 1166 super::child_opt(self)
@@ -1346,26 +1172,11 @@ impl<'a> LambdaExpr<'a> {
1346} 1172}
1347 1173
1348// LetStmt 1174// LetStmt
1349
1350#[derive(Debug, Clone)]
1351pub struct LetStmtNode(SyntaxNode);
1352
1353impl LetStmtNode {
1354 pub fn ast(&self) -> LetStmt {
1355 LetStmt::cast(self.0.borrowed()).unwrap()
1356 }
1357}
1358
1359impl<'a> From<LetStmt<'a>> for LetStmtNode {
1360 fn from(ast: LetStmt<'a>) -> LetStmtNode {
1361 let syntax = ast.syntax().owned();
1362 LetStmtNode(syntax)
1363 }
1364}
1365#[derive(Debug, Clone, Copy)] 1175#[derive(Debug, Clone, Copy)]
1366pub struct LetStmt<'a> { 1176pub struct LetStmtNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1367 syntax: SyntaxNodeRef<'a>, 1177 syntax: SyntaxNode<R>,
1368} 1178}
1179pub type LetStmt<'a> = LetStmtNode<RefRoot<'a>>;
1369 1180
1370impl<'a> AstNode<'a> for LetStmt<'a> { 1181impl<'a> AstNode<'a> for LetStmt<'a> {
1371 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1182 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1377,6 +1188,16 @@ impl<'a> AstNode<'a> for LetStmt<'a> {
1377 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1188 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1378} 1189}
1379 1190
1191impl<R: TreeRoot<RaTypes>> LetStmtNode<R> {
1192 pub fn borrowed(&self) -> LetStmt {
1193 LetStmtNode { syntax: self.syntax.borrowed() }
1194 }
1195 pub fn owned(&self) -> LetStmtNode {
1196 LetStmtNode { syntax: self.syntax.owned() }
1197 }
1198}
1199
1200
1380impl<'a> LetStmt<'a> { 1201impl<'a> LetStmt<'a> {
1381 pub fn pat(self) -> Option<Pat<'a>> { 1202 pub fn pat(self) -> Option<Pat<'a>> {
1382 super::child_opt(self) 1203 super::child_opt(self)
@@ -1388,26 +1209,11 @@ impl<'a> LetStmt<'a> {
1388} 1209}
1389 1210
1390// Lifetime 1211// Lifetime
1391
1392#[derive(Debug, Clone)]
1393pub struct LifetimeNode(SyntaxNode);
1394
1395impl LifetimeNode {
1396 pub fn ast(&self) -> Lifetime {
1397 Lifetime::cast(self.0.borrowed()).unwrap()
1398 }
1399}
1400
1401impl<'a> From<Lifetime<'a>> for LifetimeNode {
1402 fn from(ast: Lifetime<'a>) -> LifetimeNode {
1403 let syntax = ast.syntax().owned();
1404 LifetimeNode(syntax)
1405 }
1406}
1407#[derive(Debug, Clone, Copy)] 1212#[derive(Debug, Clone, Copy)]
1408pub struct Lifetime<'a> { 1213pub struct LifetimeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1409 syntax: SyntaxNodeRef<'a>, 1214 syntax: SyntaxNode<R>,
1410} 1215}
1216pub type Lifetime<'a> = LifetimeNode<RefRoot<'a>>;
1411 1217
1412impl<'a> AstNode<'a> for Lifetime<'a> { 1218impl<'a> AstNode<'a> for Lifetime<'a> {
1413 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1219 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1419,29 +1225,24 @@ impl<'a> AstNode<'a> for Lifetime<'a> {
1419 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1225 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1420} 1226}
1421 1227
1422impl<'a> Lifetime<'a> {} 1228impl<R: TreeRoot<RaTypes>> LifetimeNode<R> {
1423 1229 pub fn borrowed(&self) -> Lifetime {
1424// LifetimeParam 1230 LifetimeNode { syntax: self.syntax.borrowed() }
1425
1426#[derive(Debug, Clone)]
1427pub struct LifetimeParamNode(SyntaxNode);
1428
1429impl LifetimeParamNode {
1430 pub fn ast(&self) -> LifetimeParam {
1431 LifetimeParam::cast(self.0.borrowed()).unwrap()
1432 } 1231 }
1433} 1232 pub fn owned(&self) -> LifetimeNode {
1434 1233 LifetimeNode { syntax: self.syntax.owned() }
1435impl<'a> From<LifetimeParam<'a>> for LifetimeParamNode {
1436 fn from(ast: LifetimeParam<'a>) -> LifetimeParamNode {
1437 let syntax = ast.syntax().owned();
1438 LifetimeParamNode(syntax)
1439 } 1234 }
1440} 1235}
1236
1237
1238impl<'a> Lifetime<'a> {}
1239
1240// LifetimeParam
1441#[derive(Debug, Clone, Copy)] 1241#[derive(Debug, Clone, Copy)]
1442pub struct LifetimeParam<'a> { 1242pub struct LifetimeParamNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1443 syntax: SyntaxNodeRef<'a>, 1243 syntax: SyntaxNode<R>,
1444} 1244}
1245pub type LifetimeParam<'a> = LifetimeParamNode<RefRoot<'a>>;
1445 1246
1446impl<'a> AstNode<'a> for LifetimeParam<'a> { 1247impl<'a> AstNode<'a> for LifetimeParam<'a> {
1447 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1248 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1453,33 +1254,28 @@ impl<'a> AstNode<'a> for LifetimeParam<'a> {
1453 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1254 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1454} 1255}
1455 1256
1456impl<'a> LifetimeParam<'a> { 1257impl<R: TreeRoot<RaTypes>> LifetimeParamNode<R> {
1457 pub fn lifetime(self) -> Option<Lifetime<'a>> { 1258 pub fn borrowed(&self) -> LifetimeParam {
1458 super::child_opt(self) 1259 LifetimeParamNode { syntax: self.syntax.borrowed() }
1260 }
1261 pub fn owned(&self) -> LifetimeParamNode {
1262 LifetimeParamNode { syntax: self.syntax.owned() }
1459 } 1263 }
1460} 1264}
1461 1265
1462// Literal
1463 1266
1464#[derive(Debug, Clone)] 1267impl<'a> LifetimeParam<'a> {
1465pub struct LiteralNode(SyntaxNode); 1268 pub fn lifetime(self) -> Option<Lifetime<'a>> {
1466 1269 super::child_opt(self)
1467impl LiteralNode {
1468 pub fn ast(&self) -> Literal {
1469 Literal::cast(self.0.borrowed()).unwrap()
1470 } 1270 }
1471} 1271}
1472 1272
1473impl<'a> From<Literal<'a>> for LiteralNode { 1273// Literal
1474 fn from(ast: Literal<'a>) -> LiteralNode {
1475 let syntax = ast.syntax().owned();
1476 LiteralNode(syntax)
1477 }
1478}
1479#[derive(Debug, Clone, Copy)] 1274#[derive(Debug, Clone, Copy)]
1480pub struct Literal<'a> { 1275pub struct LiteralNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1481 syntax: SyntaxNodeRef<'a>, 1276 syntax: SyntaxNode<R>,
1482} 1277}
1278pub type Literal<'a> = LiteralNode<RefRoot<'a>>;
1483 1279
1484impl<'a> AstNode<'a> for Literal<'a> { 1280impl<'a> AstNode<'a> for Literal<'a> {
1485 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1281 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1491,29 +1287,24 @@ impl<'a> AstNode<'a> for Literal<'a> {
1491 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1287 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1492} 1288}
1493 1289
1494impl<'a> Literal<'a> {} 1290impl<R: TreeRoot<RaTypes>> LiteralNode<R> {
1495 1291 pub fn borrowed(&self) -> Literal {
1496// LoopExpr 1292 LiteralNode { syntax: self.syntax.borrowed() }
1497
1498#[derive(Debug, Clone)]
1499pub struct LoopExprNode(SyntaxNode);
1500
1501impl LoopExprNode {
1502 pub fn ast(&self) -> LoopExpr {
1503 LoopExpr::cast(self.0.borrowed()).unwrap()
1504 } 1293 }
1505} 1294 pub fn owned(&self) -> LiteralNode {
1506 1295 LiteralNode { syntax: self.syntax.owned() }
1507impl<'a> From<LoopExpr<'a>> for LoopExprNode {
1508 fn from(ast: LoopExpr<'a>) -> LoopExprNode {
1509 let syntax = ast.syntax().owned();
1510 LoopExprNode(syntax)
1511 } 1296 }
1512} 1297}
1298
1299
1300impl<'a> Literal<'a> {}
1301
1302// LoopExpr
1513#[derive(Debug, Clone, Copy)] 1303#[derive(Debug, Clone, Copy)]
1514pub struct LoopExpr<'a> { 1304pub struct LoopExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1515 syntax: SyntaxNodeRef<'a>, 1305 syntax: SyntaxNode<R>,
1516} 1306}
1307pub type LoopExpr<'a> = LoopExprNode<RefRoot<'a>>;
1517 1308
1518impl<'a> AstNode<'a> for LoopExpr<'a> { 1309impl<'a> AstNode<'a> for LoopExpr<'a> {
1519 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1310 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1525,30 +1316,25 @@ impl<'a> AstNode<'a> for LoopExpr<'a> {
1525 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1316 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1526} 1317}
1527 1318
1319impl<R: TreeRoot<RaTypes>> LoopExprNode<R> {
1320 pub fn borrowed(&self) -> LoopExpr {
1321 LoopExprNode { syntax: self.syntax.borrowed() }
1322 }
1323 pub fn owned(&self) -> LoopExprNode {
1324 LoopExprNode { syntax: self.syntax.owned() }
1325 }
1326}
1327
1328
1528impl<'a> ast::LoopBodyOwner<'a> for LoopExpr<'a> {} 1329impl<'a> ast::LoopBodyOwner<'a> for LoopExpr<'a> {}
1529impl<'a> LoopExpr<'a> {} 1330impl<'a> LoopExpr<'a> {}
1530 1331
1531// MatchArm 1332// MatchArm
1532
1533#[derive(Debug, Clone)]
1534pub struct MatchArmNode(SyntaxNode);
1535
1536impl MatchArmNode {
1537 pub fn ast(&self) -> MatchArm {
1538 MatchArm::cast(self.0.borrowed()).unwrap()
1539 }
1540}
1541
1542impl<'a> From<MatchArm<'a>> for MatchArmNode {
1543 fn from(ast: MatchArm<'a>) -> MatchArmNode {
1544 let syntax = ast.syntax().owned();
1545 MatchArmNode(syntax)
1546 }
1547}
1548#[derive(Debug, Clone, Copy)] 1333#[derive(Debug, Clone, Copy)]
1549pub struct MatchArm<'a> { 1334pub struct MatchArmNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1550 syntax: SyntaxNodeRef<'a>, 1335 syntax: SyntaxNode<R>,
1551} 1336}
1337pub type MatchArm<'a> = MatchArmNode<RefRoot<'a>>;
1552 1338
1553impl<'a> AstNode<'a> for MatchArm<'a> { 1339impl<'a> AstNode<'a> for MatchArm<'a> {
1554 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1340 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1560,6 +1346,16 @@ impl<'a> AstNode<'a> for MatchArm<'a> {
1560 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1346 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1561} 1347}
1562 1348
1349impl<R: TreeRoot<RaTypes>> MatchArmNode<R> {
1350 pub fn borrowed(&self) -> MatchArm {
1351 MatchArmNode { syntax: self.syntax.borrowed() }
1352 }
1353 pub fn owned(&self) -> MatchArmNode {
1354 MatchArmNode { syntax: self.syntax.owned() }
1355 }
1356}
1357
1358
1563impl<'a> MatchArm<'a> { 1359impl<'a> MatchArm<'a> {
1564 pub fn pats(self) -> impl Iterator<Item = Pat<'a>> + 'a { 1360 pub fn pats(self) -> impl Iterator<Item = Pat<'a>> + 'a {
1565 super::children(self) 1361 super::children(self)
@@ -1575,26 +1371,11 @@ impl<'a> MatchArm<'a> {
1575} 1371}
1576 1372
1577// MatchArmList 1373// MatchArmList
1578
1579#[derive(Debug, Clone)]
1580pub struct MatchArmListNode(SyntaxNode);
1581
1582impl MatchArmListNode {
1583 pub fn ast(&self) -> MatchArmList {
1584 MatchArmList::cast(self.0.borrowed()).unwrap()
1585 }
1586}
1587
1588impl<'a> From<MatchArmList<'a>> for MatchArmListNode {
1589 fn from(ast: MatchArmList<'a>) -> MatchArmListNode {
1590 let syntax = ast.syntax().owned();
1591 MatchArmListNode(syntax)
1592 }
1593}
1594#[derive(Debug, Clone, Copy)] 1374#[derive(Debug, Clone, Copy)]
1595pub struct MatchArmList<'a> { 1375pub struct MatchArmListNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1596 syntax: SyntaxNodeRef<'a>, 1376 syntax: SyntaxNode<R>,
1597} 1377}
1378pub type MatchArmList<'a> = MatchArmListNode<RefRoot<'a>>;
1598 1379
1599impl<'a> AstNode<'a> for MatchArmList<'a> { 1380impl<'a> AstNode<'a> for MatchArmList<'a> {
1600 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1381 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1606,33 +1387,28 @@ impl<'a> AstNode<'a> for MatchArmList<'a> {
1606 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1387 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1607} 1388}
1608 1389
1609impl<'a> MatchArmList<'a> { 1390impl<R: TreeRoot<RaTypes>> MatchArmListNode<R> {
1610 pub fn arms(self) -> impl Iterator<Item = MatchArm<'a>> + 'a { 1391 pub fn borrowed(&self) -> MatchArmList {
1611 super::children(self) 1392 MatchArmListNode { syntax: self.syntax.borrowed() }
1393 }
1394 pub fn owned(&self) -> MatchArmListNode {
1395 MatchArmListNode { syntax: self.syntax.owned() }
1612 } 1396 }
1613} 1397}
1614 1398
1615// MatchExpr
1616
1617#[derive(Debug, Clone)]
1618pub struct MatchExprNode(SyntaxNode);
1619 1399
1620impl MatchExprNode { 1400impl<'a> MatchArmList<'a> {
1621 pub fn ast(&self) -> MatchExpr { 1401 pub fn arms(self) -> impl Iterator<Item = MatchArm<'a>> + 'a {
1622 MatchExpr::cast(self.0.borrowed()).unwrap() 1402 super::children(self)
1623 } 1403 }
1624} 1404}
1625 1405
1626impl<'a> From<MatchExpr<'a>> for MatchExprNode { 1406// MatchExpr
1627 fn from(ast: MatchExpr<'a>) -> MatchExprNode {
1628 let syntax = ast.syntax().owned();
1629 MatchExprNode(syntax)
1630 }
1631}
1632#[derive(Debug, Clone, Copy)] 1407#[derive(Debug, Clone, Copy)]
1633pub struct MatchExpr<'a> { 1408pub struct MatchExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1634 syntax: SyntaxNodeRef<'a>, 1409 syntax: SyntaxNode<R>,
1635} 1410}
1411pub type MatchExpr<'a> = MatchExprNode<RefRoot<'a>>;
1636 1412
1637impl<'a> AstNode<'a> for MatchExpr<'a> { 1413impl<'a> AstNode<'a> for MatchExpr<'a> {
1638 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1414 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1644,6 +1420,16 @@ impl<'a> AstNode<'a> for MatchExpr<'a> {
1644 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1420 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1645} 1421}
1646 1422
1423impl<R: TreeRoot<RaTypes>> MatchExprNode<R> {
1424 pub fn borrowed(&self) -> MatchExpr {
1425 MatchExprNode { syntax: self.syntax.borrowed() }
1426 }
1427 pub fn owned(&self) -> MatchExprNode {
1428 MatchExprNode { syntax: self.syntax.owned() }
1429 }
1430}
1431
1432
1647impl<'a> MatchExpr<'a> { 1433impl<'a> MatchExpr<'a> {
1648 pub fn expr(self) -> Option<Expr<'a>> { 1434 pub fn expr(self) -> Option<Expr<'a>> {
1649 super::child_opt(self) 1435 super::child_opt(self)
@@ -1655,26 +1441,11 @@ impl<'a> MatchExpr<'a> {
1655} 1441}
1656 1442
1657// MatchGuard 1443// MatchGuard
1658
1659#[derive(Debug, Clone)]
1660pub struct MatchGuardNode(SyntaxNode);
1661
1662impl MatchGuardNode {
1663 pub fn ast(&self) -> MatchGuard {
1664 MatchGuard::cast(self.0.borrowed()).unwrap()
1665 }
1666}
1667
1668impl<'a> From<MatchGuard<'a>> for MatchGuardNode {
1669 fn from(ast: MatchGuard<'a>) -> MatchGuardNode {
1670 let syntax = ast.syntax().owned();
1671 MatchGuardNode(syntax)
1672 }
1673}
1674#[derive(Debug, Clone, Copy)] 1444#[derive(Debug, Clone, Copy)]
1675pub struct MatchGuard<'a> { 1445pub struct MatchGuardNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1676 syntax: SyntaxNodeRef<'a>, 1446 syntax: SyntaxNode<R>,
1677} 1447}
1448pub type MatchGuard<'a> = MatchGuardNode<RefRoot<'a>>;
1678 1449
1679impl<'a> AstNode<'a> for MatchGuard<'a> { 1450impl<'a> AstNode<'a> for MatchGuard<'a> {
1680 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1451 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1686,29 +1457,24 @@ impl<'a> AstNode<'a> for MatchGuard<'a> {
1686 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1457 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1687} 1458}
1688 1459
1689impl<'a> MatchGuard<'a> {} 1460impl<R: TreeRoot<RaTypes>> MatchGuardNode<R> {
1690 1461 pub fn borrowed(&self) -> MatchGuard {
1691// MethodCallExpr 1462 MatchGuardNode { syntax: self.syntax.borrowed() }
1692
1693#[derive(Debug, Clone)]
1694pub struct MethodCallExprNode(SyntaxNode);
1695
1696impl MethodCallExprNode {
1697 pub fn ast(&self) -> MethodCallExpr {
1698 MethodCallExpr::cast(self.0.borrowed()).unwrap()
1699 } 1463 }
1700} 1464 pub fn owned(&self) -> MatchGuardNode {
1701 1465 MatchGuardNode { syntax: self.syntax.owned() }
1702impl<'a> From<MethodCallExpr<'a>> for MethodCallExprNode {
1703 fn from(ast: MethodCallExpr<'a>) -> MethodCallExprNode {
1704 let syntax = ast.syntax().owned();
1705 MethodCallExprNode(syntax)
1706 } 1466 }
1707} 1467}
1468
1469
1470impl<'a> MatchGuard<'a> {}
1471
1472// MethodCallExpr
1708#[derive(Debug, Clone, Copy)] 1473#[derive(Debug, Clone, Copy)]
1709pub struct MethodCallExpr<'a> { 1474pub struct MethodCallExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1710 syntax: SyntaxNodeRef<'a>, 1475 syntax: SyntaxNode<R>,
1711} 1476}
1477pub type MethodCallExpr<'a> = MethodCallExprNode<RefRoot<'a>>;
1712 1478
1713impl<'a> AstNode<'a> for MethodCallExpr<'a> { 1479impl<'a> AstNode<'a> for MethodCallExpr<'a> {
1714 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1480 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1720,6 +1486,16 @@ impl<'a> AstNode<'a> for MethodCallExpr<'a> {
1720 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1486 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1721} 1487}
1722 1488
1489impl<R: TreeRoot<RaTypes>> MethodCallExprNode<R> {
1490 pub fn borrowed(&self) -> MethodCallExpr {
1491 MethodCallExprNode { syntax: self.syntax.borrowed() }
1492 }
1493 pub fn owned(&self) -> MethodCallExprNode {
1494 MethodCallExprNode { syntax: self.syntax.owned() }
1495 }
1496}
1497
1498
1723impl<'a> ast::ArgListOwner<'a> for MethodCallExpr<'a> {} 1499impl<'a> ast::ArgListOwner<'a> for MethodCallExpr<'a> {}
1724impl<'a> MethodCallExpr<'a> { 1500impl<'a> MethodCallExpr<'a> {
1725 pub fn expr(self) -> Option<Expr<'a>> { 1501 pub fn expr(self) -> Option<Expr<'a>> {
@@ -1728,26 +1504,11 @@ impl<'a> MethodCallExpr<'a> {
1728} 1504}
1729 1505
1730// Module 1506// Module
1731
1732#[derive(Debug, Clone)]
1733pub struct ModuleNode(SyntaxNode);
1734
1735impl ModuleNode {
1736 pub fn ast(&self) -> Module {
1737 Module::cast(self.0.borrowed()).unwrap()
1738 }
1739}
1740
1741impl<'a> From<Module<'a>> for ModuleNode {
1742 fn from(ast: Module<'a>) -> ModuleNode {
1743 let syntax = ast.syntax().owned();
1744 ModuleNode(syntax)
1745 }
1746}
1747#[derive(Debug, Clone, Copy)] 1507#[derive(Debug, Clone, Copy)]
1748pub struct Module<'a> { 1508pub struct ModuleNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1749 syntax: SyntaxNodeRef<'a>, 1509 syntax: SyntaxNode<R>,
1750} 1510}
1511pub type Module<'a> = ModuleNode<RefRoot<'a>>;
1751 1512
1752impl<'a> AstNode<'a> for Module<'a> { 1513impl<'a> AstNode<'a> for Module<'a> {
1753 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1514 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1759,6 +1520,16 @@ impl<'a> AstNode<'a> for Module<'a> {
1759 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1520 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1760} 1521}
1761 1522
1523impl<R: TreeRoot<RaTypes>> ModuleNode<R> {
1524 pub fn borrowed(&self) -> Module {
1525 ModuleNode { syntax: self.syntax.borrowed() }
1526 }
1527 pub fn owned(&self) -> ModuleNode {
1528 ModuleNode { syntax: self.syntax.owned() }
1529 }
1530}
1531
1532
1762impl<'a> ast::NameOwner<'a> for Module<'a> {} 1533impl<'a> ast::NameOwner<'a> for Module<'a> {}
1763impl<'a> ast::AttrsOwner<'a> for Module<'a> {} 1534impl<'a> ast::AttrsOwner<'a> for Module<'a> {}
1764impl<'a> Module<'a> { 1535impl<'a> Module<'a> {
@@ -1768,22 +1539,6 @@ impl<'a> Module<'a> {
1768} 1539}
1769 1540
1770// ModuleItem 1541// ModuleItem
1771
1772#[derive(Debug, Clone)]
1773pub struct ModuleItemNode(SyntaxNode);
1774
1775impl ModuleItemNode {
1776 pub fn ast(&self) -> ModuleItem {
1777 ModuleItem::cast(self.0.borrowed()).unwrap()
1778 }
1779}
1780
1781impl<'a> From<ModuleItem<'a>> for ModuleItemNode {
1782 fn from(ast: ModuleItem<'a>) -> ModuleItemNode {
1783 let syntax = ast.syntax().owned();
1784 ModuleItemNode(syntax)
1785 }
1786}
1787#[derive(Debug, Clone, Copy)] 1542#[derive(Debug, Clone, Copy)]
1788pub enum ModuleItem<'a> { 1543pub enum ModuleItem<'a> {
1789 StructDef(StructDef<'a>), 1544 StructDef(StructDef<'a>),
@@ -1836,26 +1591,11 @@ impl<'a> AstNode<'a> for ModuleItem<'a> {
1836impl<'a> ModuleItem<'a> {} 1591impl<'a> ModuleItem<'a> {}
1837 1592
1838// Name 1593// Name
1839
1840#[derive(Debug, Clone)]
1841pub struct NameNode(SyntaxNode);
1842
1843impl NameNode {
1844 pub fn ast(&self) -> Name {
1845 Name::cast(self.0.borrowed()).unwrap()
1846 }
1847}
1848
1849impl<'a> From<Name<'a>> for NameNode {
1850 fn from(ast: Name<'a>) -> NameNode {
1851 let syntax = ast.syntax().owned();
1852 NameNode(syntax)
1853 }
1854}
1855#[derive(Debug, Clone, Copy)] 1594#[derive(Debug, Clone, Copy)]
1856pub struct Name<'a> { 1595pub struct NameNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1857 syntax: SyntaxNodeRef<'a>, 1596 syntax: SyntaxNode<R>,
1858} 1597}
1598pub type Name<'a> = NameNode<RefRoot<'a>>;
1859 1599
1860impl<'a> AstNode<'a> for Name<'a> { 1600impl<'a> AstNode<'a> for Name<'a> {
1861 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1601 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1867,29 +1607,24 @@ impl<'a> AstNode<'a> for Name<'a> {
1867 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1607 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1868} 1608}
1869 1609
1870impl<'a> Name<'a> {} 1610impl<R: TreeRoot<RaTypes>> NameNode<R> {
1871 1611 pub fn borrowed(&self) -> Name {
1872// NameRef 1612 NameNode { syntax: self.syntax.borrowed() }
1873
1874#[derive(Debug, Clone)]
1875pub struct NameRefNode(SyntaxNode);
1876
1877impl NameRefNode {
1878 pub fn ast(&self) -> NameRef {
1879 NameRef::cast(self.0.borrowed()).unwrap()
1880 } 1613 }
1881} 1614 pub fn owned(&self) -> NameNode {
1882 1615 NameNode { syntax: self.syntax.owned() }
1883impl<'a> From<NameRef<'a>> for NameRefNode {
1884 fn from(ast: NameRef<'a>) -> NameRefNode {
1885 let syntax = ast.syntax().owned();
1886 NameRefNode(syntax)
1887 } 1616 }
1888} 1617}
1618
1619
1620impl<'a> Name<'a> {}
1621
1622// NameRef
1889#[derive(Debug, Clone, Copy)] 1623#[derive(Debug, Clone, Copy)]
1890pub struct NameRef<'a> { 1624pub struct NameRefNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1891 syntax: SyntaxNodeRef<'a>, 1625 syntax: SyntaxNode<R>,
1892} 1626}
1627pub type NameRef<'a> = NameRefNode<RefRoot<'a>>;
1893 1628
1894impl<'a> AstNode<'a> for NameRef<'a> { 1629impl<'a> AstNode<'a> for NameRef<'a> {
1895 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1630 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1901,29 +1636,24 @@ impl<'a> AstNode<'a> for NameRef<'a> {
1901 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1636 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1902} 1637}
1903 1638
1904impl<'a> NameRef<'a> {} 1639impl<R: TreeRoot<RaTypes>> NameRefNode<R> {
1905 1640 pub fn borrowed(&self) -> NameRef {
1906// NamedField 1641 NameRefNode { syntax: self.syntax.borrowed() }
1907
1908#[derive(Debug, Clone)]
1909pub struct NamedFieldNode(SyntaxNode);
1910
1911impl NamedFieldNode {
1912 pub fn ast(&self) -> NamedField {
1913 NamedField::cast(self.0.borrowed()).unwrap()
1914 } 1642 }
1915} 1643 pub fn owned(&self) -> NameRefNode {
1916 1644 NameRefNode { syntax: self.syntax.owned() }
1917impl<'a> From<NamedField<'a>> for NamedFieldNode {
1918 fn from(ast: NamedField<'a>) -> NamedFieldNode {
1919 let syntax = ast.syntax().owned();
1920 NamedFieldNode(syntax)
1921 } 1645 }
1922} 1646}
1647
1648
1649impl<'a> NameRef<'a> {}
1650
1651// NamedField
1923#[derive(Debug, Clone, Copy)] 1652#[derive(Debug, Clone, Copy)]
1924pub struct NamedField<'a> { 1653pub struct NamedFieldNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1925 syntax: SyntaxNodeRef<'a>, 1654 syntax: SyntaxNode<R>,
1926} 1655}
1656pub type NamedField<'a> = NamedFieldNode<RefRoot<'a>>;
1927 1657
1928impl<'a> AstNode<'a> for NamedField<'a> { 1658impl<'a> AstNode<'a> for NamedField<'a> {
1929 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1659 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1935,29 +1665,24 @@ impl<'a> AstNode<'a> for NamedField<'a> {
1935 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1665 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1936} 1666}
1937 1667
1938impl<'a> NamedField<'a> {} 1668impl<R: TreeRoot<RaTypes>> NamedFieldNode<R> {
1939 1669 pub fn borrowed(&self) -> NamedField {
1940// NamedFieldDef 1670 NamedFieldNode { syntax: self.syntax.borrowed() }
1941
1942#[derive(Debug, Clone)]
1943pub struct NamedFieldDefNode(SyntaxNode);
1944
1945impl NamedFieldDefNode {
1946 pub fn ast(&self) -> NamedFieldDef {
1947 NamedFieldDef::cast(self.0.borrowed()).unwrap()
1948 } 1671 }
1949} 1672 pub fn owned(&self) -> NamedFieldNode {
1950 1673 NamedFieldNode { syntax: self.syntax.owned() }
1951impl<'a> From<NamedFieldDef<'a>> for NamedFieldDefNode {
1952 fn from(ast: NamedFieldDef<'a>) -> NamedFieldDefNode {
1953 let syntax = ast.syntax().owned();
1954 NamedFieldDefNode(syntax)
1955 } 1674 }
1956} 1675}
1676
1677
1678impl<'a> NamedField<'a> {}
1679
1680// NamedFieldDef
1957#[derive(Debug, Clone, Copy)] 1681#[derive(Debug, Clone, Copy)]
1958pub struct NamedFieldDef<'a> { 1682pub struct NamedFieldDefNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1959 syntax: SyntaxNodeRef<'a>, 1683 syntax: SyntaxNode<R>,
1960} 1684}
1685pub type NamedFieldDef<'a> = NamedFieldDefNode<RefRoot<'a>>;
1961 1686
1962impl<'a> AstNode<'a> for NamedFieldDef<'a> { 1687impl<'a> AstNode<'a> for NamedFieldDef<'a> {
1963 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1688 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1969,31 +1694,26 @@ impl<'a> AstNode<'a> for NamedFieldDef<'a> {
1969 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1694 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1970} 1695}
1971 1696
1697impl<R: TreeRoot<RaTypes>> NamedFieldDefNode<R> {
1698 pub fn borrowed(&self) -> NamedFieldDef {
1699 NamedFieldDefNode { syntax: self.syntax.borrowed() }
1700 }
1701 pub fn owned(&self) -> NamedFieldDefNode {
1702 NamedFieldDefNode { syntax: self.syntax.owned() }
1703 }
1704}
1705
1706
1972impl<'a> ast::NameOwner<'a> for NamedFieldDef<'a> {} 1707impl<'a> ast::NameOwner<'a> for NamedFieldDef<'a> {}
1973impl<'a> ast::AttrsOwner<'a> for NamedFieldDef<'a> {} 1708impl<'a> ast::AttrsOwner<'a> for NamedFieldDef<'a> {}
1974impl<'a> NamedFieldDef<'a> {} 1709impl<'a> NamedFieldDef<'a> {}
1975 1710
1976// NamedFieldList 1711// NamedFieldList
1977
1978#[derive(Debug, Clone)]
1979pub struct NamedFieldListNode(SyntaxNode);
1980
1981impl NamedFieldListNode {
1982 pub fn ast(&self) -> NamedFieldList {
1983 NamedFieldList::cast(self.0.borrowed()).unwrap()
1984 }
1985}
1986
1987impl<'a> From<NamedFieldList<'a>> for NamedFieldListNode {
1988 fn from(ast: NamedFieldList<'a>) -> NamedFieldListNode {
1989 let syntax = ast.syntax().owned();
1990 NamedFieldListNode(syntax)
1991 }
1992}
1993#[derive(Debug, Clone, Copy)] 1712#[derive(Debug, Clone, Copy)]
1994pub struct NamedFieldList<'a> { 1713pub struct NamedFieldListNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1995 syntax: SyntaxNodeRef<'a>, 1714 syntax: SyntaxNode<R>,
1996} 1715}
1716pub type NamedFieldList<'a> = NamedFieldListNode<RefRoot<'a>>;
1997 1717
1998impl<'a> AstNode<'a> for NamedFieldList<'a> { 1718impl<'a> AstNode<'a> for NamedFieldList<'a> {
1999 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1719 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2005,29 +1725,24 @@ impl<'a> AstNode<'a> for NamedFieldList<'a> {
2005 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1725 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2006} 1726}
2007 1727
2008impl<'a> NamedFieldList<'a> {} 1728impl<R: TreeRoot<RaTypes>> NamedFieldListNode<R> {
2009 1729 pub fn borrowed(&self) -> NamedFieldList {
2010// NeverType 1730 NamedFieldListNode { syntax: self.syntax.borrowed() }
2011
2012#[derive(Debug, Clone)]
2013pub struct NeverTypeNode(SyntaxNode);
2014
2015impl NeverTypeNode {
2016 pub fn ast(&self) -> NeverType {
2017 NeverType::cast(self.0.borrowed()).unwrap()
2018 } 1731 }
2019} 1732 pub fn owned(&self) -> NamedFieldListNode {
2020 1733 NamedFieldListNode { syntax: self.syntax.owned() }
2021impl<'a> From<NeverType<'a>> for NeverTypeNode {
2022 fn from(ast: NeverType<'a>) -> NeverTypeNode {
2023 let syntax = ast.syntax().owned();
2024 NeverTypeNode(syntax)
2025 } 1734 }
2026} 1735}
1736
1737
1738impl<'a> NamedFieldList<'a> {}
1739
1740// NeverType
2027#[derive(Debug, Clone, Copy)] 1741#[derive(Debug, Clone, Copy)]
2028pub struct NeverType<'a> { 1742pub struct NeverTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2029 syntax: SyntaxNodeRef<'a>, 1743 syntax: SyntaxNode<R>,
2030} 1744}
1745pub type NeverType<'a> = NeverTypeNode<RefRoot<'a>>;
2031 1746
2032impl<'a> AstNode<'a> for NeverType<'a> { 1747impl<'a> AstNode<'a> for NeverType<'a> {
2033 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1748 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2039,25 +1754,19 @@ impl<'a> AstNode<'a> for NeverType<'a> {
2039 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1754 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2040} 1755}
2041 1756
2042impl<'a> NeverType<'a> {} 1757impl<R: TreeRoot<RaTypes>> NeverTypeNode<R> {
2043 1758 pub fn borrowed(&self) -> NeverType {
2044// NominalDef 1759 NeverTypeNode { syntax: self.syntax.borrowed() }
2045
2046#[derive(Debug, Clone)]
2047pub struct NominalDefNode(SyntaxNode);
2048
2049impl NominalDefNode {
2050 pub fn ast(&self) -> NominalDef {
2051 NominalDef::cast(self.0.borrowed()).unwrap()
2052 } 1760 }
2053} 1761 pub fn owned(&self) -> NeverTypeNode {
2054 1762 NeverTypeNode { syntax: self.syntax.owned() }
2055impl<'a> From<NominalDef<'a>> for NominalDefNode {
2056 fn from(ast: NominalDef<'a>) -> NominalDefNode {
2057 let syntax = ast.syntax().owned();
2058 NominalDefNode(syntax)
2059 } 1763 }
2060} 1764}
1765
1766
1767impl<'a> NeverType<'a> {}
1768
1769// NominalDef
2061#[derive(Debug, Clone, Copy)] 1770#[derive(Debug, Clone, Copy)]
2062pub enum NominalDef<'a> { 1771pub enum NominalDef<'a> {
2063 StructDef(StructDef<'a>), 1772 StructDef(StructDef<'a>),
@@ -2086,26 +1795,11 @@ impl<'a> ast::AttrsOwner<'a> for NominalDef<'a> {}
2086impl<'a> NominalDef<'a> {} 1795impl<'a> NominalDef<'a> {}
2087 1796
2088// Param 1797// Param
2089
2090#[derive(Debug, Clone)]
2091pub struct ParamNode(SyntaxNode);
2092
2093impl ParamNode {
2094 pub fn ast(&self) -> Param {
2095 Param::cast(self.0.borrowed()).unwrap()
2096 }
2097}
2098
2099impl<'a> From<Param<'a>> for ParamNode {
2100 fn from(ast: Param<'a>) -> ParamNode {
2101 let syntax = ast.syntax().owned();
2102 ParamNode(syntax)
2103 }
2104}
2105#[derive(Debug, Clone, Copy)] 1798#[derive(Debug, Clone, Copy)]
2106pub struct Param<'a> { 1799pub struct ParamNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2107 syntax: SyntaxNodeRef<'a>, 1800 syntax: SyntaxNode<R>,
2108} 1801}
1802pub type Param<'a> = ParamNode<RefRoot<'a>>;
2109 1803
2110impl<'a> AstNode<'a> for Param<'a> { 1804impl<'a> AstNode<'a> for Param<'a> {
2111 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1805 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2117,33 +1811,28 @@ impl<'a> AstNode<'a> for Param<'a> {
2117 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1811 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2118} 1812}
2119 1813
2120impl<'a> Param<'a> { 1814impl<R: TreeRoot<RaTypes>> ParamNode<R> {
2121 pub fn pat(self) -> Option<Pat<'a>> { 1815 pub fn borrowed(&self) -> Param {
2122 super::child_opt(self) 1816 ParamNode { syntax: self.syntax.borrowed() }
1817 }
1818 pub fn owned(&self) -> ParamNode {
1819 ParamNode { syntax: self.syntax.owned() }
2123 } 1820 }
2124} 1821}
2125 1822
2126// ParamList
2127
2128#[derive(Debug, Clone)]
2129pub struct ParamListNode(SyntaxNode);
2130 1823
2131impl ParamListNode { 1824impl<'a> Param<'a> {
2132 pub fn ast(&self) -> ParamList { 1825 pub fn pat(self) -> Option<Pat<'a>> {
2133 ParamList::cast(self.0.borrowed()).unwrap() 1826 super::child_opt(self)
2134 } 1827 }
2135} 1828}
2136 1829
2137impl<'a> From<ParamList<'a>> for ParamListNode { 1830// ParamList
2138 fn from(ast: ParamList<'a>) -> ParamListNode {
2139 let syntax = ast.syntax().owned();
2140 ParamListNode(syntax)
2141 }
2142}
2143#[derive(Debug, Clone, Copy)] 1831#[derive(Debug, Clone, Copy)]
2144pub struct ParamList<'a> { 1832pub struct ParamListNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2145 syntax: SyntaxNodeRef<'a>, 1833 syntax: SyntaxNode<R>,
2146} 1834}
1835pub type ParamList<'a> = ParamListNode<RefRoot<'a>>;
2147 1836
2148impl<'a> AstNode<'a> for ParamList<'a> { 1837impl<'a> AstNode<'a> for ParamList<'a> {
2149 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1838 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2155,6 +1844,16 @@ impl<'a> AstNode<'a> for ParamList<'a> {
2155 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1844 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2156} 1845}
2157 1846
1847impl<R: TreeRoot<RaTypes>> ParamListNode<R> {
1848 pub fn borrowed(&self) -> ParamList {
1849 ParamListNode { syntax: self.syntax.borrowed() }
1850 }
1851 pub fn owned(&self) -> ParamListNode {
1852 ParamListNode { syntax: self.syntax.owned() }
1853 }
1854}
1855
1856
2158impl<'a> ParamList<'a> { 1857impl<'a> ParamList<'a> {
2159 pub fn params(self) -> impl Iterator<Item = Param<'a>> + 'a { 1858 pub fn params(self) -> impl Iterator<Item = Param<'a>> + 'a {
2160 super::children(self) 1859 super::children(self)
@@ -2166,26 +1865,11 @@ impl<'a> ParamList<'a> {
2166} 1865}
2167 1866
2168// ParenExpr 1867// ParenExpr
2169
2170#[derive(Debug, Clone)]
2171pub struct ParenExprNode(SyntaxNode);
2172
2173impl ParenExprNode {
2174 pub fn ast(&self) -> ParenExpr {
2175 ParenExpr::cast(self.0.borrowed()).unwrap()
2176 }
2177}
2178
2179impl<'a> From<ParenExpr<'a>> for ParenExprNode {
2180 fn from(ast: ParenExpr<'a>) -> ParenExprNode {
2181 let syntax = ast.syntax().owned();
2182 ParenExprNode(syntax)
2183 }
2184}
2185#[derive(Debug, Clone, Copy)] 1868#[derive(Debug, Clone, Copy)]
2186pub struct ParenExpr<'a> { 1869pub struct ParenExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2187 syntax: SyntaxNodeRef<'a>, 1870 syntax: SyntaxNode<R>,
2188} 1871}
1872pub type ParenExpr<'a> = ParenExprNode<RefRoot<'a>>;
2189 1873
2190impl<'a> AstNode<'a> for ParenExpr<'a> { 1874impl<'a> AstNode<'a> for ParenExpr<'a> {
2191 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1875 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2197,29 +1881,24 @@ impl<'a> AstNode<'a> for ParenExpr<'a> {
2197 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1881 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2198} 1882}
2199 1883
2200impl<'a> ParenExpr<'a> {} 1884impl<R: TreeRoot<RaTypes>> ParenExprNode<R> {
2201 1885 pub fn borrowed(&self) -> ParenExpr {
2202// ParenType 1886 ParenExprNode { syntax: self.syntax.borrowed() }
2203
2204#[derive(Debug, Clone)]
2205pub struct ParenTypeNode(SyntaxNode);
2206
2207impl ParenTypeNode {
2208 pub fn ast(&self) -> ParenType {
2209 ParenType::cast(self.0.borrowed()).unwrap()
2210 } 1887 }
2211} 1888 pub fn owned(&self) -> ParenExprNode {
2212 1889 ParenExprNode { syntax: self.syntax.owned() }
2213impl<'a> From<ParenType<'a>> for ParenTypeNode {
2214 fn from(ast: ParenType<'a>) -> ParenTypeNode {
2215 let syntax = ast.syntax().owned();
2216 ParenTypeNode(syntax)
2217 } 1890 }
2218} 1891}
1892
1893
1894impl<'a> ParenExpr<'a> {}
1895
1896// ParenType
2219#[derive(Debug, Clone, Copy)] 1897#[derive(Debug, Clone, Copy)]
2220pub struct ParenType<'a> { 1898pub struct ParenTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2221 syntax: SyntaxNodeRef<'a>, 1899 syntax: SyntaxNode<R>,
2222} 1900}
1901pub type ParenType<'a> = ParenTypeNode<RefRoot<'a>>;
2223 1902
2224impl<'a> AstNode<'a> for ParenType<'a> { 1903impl<'a> AstNode<'a> for ParenType<'a> {
2225 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1904 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2231,25 +1910,19 @@ impl<'a> AstNode<'a> for ParenType<'a> {
2231 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1910 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2232} 1911}
2233 1912
2234impl<'a> ParenType<'a> {} 1913impl<R: TreeRoot<RaTypes>> ParenTypeNode<R> {
2235 1914 pub fn borrowed(&self) -> ParenType {
2236// Pat 1915 ParenTypeNode { syntax: self.syntax.borrowed() }
2237
2238#[derive(Debug, Clone)]
2239pub struct PatNode(SyntaxNode);
2240
2241impl PatNode {
2242 pub fn ast(&self) -> Pat {
2243 Pat::cast(self.0.borrowed()).unwrap()
2244 } 1916 }
2245} 1917 pub fn owned(&self) -> ParenTypeNode {
2246 1918 ParenTypeNode { syntax: self.syntax.owned() }
2247impl<'a> From<Pat<'a>> for PatNode {
2248 fn from(ast: Pat<'a>) -> PatNode {
2249 let syntax = ast.syntax().owned();
2250 PatNode(syntax)
2251 } 1919 }
2252} 1920}
1921
1922
1923impl<'a> ParenType<'a> {}
1924
1925// Pat
2253#[derive(Debug, Clone, Copy)] 1926#[derive(Debug, Clone, Copy)]
2254pub enum Pat<'a> { 1927pub enum Pat<'a> {
2255 RefPat(RefPat<'a>), 1928 RefPat(RefPat<'a>),
@@ -2299,26 +1972,11 @@ impl<'a> AstNode<'a> for Pat<'a> {
2299impl<'a> Pat<'a> {} 1972impl<'a> Pat<'a> {}
2300 1973
2301// Path 1974// Path
2302
2303#[derive(Debug, Clone)]
2304pub struct PathNode(SyntaxNode);
2305
2306impl PathNode {
2307 pub fn ast(&self) -> Path {
2308 Path::cast(self.0.borrowed()).unwrap()
2309 }
2310}
2311
2312impl<'a> From<Path<'a>> for PathNode {
2313 fn from(ast: Path<'a>) -> PathNode {
2314 let syntax = ast.syntax().owned();
2315 PathNode(syntax)
2316 }
2317}
2318#[derive(Debug, Clone, Copy)] 1975#[derive(Debug, Clone, Copy)]
2319pub struct Path<'a> { 1976pub struct PathNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2320 syntax: SyntaxNodeRef<'a>, 1977 syntax: SyntaxNode<R>,
2321} 1978}
1979pub type Path<'a> = PathNode<RefRoot<'a>>;
2322 1980
2323impl<'a> AstNode<'a> for Path<'a> { 1981impl<'a> AstNode<'a> for Path<'a> {
2324 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1982 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2330,6 +1988,16 @@ impl<'a> AstNode<'a> for Path<'a> {
2330 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1988 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2331} 1989}
2332 1990
1991impl<R: TreeRoot<RaTypes>> PathNode<R> {
1992 pub fn borrowed(&self) -> Path {
1993 PathNode { syntax: self.syntax.borrowed() }
1994 }
1995 pub fn owned(&self) -> PathNode {
1996 PathNode { syntax: self.syntax.owned() }
1997 }
1998}
1999
2000
2333impl<'a> Path<'a> { 2001impl<'a> Path<'a> {
2334 pub fn segment(self) -> Option<PathSegment<'a>> { 2002 pub fn segment(self) -> Option<PathSegment<'a>> {
2335 super::child_opt(self) 2003 super::child_opt(self)
@@ -2341,26 +2009,11 @@ impl<'a> Path<'a> {
2341} 2009}
2342 2010
2343// PathExpr 2011// PathExpr
2344
2345#[derive(Debug, Clone)]
2346pub struct PathExprNode(SyntaxNode);
2347
2348impl PathExprNode {
2349 pub fn ast(&self) -> PathExpr {
2350 PathExpr::cast(self.0.borrowed()).unwrap()
2351 }
2352}
2353
2354impl<'a> From<PathExpr<'a>> for PathExprNode {
2355 fn from(ast: PathExpr<'a>) -> PathExprNode {
2356 let syntax = ast.syntax().owned();
2357 PathExprNode(syntax)
2358 }
2359}
2360#[derive(Debug, Clone, Copy)] 2012#[derive(Debug, Clone, Copy)]
2361pub struct PathExpr<'a> { 2013pub struct PathExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2362 syntax: SyntaxNodeRef<'a>, 2014 syntax: SyntaxNode<R>,
2363} 2015}
2016pub type PathExpr<'a> = PathExprNode<RefRoot<'a>>;
2364 2017
2365impl<'a> AstNode<'a> for PathExpr<'a> { 2018impl<'a> AstNode<'a> for PathExpr<'a> {
2366 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2019 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2372,33 +2025,28 @@ impl<'a> AstNode<'a> for PathExpr<'a> {
2372 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2025 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2373} 2026}
2374 2027
2375impl<'a> PathExpr<'a> { 2028impl<R: TreeRoot<RaTypes>> PathExprNode<R> {
2376 pub fn path(self) -> Option<Path<'a>> { 2029 pub fn borrowed(&self) -> PathExpr {
2377 super::child_opt(self) 2030 PathExprNode { syntax: self.syntax.borrowed() }
2031 }
2032 pub fn owned(&self) -> PathExprNode {
2033 PathExprNode { syntax: self.syntax.owned() }
2378 } 2034 }
2379} 2035}
2380 2036
2381// PathPat
2382
2383#[derive(Debug, Clone)]
2384pub struct PathPatNode(SyntaxNode);
2385 2037
2386impl PathPatNode { 2038impl<'a> PathExpr<'a> {
2387 pub fn ast(&self) -> PathPat { 2039 pub fn path(self) -> Option<Path<'a>> {
2388 PathPat::cast(self.0.borrowed()).unwrap() 2040 super::child_opt(self)
2389 } 2041 }
2390} 2042}
2391 2043
2392impl<'a> From<PathPat<'a>> for PathPatNode { 2044// PathPat
2393 fn from(ast: PathPat<'a>) -> PathPatNode {
2394 let syntax = ast.syntax().owned();
2395 PathPatNode(syntax)
2396 }
2397}
2398#[derive(Debug, Clone, Copy)] 2045#[derive(Debug, Clone, Copy)]
2399pub struct PathPat<'a> { 2046pub struct PathPatNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2400 syntax: SyntaxNodeRef<'a>, 2047 syntax: SyntaxNode<R>,
2401} 2048}
2049pub type PathPat<'a> = PathPatNode<RefRoot<'a>>;
2402 2050
2403impl<'a> AstNode<'a> for PathPat<'a> { 2051impl<'a> AstNode<'a> for PathPat<'a> {
2404 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2052 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2410,29 +2058,24 @@ impl<'a> AstNode<'a> for PathPat<'a> {
2410 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2058 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2411} 2059}
2412 2060
2413impl<'a> PathPat<'a> {} 2061impl<R: TreeRoot<RaTypes>> PathPatNode<R> {
2414 2062 pub fn borrowed(&self) -> PathPat {
2415// PathSegment 2063 PathPatNode { syntax: self.syntax.borrowed() }
2416
2417#[derive(Debug, Clone)]
2418pub struct PathSegmentNode(SyntaxNode);
2419
2420impl PathSegmentNode {
2421 pub fn ast(&self) -> PathSegment {
2422 PathSegment::cast(self.0.borrowed()).unwrap()
2423 } 2064 }
2424} 2065 pub fn owned(&self) -> PathPatNode {
2425 2066 PathPatNode { syntax: self.syntax.owned() }
2426impl<'a> From<PathSegment<'a>> for PathSegmentNode {
2427 fn from(ast: PathSegment<'a>) -> PathSegmentNode {
2428 let syntax = ast.syntax().owned();
2429 PathSegmentNode(syntax)
2430 } 2067 }
2431} 2068}
2069
2070
2071impl<'a> PathPat<'a> {}
2072
2073// PathSegment
2432#[derive(Debug, Clone, Copy)] 2074#[derive(Debug, Clone, Copy)]
2433pub struct PathSegment<'a> { 2075pub struct PathSegmentNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2434 syntax: SyntaxNodeRef<'a>, 2076 syntax: SyntaxNode<R>,
2435} 2077}
2078pub type PathSegment<'a> = PathSegmentNode<RefRoot<'a>>;
2436 2079
2437impl<'a> AstNode<'a> for PathSegment<'a> { 2080impl<'a> AstNode<'a> for PathSegment<'a> {
2438 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2081 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2444,33 +2087,28 @@ impl<'a> AstNode<'a> for PathSegment<'a> {
2444 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2087 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2445} 2088}
2446 2089
2447impl<'a> PathSegment<'a> { 2090impl<R: TreeRoot<RaTypes>> PathSegmentNode<R> {
2448 pub fn name_ref(self) -> Option<NameRef<'a>> { 2091 pub fn borrowed(&self) -> PathSegment {
2449 super::child_opt(self) 2092 PathSegmentNode { syntax: self.syntax.borrowed() }
2093 }
2094 pub fn owned(&self) -> PathSegmentNode {
2095 PathSegmentNode { syntax: self.syntax.owned() }
2450 } 2096 }
2451} 2097}
2452 2098
2453// PathType
2454
2455#[derive(Debug, Clone)]
2456pub struct PathTypeNode(SyntaxNode);
2457 2099
2458impl PathTypeNode { 2100impl<'a> PathSegment<'a> {
2459 pub fn ast(&self) -> PathType { 2101 pub fn name_ref(self) -> Option<NameRef<'a>> {
2460 PathType::cast(self.0.borrowed()).unwrap() 2102 super::child_opt(self)
2461 } 2103 }
2462} 2104}
2463 2105
2464impl<'a> From<PathType<'a>> for PathTypeNode { 2106// PathType
2465 fn from(ast: PathType<'a>) -> PathTypeNode {
2466 let syntax = ast.syntax().owned();
2467 PathTypeNode(syntax)
2468 }
2469}
2470#[derive(Debug, Clone, Copy)] 2107#[derive(Debug, Clone, Copy)]
2471pub struct PathType<'a> { 2108pub struct PathTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2472 syntax: SyntaxNodeRef<'a>, 2109 syntax: SyntaxNode<R>,
2473} 2110}
2111pub type PathType<'a> = PathTypeNode<RefRoot<'a>>;
2474 2112
2475impl<'a> AstNode<'a> for PathType<'a> { 2113impl<'a> AstNode<'a> for PathType<'a> {
2476 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2114 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2482,29 +2120,24 @@ impl<'a> AstNode<'a> for PathType<'a> {
2482 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2120 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2483} 2121}
2484 2122
2485impl<'a> PathType<'a> {} 2123impl<R: TreeRoot<RaTypes>> PathTypeNode<R> {
2486 2124 pub fn borrowed(&self) -> PathType {
2487// PlaceholderPat 2125 PathTypeNode { syntax: self.syntax.borrowed() }
2488
2489#[derive(Debug, Clone)]
2490pub struct PlaceholderPatNode(SyntaxNode);
2491
2492impl PlaceholderPatNode {
2493 pub fn ast(&self) -> PlaceholderPat {
2494 PlaceholderPat::cast(self.0.borrowed()).unwrap()
2495 } 2126 }
2496} 2127 pub fn owned(&self) -> PathTypeNode {
2497 2128 PathTypeNode { syntax: self.syntax.owned() }
2498impl<'a> From<PlaceholderPat<'a>> for PlaceholderPatNode {
2499 fn from(ast: PlaceholderPat<'a>) -> PlaceholderPatNode {
2500 let syntax = ast.syntax().owned();
2501 PlaceholderPatNode(syntax)
2502 } 2129 }
2503} 2130}
2131
2132
2133impl<'a> PathType<'a> {}
2134
2135// PlaceholderPat
2504#[derive(Debug, Clone, Copy)] 2136#[derive(Debug, Clone, Copy)]
2505pub struct PlaceholderPat<'a> { 2137pub struct PlaceholderPatNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2506 syntax: SyntaxNodeRef<'a>, 2138 syntax: SyntaxNode<R>,
2507} 2139}
2140pub type PlaceholderPat<'a> = PlaceholderPatNode<RefRoot<'a>>;
2508 2141
2509impl<'a> AstNode<'a> for PlaceholderPat<'a> { 2142impl<'a> AstNode<'a> for PlaceholderPat<'a> {
2510 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2143 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2516,29 +2149,24 @@ impl<'a> AstNode<'a> for PlaceholderPat<'a> {
2516 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2149 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2517} 2150}
2518 2151
2519impl<'a> PlaceholderPat<'a> {} 2152impl<R: TreeRoot<RaTypes>> PlaceholderPatNode<R> {
2520 2153 pub fn borrowed(&self) -> PlaceholderPat {
2521// PlaceholderType 2154 PlaceholderPatNode { syntax: self.syntax.borrowed() }
2522
2523#[derive(Debug, Clone)]
2524pub struct PlaceholderTypeNode(SyntaxNode);
2525
2526impl PlaceholderTypeNode {
2527 pub fn ast(&self) -> PlaceholderType {
2528 PlaceholderType::cast(self.0.borrowed()).unwrap()
2529 } 2155 }
2530} 2156 pub fn owned(&self) -> PlaceholderPatNode {
2531 2157 PlaceholderPatNode { syntax: self.syntax.owned() }
2532impl<'a> From<PlaceholderType<'a>> for PlaceholderTypeNode {
2533 fn from(ast: PlaceholderType<'a>) -> PlaceholderTypeNode {
2534 let syntax = ast.syntax().owned();
2535 PlaceholderTypeNode(syntax)
2536 } 2158 }
2537} 2159}
2160
2161
2162impl<'a> PlaceholderPat<'a> {}
2163
2164// PlaceholderType
2538#[derive(Debug, Clone, Copy)] 2165#[derive(Debug, Clone, Copy)]
2539pub struct PlaceholderType<'a> { 2166pub struct PlaceholderTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2540 syntax: SyntaxNodeRef<'a>, 2167 syntax: SyntaxNode<R>,
2541} 2168}
2169pub type PlaceholderType<'a> = PlaceholderTypeNode<RefRoot<'a>>;
2542 2170
2543impl<'a> AstNode<'a> for PlaceholderType<'a> { 2171impl<'a> AstNode<'a> for PlaceholderType<'a> {
2544 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2172 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2550,29 +2178,24 @@ impl<'a> AstNode<'a> for PlaceholderType<'a> {
2550 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2178 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2551} 2179}
2552 2180
2553impl<'a> PlaceholderType<'a> {} 2181impl<R: TreeRoot<RaTypes>> PlaceholderTypeNode<R> {
2554 2182 pub fn borrowed(&self) -> PlaceholderType {
2555// PointerType 2183 PlaceholderTypeNode { syntax: self.syntax.borrowed() }
2556
2557#[derive(Debug, Clone)]
2558pub struct PointerTypeNode(SyntaxNode);
2559
2560impl PointerTypeNode {
2561 pub fn ast(&self) -> PointerType {
2562 PointerType::cast(self.0.borrowed()).unwrap()
2563 } 2184 }
2564} 2185 pub fn owned(&self) -> PlaceholderTypeNode {
2565 2186 PlaceholderTypeNode { syntax: self.syntax.owned() }
2566impl<'a> From<PointerType<'a>> for PointerTypeNode {
2567 fn from(ast: PointerType<'a>) -> PointerTypeNode {
2568 let syntax = ast.syntax().owned();
2569 PointerTypeNode(syntax)
2570 } 2187 }
2571} 2188}
2189
2190
2191impl<'a> PlaceholderType<'a> {}
2192
2193// PointerType
2572#[derive(Debug, Clone, Copy)] 2194#[derive(Debug, Clone, Copy)]
2573pub struct PointerType<'a> { 2195pub struct PointerTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2574 syntax: SyntaxNodeRef<'a>, 2196 syntax: SyntaxNode<R>,
2575} 2197}
2198pub type PointerType<'a> = PointerTypeNode<RefRoot<'a>>;
2576 2199
2577impl<'a> AstNode<'a> for PointerType<'a> { 2200impl<'a> AstNode<'a> for PointerType<'a> {
2578 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2201 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2584,29 +2207,24 @@ impl<'a> AstNode<'a> for PointerType<'a> {
2584 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2207 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2585} 2208}
2586 2209
2587impl<'a> PointerType<'a> {} 2210impl<R: TreeRoot<RaTypes>> PointerTypeNode<R> {
2588 2211 pub fn borrowed(&self) -> PointerType {
2589// PrefixExpr 2212 PointerTypeNode { syntax: self.syntax.borrowed() }
2590
2591#[derive(Debug, Clone)]
2592pub struct PrefixExprNode(SyntaxNode);
2593
2594impl PrefixExprNode {
2595 pub fn ast(&self) -> PrefixExpr {
2596 PrefixExpr::cast(self.0.borrowed()).unwrap()
2597 } 2213 }
2598} 2214 pub fn owned(&self) -> PointerTypeNode {
2599 2215 PointerTypeNode { syntax: self.syntax.owned() }
2600impl<'a> From<PrefixExpr<'a>> for PrefixExprNode {
2601 fn from(ast: PrefixExpr<'a>) -> PrefixExprNode {
2602 let syntax = ast.syntax().owned();
2603 PrefixExprNode(syntax)
2604 } 2216 }
2605} 2217}
2218
2219
2220impl<'a> PointerType<'a> {}
2221
2222// PrefixExpr
2606#[derive(Debug, Clone, Copy)] 2223#[derive(Debug, Clone, Copy)]
2607pub struct PrefixExpr<'a> { 2224pub struct PrefixExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2608 syntax: SyntaxNodeRef<'a>, 2225 syntax: SyntaxNode<R>,
2609} 2226}
2227pub type PrefixExpr<'a> = PrefixExprNode<RefRoot<'a>>;
2610 2228
2611impl<'a> AstNode<'a> for PrefixExpr<'a> { 2229impl<'a> AstNode<'a> for PrefixExpr<'a> {
2612 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2230 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2618,29 +2236,24 @@ impl<'a> AstNode<'a> for PrefixExpr<'a> {
2618 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2236 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2619} 2237}
2620 2238
2621impl<'a> PrefixExpr<'a> {} 2239impl<R: TreeRoot<RaTypes>> PrefixExprNode<R> {
2622 2240 pub fn borrowed(&self) -> PrefixExpr {
2623// RangeExpr 2241 PrefixExprNode { syntax: self.syntax.borrowed() }
2624
2625#[derive(Debug, Clone)]
2626pub struct RangeExprNode(SyntaxNode);
2627
2628impl RangeExprNode {
2629 pub fn ast(&self) -> RangeExpr {
2630 RangeExpr::cast(self.0.borrowed()).unwrap()
2631 } 2242 }
2632} 2243 pub fn owned(&self) -> PrefixExprNode {
2633 2244 PrefixExprNode { syntax: self.syntax.owned() }
2634impl<'a> From<RangeExpr<'a>> for RangeExprNode {
2635 fn from(ast: RangeExpr<'a>) -> RangeExprNode {
2636 let syntax = ast.syntax().owned();
2637 RangeExprNode(syntax)
2638 } 2245 }
2639} 2246}
2247
2248
2249impl<'a> PrefixExpr<'a> {}
2250
2251// RangeExpr
2640#[derive(Debug, Clone, Copy)] 2252#[derive(Debug, Clone, Copy)]
2641pub struct RangeExpr<'a> { 2253pub struct RangeExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2642 syntax: SyntaxNodeRef<'a>, 2254 syntax: SyntaxNode<R>,
2643} 2255}
2256pub type RangeExpr<'a> = RangeExprNode<RefRoot<'a>>;
2644 2257
2645impl<'a> AstNode<'a> for RangeExpr<'a> { 2258impl<'a> AstNode<'a> for RangeExpr<'a> {
2646 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2259 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2652,29 +2265,24 @@ impl<'a> AstNode<'a> for RangeExpr<'a> {
2652 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2265 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2653} 2266}
2654 2267
2655impl<'a> RangeExpr<'a> {} 2268impl<R: TreeRoot<RaTypes>> RangeExprNode<R> {
2656 2269 pub fn borrowed(&self) -> RangeExpr {
2657// RangePat 2270 RangeExprNode { syntax: self.syntax.borrowed() }
2658
2659#[derive(Debug, Clone)]
2660pub struct RangePatNode(SyntaxNode);
2661
2662impl RangePatNode {
2663 pub fn ast(&self) -> RangePat {
2664 RangePat::cast(self.0.borrowed()).unwrap()
2665 } 2271 }
2666} 2272 pub fn owned(&self) -> RangeExprNode {
2667 2273 RangeExprNode { syntax: self.syntax.owned() }
2668impl<'a> From<RangePat<'a>> for RangePatNode {
2669 fn from(ast: RangePat<'a>) -> RangePatNode {
2670 let syntax = ast.syntax().owned();
2671 RangePatNode(syntax)
2672 } 2274 }
2673} 2275}
2276
2277
2278impl<'a> RangeExpr<'a> {}
2279
2280// RangePat
2674#[derive(Debug, Clone, Copy)] 2281#[derive(Debug, Clone, Copy)]
2675pub struct RangePat<'a> { 2282pub struct RangePatNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2676 syntax: SyntaxNodeRef<'a>, 2283 syntax: SyntaxNode<R>,
2677} 2284}
2285pub type RangePat<'a> = RangePatNode<RefRoot<'a>>;
2678 2286
2679impl<'a> AstNode<'a> for RangePat<'a> { 2287impl<'a> AstNode<'a> for RangePat<'a> {
2680 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2288 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2686,29 +2294,24 @@ impl<'a> AstNode<'a> for RangePat<'a> {
2686 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2294 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2687} 2295}
2688 2296
2689impl<'a> RangePat<'a> {} 2297impl<R: TreeRoot<RaTypes>> RangePatNode<R> {
2690 2298 pub fn borrowed(&self) -> RangePat {
2691// RefExpr 2299 RangePatNode { syntax: self.syntax.borrowed() }
2692
2693#[derive(Debug, Clone)]
2694pub struct RefExprNode(SyntaxNode);
2695
2696impl RefExprNode {
2697 pub fn ast(&self) -> RefExpr {
2698 RefExpr::cast(self.0.borrowed()).unwrap()
2699 } 2300 }
2700} 2301 pub fn owned(&self) -> RangePatNode {
2701 2302 RangePatNode { syntax: self.syntax.owned() }
2702impl<'a> From<RefExpr<'a>> for RefExprNode {
2703 fn from(ast: RefExpr<'a>) -> RefExprNode {
2704 let syntax = ast.syntax().owned();
2705 RefExprNode(syntax)
2706 } 2303 }
2707} 2304}
2305
2306
2307impl<'a> RangePat<'a> {}
2308
2309// RefExpr
2708#[derive(Debug, Clone, Copy)] 2310#[derive(Debug, Clone, Copy)]
2709pub struct RefExpr<'a> { 2311pub struct RefExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2710 syntax: SyntaxNodeRef<'a>, 2312 syntax: SyntaxNode<R>,
2711} 2313}
2314pub type RefExpr<'a> = RefExprNode<RefRoot<'a>>;
2712 2315
2713impl<'a> AstNode<'a> for RefExpr<'a> { 2316impl<'a> AstNode<'a> for RefExpr<'a> {
2714 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2317 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2720,29 +2323,24 @@ impl<'a> AstNode<'a> for RefExpr<'a> {
2720 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2323 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2721} 2324}
2722 2325
2723impl<'a> RefExpr<'a> {} 2326impl<R: TreeRoot<RaTypes>> RefExprNode<R> {
2724 2327 pub fn borrowed(&self) -> RefExpr {
2725// RefPat 2328 RefExprNode { syntax: self.syntax.borrowed() }
2726
2727#[derive(Debug, Clone)]
2728pub struct RefPatNode(SyntaxNode);
2729
2730impl RefPatNode {
2731 pub fn ast(&self) -> RefPat {
2732 RefPat::cast(self.0.borrowed()).unwrap()
2733 } 2329 }
2734} 2330 pub fn owned(&self) -> RefExprNode {
2735 2331 RefExprNode { syntax: self.syntax.owned() }
2736impl<'a> From<RefPat<'a>> for RefPatNode {
2737 fn from(ast: RefPat<'a>) -> RefPatNode {
2738 let syntax = ast.syntax().owned();
2739 RefPatNode(syntax)
2740 } 2332 }
2741} 2333}
2334
2335
2336impl<'a> RefExpr<'a> {}
2337
2338// RefPat
2742#[derive(Debug, Clone, Copy)] 2339#[derive(Debug, Clone, Copy)]
2743pub struct RefPat<'a> { 2340pub struct RefPatNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2744 syntax: SyntaxNodeRef<'a>, 2341 syntax: SyntaxNode<R>,
2745} 2342}
2343pub type RefPat<'a> = RefPatNode<RefRoot<'a>>;
2746 2344
2747impl<'a> AstNode<'a> for RefPat<'a> { 2345impl<'a> AstNode<'a> for RefPat<'a> {
2748 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2346 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2754,29 +2352,24 @@ impl<'a> AstNode<'a> for RefPat<'a> {
2754 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2352 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2755} 2353}
2756 2354
2757impl<'a> RefPat<'a> {} 2355impl<R: TreeRoot<RaTypes>> RefPatNode<R> {
2758 2356 pub fn borrowed(&self) -> RefPat {
2759// ReferenceType 2357 RefPatNode { syntax: self.syntax.borrowed() }
2760
2761#[derive(Debug, Clone)]
2762pub struct ReferenceTypeNode(SyntaxNode);
2763
2764impl ReferenceTypeNode {
2765 pub fn ast(&self) -> ReferenceType {
2766 ReferenceType::cast(self.0.borrowed()).unwrap()
2767 } 2358 }
2768} 2359 pub fn owned(&self) -> RefPatNode {
2769 2360 RefPatNode { syntax: self.syntax.owned() }
2770impl<'a> From<ReferenceType<'a>> for ReferenceTypeNode {
2771 fn from(ast: ReferenceType<'a>) -> ReferenceTypeNode {
2772 let syntax = ast.syntax().owned();
2773 ReferenceTypeNode(syntax)
2774 } 2361 }
2775} 2362}
2363
2364
2365impl<'a> RefPat<'a> {}
2366
2367// ReferenceType
2776#[derive(Debug, Clone, Copy)] 2368#[derive(Debug, Clone, Copy)]
2777pub struct ReferenceType<'a> { 2369pub struct ReferenceTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2778 syntax: SyntaxNodeRef<'a>, 2370 syntax: SyntaxNode<R>,
2779} 2371}
2372pub type ReferenceType<'a> = ReferenceTypeNode<RefRoot<'a>>;
2780 2373
2781impl<'a> AstNode<'a> for ReferenceType<'a> { 2374impl<'a> AstNode<'a> for ReferenceType<'a> {
2782 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2375 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2788,29 +2381,24 @@ impl<'a> AstNode<'a> for ReferenceType<'a> {
2788 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2381 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2789} 2382}
2790 2383
2791impl<'a> ReferenceType<'a> {} 2384impl<R: TreeRoot<RaTypes>> ReferenceTypeNode<R> {
2792 2385 pub fn borrowed(&self) -> ReferenceType {
2793// RetType 2386 ReferenceTypeNode { syntax: self.syntax.borrowed() }
2794
2795#[derive(Debug, Clone)]
2796pub struct RetTypeNode(SyntaxNode);
2797
2798impl RetTypeNode {
2799 pub fn ast(&self) -> RetType {
2800 RetType::cast(self.0.borrowed()).unwrap()
2801 } 2387 }
2802} 2388 pub fn owned(&self) -> ReferenceTypeNode {
2803 2389 ReferenceTypeNode { syntax: self.syntax.owned() }
2804impl<'a> From<RetType<'a>> for RetTypeNode {
2805 fn from(ast: RetType<'a>) -> RetTypeNode {
2806 let syntax = ast.syntax().owned();
2807 RetTypeNode(syntax)
2808 } 2390 }
2809} 2391}
2392
2393
2394impl<'a> ReferenceType<'a> {}
2395
2396// RetType
2810#[derive(Debug, Clone, Copy)] 2397#[derive(Debug, Clone, Copy)]
2811pub struct RetType<'a> { 2398pub struct RetTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2812 syntax: SyntaxNodeRef<'a>, 2399 syntax: SyntaxNode<R>,
2813} 2400}
2401pub type RetType<'a> = RetTypeNode<RefRoot<'a>>;
2814 2402
2815impl<'a> AstNode<'a> for RetType<'a> { 2403impl<'a> AstNode<'a> for RetType<'a> {
2816 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2404 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2822,29 +2410,24 @@ impl<'a> AstNode<'a> for RetType<'a> {
2822 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2410 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2823} 2411}
2824 2412
2825impl<'a> RetType<'a> {} 2413impl<R: TreeRoot<RaTypes>> RetTypeNode<R> {
2826 2414 pub fn borrowed(&self) -> RetType {
2827// ReturnExpr 2415 RetTypeNode { syntax: self.syntax.borrowed() }
2828
2829#[derive(Debug, Clone)]
2830pub struct ReturnExprNode(SyntaxNode);
2831
2832impl ReturnExprNode {
2833 pub fn ast(&self) -> ReturnExpr {
2834 ReturnExpr::cast(self.0.borrowed()).unwrap()
2835 } 2416 }
2836} 2417 pub fn owned(&self) -> RetTypeNode {
2837 2418 RetTypeNode { syntax: self.syntax.owned() }
2838impl<'a> From<ReturnExpr<'a>> for ReturnExprNode {
2839 fn from(ast: ReturnExpr<'a>) -> ReturnExprNode {
2840 let syntax = ast.syntax().owned();
2841 ReturnExprNode(syntax)
2842 } 2419 }
2843} 2420}
2421
2422
2423impl<'a> RetType<'a> {}
2424
2425// ReturnExpr
2844#[derive(Debug, Clone, Copy)] 2426#[derive(Debug, Clone, Copy)]
2845pub struct ReturnExpr<'a> { 2427pub struct ReturnExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2846 syntax: SyntaxNodeRef<'a>, 2428 syntax: SyntaxNode<R>,
2847} 2429}
2430pub type ReturnExpr<'a> = ReturnExprNode<RefRoot<'a>>;
2848 2431
2849impl<'a> AstNode<'a> for ReturnExpr<'a> { 2432impl<'a> AstNode<'a> for ReturnExpr<'a> {
2850 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2433 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2856,29 +2439,24 @@ impl<'a> AstNode<'a> for ReturnExpr<'a> {
2856 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2439 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2857} 2440}
2858 2441
2859impl<'a> ReturnExpr<'a> {} 2442impl<R: TreeRoot<RaTypes>> ReturnExprNode<R> {
2860 2443 pub fn borrowed(&self) -> ReturnExpr {
2861// Root 2444 ReturnExprNode { syntax: self.syntax.borrowed() }
2862
2863#[derive(Debug, Clone)]
2864pub struct RootNode(SyntaxNode);
2865
2866impl RootNode {
2867 pub fn ast(&self) -> Root {
2868 Root::cast(self.0.borrowed()).unwrap()
2869 } 2445 }
2870} 2446 pub fn owned(&self) -> ReturnExprNode {
2871 2447 ReturnExprNode { syntax: self.syntax.owned() }
2872impl<'a> From<Root<'a>> for RootNode {
2873 fn from(ast: Root<'a>) -> RootNode {
2874 let syntax = ast.syntax().owned();
2875 RootNode(syntax)
2876 } 2448 }
2877} 2449}
2450
2451
2452impl<'a> ReturnExpr<'a> {}
2453
2454// Root
2878#[derive(Debug, Clone, Copy)] 2455#[derive(Debug, Clone, Copy)]
2879pub struct Root<'a> { 2456pub struct RootNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2880 syntax: SyntaxNodeRef<'a>, 2457 syntax: SyntaxNode<R>,
2881} 2458}
2459pub type Root<'a> = RootNode<RefRoot<'a>>;
2882 2460
2883impl<'a> AstNode<'a> for Root<'a> { 2461impl<'a> AstNode<'a> for Root<'a> {
2884 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2462 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2890,6 +2468,16 @@ impl<'a> AstNode<'a> for Root<'a> {
2890 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2468 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2891} 2469}
2892 2470
2471impl<R: TreeRoot<RaTypes>> RootNode<R> {
2472 pub fn borrowed(&self) -> Root {
2473 RootNode { syntax: self.syntax.borrowed() }
2474 }
2475 pub fn owned(&self) -> RootNode {
2476 RootNode { syntax: self.syntax.owned() }
2477 }
2478}
2479
2480
2893impl<'a> ast::ModuleItemOwner<'a> for Root<'a> {} 2481impl<'a> ast::ModuleItemOwner<'a> for Root<'a> {}
2894impl<'a> ast::FnDefOwner<'a> for Root<'a> {} 2482impl<'a> ast::FnDefOwner<'a> for Root<'a> {}
2895impl<'a> Root<'a> { 2483impl<'a> Root<'a> {
@@ -2899,26 +2487,11 @@ impl<'a> Root<'a> {
2899} 2487}
2900 2488
2901// SelfParam 2489// SelfParam
2902
2903#[derive(Debug, Clone)]
2904pub struct SelfParamNode(SyntaxNode);
2905
2906impl SelfParamNode {
2907 pub fn ast(&self) -> SelfParam {
2908 SelfParam::cast(self.0.borrowed()).unwrap()
2909 }
2910}
2911
2912impl<'a> From<SelfParam<'a>> for SelfParamNode {
2913 fn from(ast: SelfParam<'a>) -> SelfParamNode {
2914 let syntax = ast.syntax().owned();
2915 SelfParamNode(syntax)
2916 }
2917}
2918#[derive(Debug, Clone, Copy)] 2490#[derive(Debug, Clone, Copy)]
2919pub struct SelfParam<'a> { 2491pub struct SelfParamNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2920 syntax: SyntaxNodeRef<'a>, 2492 syntax: SyntaxNode<R>,
2921} 2493}
2494pub type SelfParam<'a> = SelfParamNode<RefRoot<'a>>;
2922 2495
2923impl<'a> AstNode<'a> for SelfParam<'a> { 2496impl<'a> AstNode<'a> for SelfParam<'a> {
2924 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2497 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2930,29 +2503,24 @@ impl<'a> AstNode<'a> for SelfParam<'a> {
2930 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2503 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2931} 2504}
2932 2505
2933impl<'a> SelfParam<'a> {} 2506impl<R: TreeRoot<RaTypes>> SelfParamNode<R> {
2934 2507 pub fn borrowed(&self) -> SelfParam {
2935// SlicePat 2508 SelfParamNode { syntax: self.syntax.borrowed() }
2936
2937#[derive(Debug, Clone)]
2938pub struct SlicePatNode(SyntaxNode);
2939
2940impl SlicePatNode {
2941 pub fn ast(&self) -> SlicePat {
2942 SlicePat::cast(self.0.borrowed()).unwrap()
2943 } 2509 }
2944} 2510 pub fn owned(&self) -> SelfParamNode {
2945 2511 SelfParamNode { syntax: self.syntax.owned() }
2946impl<'a> From<SlicePat<'a>> for SlicePatNode {
2947 fn from(ast: SlicePat<'a>) -> SlicePatNode {
2948 let syntax = ast.syntax().owned();
2949 SlicePatNode(syntax)
2950 } 2512 }
2951} 2513}
2514
2515
2516impl<'a> SelfParam<'a> {}
2517
2518// SlicePat
2952#[derive(Debug, Clone, Copy)] 2519#[derive(Debug, Clone, Copy)]
2953pub struct SlicePat<'a> { 2520pub struct SlicePatNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2954 syntax: SyntaxNodeRef<'a>, 2521 syntax: SyntaxNode<R>,
2955} 2522}
2523pub type SlicePat<'a> = SlicePatNode<RefRoot<'a>>;
2956 2524
2957impl<'a> AstNode<'a> for SlicePat<'a> { 2525impl<'a> AstNode<'a> for SlicePat<'a> {
2958 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2526 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2964,29 +2532,24 @@ impl<'a> AstNode<'a> for SlicePat<'a> {
2964 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2532 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2965} 2533}
2966 2534
2967impl<'a> SlicePat<'a> {} 2535impl<R: TreeRoot<RaTypes>> SlicePatNode<R> {
2968 2536 pub fn borrowed(&self) -> SlicePat {
2969// SliceType 2537 SlicePatNode { syntax: self.syntax.borrowed() }
2970
2971#[derive(Debug, Clone)]
2972pub struct SliceTypeNode(SyntaxNode);
2973
2974impl SliceTypeNode {
2975 pub fn ast(&self) -> SliceType {
2976 SliceType::cast(self.0.borrowed()).unwrap()
2977 } 2538 }
2978} 2539 pub fn owned(&self) -> SlicePatNode {
2979 2540 SlicePatNode { syntax: self.syntax.owned() }
2980impl<'a> From<SliceType<'a>> for SliceTypeNode {
2981 fn from(ast: SliceType<'a>) -> SliceTypeNode {
2982 let syntax = ast.syntax().owned();
2983 SliceTypeNode(syntax)
2984 } 2541 }
2985} 2542}
2543
2544
2545impl<'a> SlicePat<'a> {}
2546
2547// SliceType
2986#[derive(Debug, Clone, Copy)] 2548#[derive(Debug, Clone, Copy)]
2987pub struct SliceType<'a> { 2549pub struct SliceTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2988 syntax: SyntaxNodeRef<'a>, 2550 syntax: SyntaxNode<R>,
2989} 2551}
2552pub type SliceType<'a> = SliceTypeNode<RefRoot<'a>>;
2990 2553
2991impl<'a> AstNode<'a> for SliceType<'a> { 2554impl<'a> AstNode<'a> for SliceType<'a> {
2992 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2555 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2998,29 +2561,24 @@ impl<'a> AstNode<'a> for SliceType<'a> {
2998 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2561 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2999} 2562}
3000 2563
3001impl<'a> SliceType<'a> {} 2564impl<R: TreeRoot<RaTypes>> SliceTypeNode<R> {
3002 2565 pub fn borrowed(&self) -> SliceType {
3003// StaticDef 2566 SliceTypeNode { syntax: self.syntax.borrowed() }
3004
3005#[derive(Debug, Clone)]
3006pub struct StaticDefNode(SyntaxNode);
3007
3008impl StaticDefNode {
3009 pub fn ast(&self) -> StaticDef {
3010 StaticDef::cast(self.0.borrowed()).unwrap()
3011 } 2567 }
3012} 2568 pub fn owned(&self) -> SliceTypeNode {
3013 2569 SliceTypeNode { syntax: self.syntax.owned() }
3014impl<'a> From<StaticDef<'a>> for StaticDefNode {
3015 fn from(ast: StaticDef<'a>) -> StaticDefNode {
3016 let syntax = ast.syntax().owned();
3017 StaticDefNode(syntax)
3018 } 2570 }
3019} 2571}
2572
2573
2574impl<'a> SliceType<'a> {}
2575
2576// StaticDef
3020#[derive(Debug, Clone, Copy)] 2577#[derive(Debug, Clone, Copy)]
3021pub struct StaticDef<'a> { 2578pub struct StaticDefNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3022 syntax: SyntaxNodeRef<'a>, 2579 syntax: SyntaxNode<R>,
3023} 2580}
2581pub type StaticDef<'a> = StaticDefNode<RefRoot<'a>>;
3024 2582
3025impl<'a> AstNode<'a> for StaticDef<'a> { 2583impl<'a> AstNode<'a> for StaticDef<'a> {
3026 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2584 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3032,28 +2590,22 @@ impl<'a> AstNode<'a> for StaticDef<'a> {
3032 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2590 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3033} 2591}
3034 2592
2593impl<R: TreeRoot<RaTypes>> StaticDefNode<R> {
2594 pub fn borrowed(&self) -> StaticDef {
2595 StaticDefNode { syntax: self.syntax.borrowed() }
2596 }
2597 pub fn owned(&self) -> StaticDefNode {
2598 StaticDefNode { syntax: self.syntax.owned() }
2599 }
2600}
2601
2602
3035impl<'a> ast::NameOwner<'a> for StaticDef<'a> {} 2603impl<'a> ast::NameOwner<'a> for StaticDef<'a> {}
3036impl<'a> ast::TypeParamsOwner<'a> for StaticDef<'a> {} 2604impl<'a> ast::TypeParamsOwner<'a> for StaticDef<'a> {}
3037impl<'a> ast::AttrsOwner<'a> for StaticDef<'a> {} 2605impl<'a> ast::AttrsOwner<'a> for StaticDef<'a> {}
3038impl<'a> StaticDef<'a> {} 2606impl<'a> StaticDef<'a> {}
3039 2607
3040// Stmt 2608// Stmt
3041
3042#[derive(Debug, Clone)]
3043pub struct StmtNode(SyntaxNode);
3044
3045impl StmtNode {
3046 pub fn ast(&self) -> Stmt {
3047 Stmt::cast(self.0.borrowed()).unwrap()
3048 }
3049}
3050
3051impl<'a> From<Stmt<'a>> for StmtNode {
3052 fn from(ast: Stmt<'a>) -> StmtNode {
3053 let syntax = ast.syntax().owned();
3054 StmtNode(syntax)
3055 }
3056}
3057#[derive(Debug, Clone, Copy)] 2609#[derive(Debug, Clone, Copy)]
3058pub enum Stmt<'a> { 2610pub enum Stmt<'a> {
3059 ExprStmt(ExprStmt<'a>), 2611 ExprStmt(ExprStmt<'a>),
@@ -3079,26 +2631,11 @@ impl<'a> AstNode<'a> for Stmt<'a> {
3079impl<'a> Stmt<'a> {} 2631impl<'a> Stmt<'a> {}
3080 2632
3081// StructDef 2633// StructDef
3082
3083#[derive(Debug, Clone)]
3084pub struct StructDefNode(SyntaxNode);
3085
3086impl StructDefNode {
3087 pub fn ast(&self) -> StructDef {
3088 StructDef::cast(self.0.borrowed()).unwrap()
3089 }
3090}
3091
3092impl<'a> From<StructDef<'a>> for StructDefNode {
3093 fn from(ast: StructDef<'a>) -> StructDefNode {
3094 let syntax = ast.syntax().owned();
3095 StructDefNode(syntax)
3096 }
3097}
3098#[derive(Debug, Clone, Copy)] 2634#[derive(Debug, Clone, Copy)]
3099pub struct StructDef<'a> { 2635pub struct StructDefNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3100 syntax: SyntaxNodeRef<'a>, 2636 syntax: SyntaxNode<R>,
3101} 2637}
2638pub type StructDef<'a> = StructDefNode<RefRoot<'a>>;
3102 2639
3103impl<'a> AstNode<'a> for StructDef<'a> { 2640impl<'a> AstNode<'a> for StructDef<'a> {
3104 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2641 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3110,6 +2647,16 @@ impl<'a> AstNode<'a> for StructDef<'a> {
3110 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2647 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3111} 2648}
3112 2649
2650impl<R: TreeRoot<RaTypes>> StructDefNode<R> {
2651 pub fn borrowed(&self) -> StructDef {
2652 StructDefNode { syntax: self.syntax.borrowed() }
2653 }
2654 pub fn owned(&self) -> StructDefNode {
2655 StructDefNode { syntax: self.syntax.owned() }
2656 }
2657}
2658
2659
3113impl<'a> ast::NameOwner<'a> for StructDef<'a> {} 2660impl<'a> ast::NameOwner<'a> for StructDef<'a> {}
3114impl<'a> ast::TypeParamsOwner<'a> for StructDef<'a> {} 2661impl<'a> ast::TypeParamsOwner<'a> for StructDef<'a> {}
3115impl<'a> ast::AttrsOwner<'a> for StructDef<'a> {} 2662impl<'a> ast::AttrsOwner<'a> for StructDef<'a> {}
@@ -3120,26 +2667,11 @@ impl<'a> StructDef<'a> {
3120} 2667}
3121 2668
3122// StructLit 2669// StructLit
3123
3124#[derive(Debug, Clone)]
3125pub struct StructLitNode(SyntaxNode);
3126
3127impl StructLitNode {
3128 pub fn ast(&self) -> StructLit {
3129 StructLit::cast(self.0.borrowed()).unwrap()
3130 }
3131}
3132
3133impl<'a> From<StructLit<'a>> for StructLitNode {
3134 fn from(ast: StructLit<'a>) -> StructLitNode {
3135 let syntax = ast.syntax().owned();
3136 StructLitNode(syntax)
3137 }
3138}
3139#[derive(Debug, Clone, Copy)] 2670#[derive(Debug, Clone, Copy)]
3140pub struct StructLit<'a> { 2671pub struct StructLitNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3141 syntax: SyntaxNodeRef<'a>, 2672 syntax: SyntaxNode<R>,
3142} 2673}
2674pub type StructLit<'a> = StructLitNode<RefRoot<'a>>;
3143 2675
3144impl<'a> AstNode<'a> for StructLit<'a> { 2676impl<'a> AstNode<'a> for StructLit<'a> {
3145 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2677 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3151,29 +2683,24 @@ impl<'a> AstNode<'a> for StructLit<'a> {
3151 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2683 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3152} 2684}
3153 2685
3154impl<'a> StructLit<'a> {} 2686impl<R: TreeRoot<RaTypes>> StructLitNode<R> {
3155 2687 pub fn borrowed(&self) -> StructLit {
3156// StructPat 2688 StructLitNode { syntax: self.syntax.borrowed() }
3157
3158#[derive(Debug, Clone)]
3159pub struct StructPatNode(SyntaxNode);
3160
3161impl StructPatNode {
3162 pub fn ast(&self) -> StructPat {
3163 StructPat::cast(self.0.borrowed()).unwrap()
3164 } 2689 }
3165} 2690 pub fn owned(&self) -> StructLitNode {
3166 2691 StructLitNode { syntax: self.syntax.owned() }
3167impl<'a> From<StructPat<'a>> for StructPatNode {
3168 fn from(ast: StructPat<'a>) -> StructPatNode {
3169 let syntax = ast.syntax().owned();
3170 StructPatNode(syntax)
3171 } 2692 }
3172} 2693}
2694
2695
2696impl<'a> StructLit<'a> {}
2697
2698// StructPat
3173#[derive(Debug, Clone, Copy)] 2699#[derive(Debug, Clone, Copy)]
3174pub struct StructPat<'a> { 2700pub struct StructPatNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3175 syntax: SyntaxNodeRef<'a>, 2701 syntax: SyntaxNode<R>,
3176} 2702}
2703pub type StructPat<'a> = StructPatNode<RefRoot<'a>>;
3177 2704
3178impl<'a> AstNode<'a> for StructPat<'a> { 2705impl<'a> AstNode<'a> for StructPat<'a> {
3179 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2706 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3185,29 +2712,24 @@ impl<'a> AstNode<'a> for StructPat<'a> {
3185 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2712 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3186} 2713}
3187 2714
3188impl<'a> StructPat<'a> {} 2715impl<R: TreeRoot<RaTypes>> StructPatNode<R> {
3189 2716 pub fn borrowed(&self) -> StructPat {
3190// TokenTree 2717 StructPatNode { syntax: self.syntax.borrowed() }
3191
3192#[derive(Debug, Clone)]
3193pub struct TokenTreeNode(SyntaxNode);
3194
3195impl TokenTreeNode {
3196 pub fn ast(&self) -> TokenTree {
3197 TokenTree::cast(self.0.borrowed()).unwrap()
3198 } 2718 }
3199} 2719 pub fn owned(&self) -> StructPatNode {
3200 2720 StructPatNode { syntax: self.syntax.owned() }
3201impl<'a> From<TokenTree<'a>> for TokenTreeNode {
3202 fn from(ast: TokenTree<'a>) -> TokenTreeNode {
3203 let syntax = ast.syntax().owned();
3204 TokenTreeNode(syntax)
3205 } 2721 }
3206} 2722}
2723
2724
2725impl<'a> StructPat<'a> {}
2726
2727// TokenTree
3207#[derive(Debug, Clone, Copy)] 2728#[derive(Debug, Clone, Copy)]
3208pub struct TokenTree<'a> { 2729pub struct TokenTreeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3209 syntax: SyntaxNodeRef<'a>, 2730 syntax: SyntaxNode<R>,
3210} 2731}
2732pub type TokenTree<'a> = TokenTreeNode<RefRoot<'a>>;
3211 2733
3212impl<'a> AstNode<'a> for TokenTree<'a> { 2734impl<'a> AstNode<'a> for TokenTree<'a> {
3213 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2735 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3219,29 +2741,24 @@ impl<'a> AstNode<'a> for TokenTree<'a> {
3219 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2741 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3220} 2742}
3221 2743
3222impl<'a> TokenTree<'a> {} 2744impl<R: TreeRoot<RaTypes>> TokenTreeNode<R> {
3223 2745 pub fn borrowed(&self) -> TokenTree {
3224// TraitDef 2746 TokenTreeNode { syntax: self.syntax.borrowed() }
3225
3226#[derive(Debug, Clone)]
3227pub struct TraitDefNode(SyntaxNode);
3228
3229impl TraitDefNode {
3230 pub fn ast(&self) -> TraitDef {
3231 TraitDef::cast(self.0.borrowed()).unwrap()
3232 } 2747 }
3233} 2748 pub fn owned(&self) -> TokenTreeNode {
3234 2749 TokenTreeNode { syntax: self.syntax.owned() }
3235impl<'a> From<TraitDef<'a>> for TraitDefNode {
3236 fn from(ast: TraitDef<'a>) -> TraitDefNode {
3237 let syntax = ast.syntax().owned();
3238 TraitDefNode(syntax)
3239 } 2750 }
3240} 2751}
2752
2753
2754impl<'a> TokenTree<'a> {}
2755
2756// TraitDef
3241#[derive(Debug, Clone, Copy)] 2757#[derive(Debug, Clone, Copy)]
3242pub struct TraitDef<'a> { 2758pub struct TraitDefNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3243 syntax: SyntaxNodeRef<'a>, 2759 syntax: SyntaxNode<R>,
3244} 2760}
2761pub type TraitDef<'a> = TraitDefNode<RefRoot<'a>>;
3245 2762
3246impl<'a> AstNode<'a> for TraitDef<'a> { 2763impl<'a> AstNode<'a> for TraitDef<'a> {
3247 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2764 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3253,31 +2770,26 @@ impl<'a> AstNode<'a> for TraitDef<'a> {
3253 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2770 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3254} 2771}
3255 2772
2773impl<R: TreeRoot<RaTypes>> TraitDefNode<R> {
2774 pub fn borrowed(&self) -> TraitDef {
2775 TraitDefNode { syntax: self.syntax.borrowed() }
2776 }
2777 pub fn owned(&self) -> TraitDefNode {
2778 TraitDefNode { syntax: self.syntax.owned() }
2779 }
2780}
2781
2782
3256impl<'a> ast::NameOwner<'a> for TraitDef<'a> {} 2783impl<'a> ast::NameOwner<'a> for TraitDef<'a> {}
3257impl<'a> ast::AttrsOwner<'a> for TraitDef<'a> {} 2784impl<'a> ast::AttrsOwner<'a> for TraitDef<'a> {}
3258impl<'a> TraitDef<'a> {} 2785impl<'a> TraitDef<'a> {}
3259 2786
3260// TryExpr 2787// TryExpr
3261
3262#[derive(Debug, Clone)]
3263pub struct TryExprNode(SyntaxNode);
3264
3265impl TryExprNode {
3266 pub fn ast(&self) -> TryExpr {
3267 TryExpr::cast(self.0.borrowed()).unwrap()
3268 }
3269}
3270
3271impl<'a> From<TryExpr<'a>> for TryExprNode {
3272 fn from(ast: TryExpr<'a>) -> TryExprNode {
3273 let syntax = ast.syntax().owned();
3274 TryExprNode(syntax)
3275 }
3276}
3277#[derive(Debug, Clone, Copy)] 2788#[derive(Debug, Clone, Copy)]
3278pub struct TryExpr<'a> { 2789pub struct TryExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3279 syntax: SyntaxNodeRef<'a>, 2790 syntax: SyntaxNode<R>,
3280} 2791}
2792pub type TryExpr<'a> = TryExprNode<RefRoot<'a>>;
3281 2793
3282impl<'a> AstNode<'a> for TryExpr<'a> { 2794impl<'a> AstNode<'a> for TryExpr<'a> {
3283 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2795 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3289,29 +2801,24 @@ impl<'a> AstNode<'a> for TryExpr<'a> {
3289 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2801 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3290} 2802}
3291 2803
3292impl<'a> TryExpr<'a> {} 2804impl<R: TreeRoot<RaTypes>> TryExprNode<R> {
3293 2805 pub fn borrowed(&self) -> TryExpr {
3294// TupleExpr 2806 TryExprNode { syntax: self.syntax.borrowed() }
3295
3296#[derive(Debug, Clone)]
3297pub struct TupleExprNode(SyntaxNode);
3298
3299impl TupleExprNode {
3300 pub fn ast(&self) -> TupleExpr {
3301 TupleExpr::cast(self.0.borrowed()).unwrap()
3302 } 2807 }
3303} 2808 pub fn owned(&self) -> TryExprNode {
3304 2809 TryExprNode { syntax: self.syntax.owned() }
3305impl<'a> From<TupleExpr<'a>> for TupleExprNode {
3306 fn from(ast: TupleExpr<'a>) -> TupleExprNode {
3307 let syntax = ast.syntax().owned();
3308 TupleExprNode(syntax)
3309 } 2810 }
3310} 2811}
2812
2813
2814impl<'a> TryExpr<'a> {}
2815
2816// TupleExpr
3311#[derive(Debug, Clone, Copy)] 2817#[derive(Debug, Clone, Copy)]
3312pub struct TupleExpr<'a> { 2818pub struct TupleExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3313 syntax: SyntaxNodeRef<'a>, 2819 syntax: SyntaxNode<R>,
3314} 2820}
2821pub type TupleExpr<'a> = TupleExprNode<RefRoot<'a>>;
3315 2822
3316impl<'a> AstNode<'a> for TupleExpr<'a> { 2823impl<'a> AstNode<'a> for TupleExpr<'a> {
3317 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2824 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3323,29 +2830,24 @@ impl<'a> AstNode<'a> for TupleExpr<'a> {
3323 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2830 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3324} 2831}
3325 2832
3326impl<'a> TupleExpr<'a> {} 2833impl<R: TreeRoot<RaTypes>> TupleExprNode<R> {
3327 2834 pub fn borrowed(&self) -> TupleExpr {
3328// TuplePat 2835 TupleExprNode { syntax: self.syntax.borrowed() }
3329
3330#[derive(Debug, Clone)]
3331pub struct TuplePatNode(SyntaxNode);
3332
3333impl TuplePatNode {
3334 pub fn ast(&self) -> TuplePat {
3335 TuplePat::cast(self.0.borrowed()).unwrap()
3336 } 2836 }
3337} 2837 pub fn owned(&self) -> TupleExprNode {
3338 2838 TupleExprNode { syntax: self.syntax.owned() }
3339impl<'a> From<TuplePat<'a>> for TuplePatNode {
3340 fn from(ast: TuplePat<'a>) -> TuplePatNode {
3341 let syntax = ast.syntax().owned();
3342 TuplePatNode(syntax)
3343 } 2839 }
3344} 2840}
2841
2842
2843impl<'a> TupleExpr<'a> {}
2844
2845// TuplePat
3345#[derive(Debug, Clone, Copy)] 2846#[derive(Debug, Clone, Copy)]
3346pub struct TuplePat<'a> { 2847pub struct TuplePatNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3347 syntax: SyntaxNodeRef<'a>, 2848 syntax: SyntaxNode<R>,
3348} 2849}
2850pub type TuplePat<'a> = TuplePatNode<RefRoot<'a>>;
3349 2851
3350impl<'a> AstNode<'a> for TuplePat<'a> { 2852impl<'a> AstNode<'a> for TuplePat<'a> {
3351 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2853 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3357,29 +2859,24 @@ impl<'a> AstNode<'a> for TuplePat<'a> {
3357 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2859 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3358} 2860}
3359 2861
3360impl<'a> TuplePat<'a> {} 2862impl<R: TreeRoot<RaTypes>> TuplePatNode<R> {
3361 2863 pub fn borrowed(&self) -> TuplePat {
3362// TupleStructPat 2864 TuplePatNode { syntax: self.syntax.borrowed() }
3363
3364#[derive(Debug, Clone)]
3365pub struct TupleStructPatNode(SyntaxNode);
3366
3367impl TupleStructPatNode {
3368 pub fn ast(&self) -> TupleStructPat {
3369 TupleStructPat::cast(self.0.borrowed()).unwrap()
3370 } 2865 }
3371} 2866 pub fn owned(&self) -> TuplePatNode {
3372 2867 TuplePatNode { syntax: self.syntax.owned() }
3373impl<'a> From<TupleStructPat<'a>> for TupleStructPatNode {
3374 fn from(ast: TupleStructPat<'a>) -> TupleStructPatNode {
3375 let syntax = ast.syntax().owned();
3376 TupleStructPatNode(syntax)
3377 } 2868 }
3378} 2869}
2870
2871
2872impl<'a> TuplePat<'a> {}
2873
2874// TupleStructPat
3379#[derive(Debug, Clone, Copy)] 2875#[derive(Debug, Clone, Copy)]
3380pub struct TupleStructPat<'a> { 2876pub struct TupleStructPatNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3381 syntax: SyntaxNodeRef<'a>, 2877 syntax: SyntaxNode<R>,
3382} 2878}
2879pub type TupleStructPat<'a> = TupleStructPatNode<RefRoot<'a>>;
3383 2880
3384impl<'a> AstNode<'a> for TupleStructPat<'a> { 2881impl<'a> AstNode<'a> for TupleStructPat<'a> {
3385 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2882 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3391,29 +2888,24 @@ impl<'a> AstNode<'a> for TupleStructPat<'a> {
3391 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2888 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3392} 2889}
3393 2890
3394impl<'a> TupleStructPat<'a> {} 2891impl<R: TreeRoot<RaTypes>> TupleStructPatNode<R> {
3395 2892 pub fn borrowed(&self) -> TupleStructPat {
3396// TupleType 2893 TupleStructPatNode { syntax: self.syntax.borrowed() }
3397
3398#[derive(Debug, Clone)]
3399pub struct TupleTypeNode(SyntaxNode);
3400
3401impl TupleTypeNode {
3402 pub fn ast(&self) -> TupleType {
3403 TupleType::cast(self.0.borrowed()).unwrap()
3404 } 2894 }
3405} 2895 pub fn owned(&self) -> TupleStructPatNode {
3406 2896 TupleStructPatNode { syntax: self.syntax.owned() }
3407impl<'a> From<TupleType<'a>> for TupleTypeNode {
3408 fn from(ast: TupleType<'a>) -> TupleTypeNode {
3409 let syntax = ast.syntax().owned();
3410 TupleTypeNode(syntax)
3411 } 2897 }
3412} 2898}
2899
2900
2901impl<'a> TupleStructPat<'a> {}
2902
2903// TupleType
3413#[derive(Debug, Clone, Copy)] 2904#[derive(Debug, Clone, Copy)]
3414pub struct TupleType<'a> { 2905pub struct TupleTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3415 syntax: SyntaxNodeRef<'a>, 2906 syntax: SyntaxNode<R>,
3416} 2907}
2908pub type TupleType<'a> = TupleTypeNode<RefRoot<'a>>;
3417 2909
3418impl<'a> AstNode<'a> for TupleType<'a> { 2910impl<'a> AstNode<'a> for TupleType<'a> {
3419 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2911 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3425,29 +2917,24 @@ impl<'a> AstNode<'a> for TupleType<'a> {
3425 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2917 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3426} 2918}
3427 2919
3428impl<'a> TupleType<'a> {} 2920impl<R: TreeRoot<RaTypes>> TupleTypeNode<R> {
3429 2921 pub fn borrowed(&self) -> TupleType {
3430// TypeDef 2922 TupleTypeNode { syntax: self.syntax.borrowed() }
3431
3432#[derive(Debug, Clone)]
3433pub struct TypeDefNode(SyntaxNode);
3434
3435impl TypeDefNode {
3436 pub fn ast(&self) -> TypeDef {
3437 TypeDef::cast(self.0.borrowed()).unwrap()
3438 } 2923 }
3439} 2924 pub fn owned(&self) -> TupleTypeNode {
3440 2925 TupleTypeNode { syntax: self.syntax.owned() }
3441impl<'a> From<TypeDef<'a>> for TypeDefNode {
3442 fn from(ast: TypeDef<'a>) -> TypeDefNode {
3443 let syntax = ast.syntax().owned();
3444 TypeDefNode(syntax)
3445 } 2926 }
3446} 2927}
2928
2929
2930impl<'a> TupleType<'a> {}
2931
2932// TypeDef
3447#[derive(Debug, Clone, Copy)] 2933#[derive(Debug, Clone, Copy)]
3448pub struct TypeDef<'a> { 2934pub struct TypeDefNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3449 syntax: SyntaxNodeRef<'a>, 2935 syntax: SyntaxNode<R>,
3450} 2936}
2937pub type TypeDef<'a> = TypeDefNode<RefRoot<'a>>;
3451 2938
3452impl<'a> AstNode<'a> for TypeDef<'a> { 2939impl<'a> AstNode<'a> for TypeDef<'a> {
3453 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2940 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3459,32 +2946,27 @@ impl<'a> AstNode<'a> for TypeDef<'a> {
3459 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2946 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3460} 2947}
3461 2948
2949impl<R: TreeRoot<RaTypes>> TypeDefNode<R> {
2950 pub fn borrowed(&self) -> TypeDef {
2951 TypeDefNode { syntax: self.syntax.borrowed() }
2952 }
2953 pub fn owned(&self) -> TypeDefNode {
2954 TypeDefNode { syntax: self.syntax.owned() }
2955 }
2956}
2957
2958
3462impl<'a> ast::NameOwner<'a> for TypeDef<'a> {} 2959impl<'a> ast::NameOwner<'a> for TypeDef<'a> {}
3463impl<'a> ast::TypeParamsOwner<'a> for TypeDef<'a> {} 2960impl<'a> ast::TypeParamsOwner<'a> for TypeDef<'a> {}
3464impl<'a> ast::AttrsOwner<'a> for TypeDef<'a> {} 2961impl<'a> ast::AttrsOwner<'a> for TypeDef<'a> {}
3465impl<'a> TypeDef<'a> {} 2962impl<'a> TypeDef<'a> {}
3466 2963
3467// TypeParam 2964// TypeParam
3468
3469#[derive(Debug, Clone)]
3470pub struct TypeParamNode(SyntaxNode);
3471
3472impl TypeParamNode {
3473 pub fn ast(&self) -> TypeParam {
3474 TypeParam::cast(self.0.borrowed()).unwrap()
3475 }
3476}
3477
3478impl<'a> From<TypeParam<'a>> for TypeParamNode {
3479 fn from(ast: TypeParam<'a>) -> TypeParamNode {
3480 let syntax = ast.syntax().owned();
3481 TypeParamNode(syntax)
3482 }
3483}
3484#[derive(Debug, Clone, Copy)] 2965#[derive(Debug, Clone, Copy)]
3485pub struct TypeParam<'a> { 2966pub struct TypeParamNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3486 syntax: SyntaxNodeRef<'a>, 2967 syntax: SyntaxNode<R>,
3487} 2968}
2969pub type TypeParam<'a> = TypeParamNode<RefRoot<'a>>;
3488 2970
3489impl<'a> AstNode<'a> for TypeParam<'a> { 2971impl<'a> AstNode<'a> for TypeParam<'a> {
3490 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2972 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3496,30 +2978,25 @@ impl<'a> AstNode<'a> for TypeParam<'a> {
3496 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2978 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3497} 2979}
3498 2980
2981impl<R: TreeRoot<RaTypes>> TypeParamNode<R> {
2982 pub fn borrowed(&self) -> TypeParam {
2983 TypeParamNode { syntax: self.syntax.borrowed() }
2984 }
2985 pub fn owned(&self) -> TypeParamNode {
2986 TypeParamNode { syntax: self.syntax.owned() }
2987 }
2988}
2989
2990
3499impl<'a> ast::NameOwner<'a> for TypeParam<'a> {} 2991impl<'a> ast::NameOwner<'a> for TypeParam<'a> {}
3500impl<'a> TypeParam<'a> {} 2992impl<'a> TypeParam<'a> {}
3501 2993
3502// TypeParamList 2994// TypeParamList
3503
3504#[derive(Debug, Clone)]
3505pub struct TypeParamListNode(SyntaxNode);
3506
3507impl TypeParamListNode {
3508 pub fn ast(&self) -> TypeParamList {
3509 TypeParamList::cast(self.0.borrowed()).unwrap()
3510 }
3511}
3512
3513impl<'a> From<TypeParamList<'a>> for TypeParamListNode {
3514 fn from(ast: TypeParamList<'a>) -> TypeParamListNode {
3515 let syntax = ast.syntax().owned();
3516 TypeParamListNode(syntax)
3517 }
3518}
3519#[derive(Debug, Clone, Copy)] 2995#[derive(Debug, Clone, Copy)]
3520pub struct TypeParamList<'a> { 2996pub struct TypeParamListNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3521 syntax: SyntaxNodeRef<'a>, 2997 syntax: SyntaxNode<R>,
3522} 2998}
2999pub type TypeParamList<'a> = TypeParamListNode<RefRoot<'a>>;
3523 3000
3524impl<'a> AstNode<'a> for TypeParamList<'a> { 3001impl<'a> AstNode<'a> for TypeParamList<'a> {
3525 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 3002 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3531,6 +3008,16 @@ impl<'a> AstNode<'a> for TypeParamList<'a> {
3531 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 3008 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3532} 3009}
3533 3010
3011impl<R: TreeRoot<RaTypes>> TypeParamListNode<R> {
3012 pub fn borrowed(&self) -> TypeParamList {
3013 TypeParamListNode { syntax: self.syntax.borrowed() }
3014 }
3015 pub fn owned(&self) -> TypeParamListNode {
3016 TypeParamListNode { syntax: self.syntax.owned() }
3017 }
3018}
3019
3020
3534impl<'a> TypeParamList<'a> { 3021impl<'a> TypeParamList<'a> {
3535 pub fn type_params(self) -> impl Iterator<Item = TypeParam<'a>> + 'a { 3022 pub fn type_params(self) -> impl Iterator<Item = TypeParam<'a>> + 'a {
3536 super::children(self) 3023 super::children(self)
@@ -3542,22 +3029,6 @@ impl<'a> TypeParamList<'a> {
3542} 3029}
3543 3030
3544// TypeRef 3031// TypeRef
3545
3546#[derive(Debug, Clone)]
3547pub struct TypeRefNode(SyntaxNode);
3548
3549impl TypeRefNode {
3550 pub fn ast(&self) -> TypeRef {
3551 TypeRef::cast(self.0.borrowed()).unwrap()
3552 }
3553}
3554
3555impl<'a> From<TypeRef<'a>> for TypeRefNode {
3556 fn from(ast: TypeRef<'a>) -> TypeRefNode {
3557 let syntax = ast.syntax().owned();
3558 TypeRefNode(syntax)
3559 }
3560}
3561#[derive(Debug, Clone, Copy)] 3032#[derive(Debug, Clone, Copy)]
3562pub enum TypeRef<'a> { 3033pub enum TypeRef<'a> {
3563 ParenType(ParenType<'a>), 3034 ParenType(ParenType<'a>),
@@ -3616,26 +3087,11 @@ impl<'a> AstNode<'a> for TypeRef<'a> {
3616impl<'a> TypeRef<'a> {} 3087impl<'a> TypeRef<'a> {}
3617 3088
3618// UseItem 3089// UseItem
3619
3620#[derive(Debug, Clone)]
3621pub struct UseItemNode(SyntaxNode);
3622
3623impl UseItemNode {
3624 pub fn ast(&self) -> UseItem {
3625 UseItem::cast(self.0.borrowed()).unwrap()
3626 }
3627}
3628
3629impl<'a> From<UseItem<'a>> for UseItemNode {
3630 fn from(ast: UseItem<'a>) -> UseItemNode {
3631 let syntax = ast.syntax().owned();
3632 UseItemNode(syntax)
3633 }
3634}
3635#[derive(Debug, Clone, Copy)] 3090#[derive(Debug, Clone, Copy)]
3636pub struct UseItem<'a> { 3091pub struct UseItemNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3637 syntax: SyntaxNodeRef<'a>, 3092 syntax: SyntaxNode<R>,
3638} 3093}
3094pub type UseItem<'a> = UseItemNode<RefRoot<'a>>;
3639 3095
3640impl<'a> AstNode<'a> for UseItem<'a> { 3096impl<'a> AstNode<'a> for UseItem<'a> {
3641 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 3097 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3647,33 +3103,28 @@ impl<'a> AstNode<'a> for UseItem<'a> {
3647 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 3103 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3648} 3104}
3649 3105
3650impl<'a> UseItem<'a> { 3106impl<R: TreeRoot<RaTypes>> UseItemNode<R> {
3651 pub fn use_tree(self) -> Option<UseTree<'a>> { 3107 pub fn borrowed(&self) -> UseItem {
3652 super::child_opt(self) 3108 UseItemNode { syntax: self.syntax.borrowed() }
3109 }
3110 pub fn owned(&self) -> UseItemNode {
3111 UseItemNode { syntax: self.syntax.owned() }
3653 } 3112 }
3654} 3113}
3655 3114
3656// UseTree
3657 3115
3658#[derive(Debug, Clone)] 3116impl<'a> UseItem<'a> {
3659pub struct UseTreeNode(SyntaxNode); 3117 pub fn use_tree(self) -> Option<UseTree<'a>> {
3660 3118 super::child_opt(self)
3661impl UseTreeNode {
3662 pub fn ast(&self) -> UseTree {
3663 UseTree::cast(self.0.borrowed()).unwrap()
3664 } 3119 }
3665} 3120}
3666 3121
3667impl<'a> From<UseTree<'a>> for UseTreeNode { 3122// UseTree
3668 fn from(ast: UseTree<'a>) -> UseTreeNode {
3669 let syntax = ast.syntax().owned();
3670 UseTreeNode(syntax)
3671 }
3672}
3673#[derive(Debug, Clone, Copy)] 3123#[derive(Debug, Clone, Copy)]
3674pub struct UseTree<'a> { 3124pub struct UseTreeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3675 syntax: SyntaxNodeRef<'a>, 3125 syntax: SyntaxNode<R>,
3676} 3126}
3127pub type UseTree<'a> = UseTreeNode<RefRoot<'a>>;
3677 3128
3678impl<'a> AstNode<'a> for UseTree<'a> { 3129impl<'a> AstNode<'a> for UseTree<'a> {
3679 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 3130 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3685,6 +3136,16 @@ impl<'a> AstNode<'a> for UseTree<'a> {
3685 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 3136 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3686} 3137}
3687 3138
3139impl<R: TreeRoot<RaTypes>> UseTreeNode<R> {
3140 pub fn borrowed(&self) -> UseTree {
3141 UseTreeNode { syntax: self.syntax.borrowed() }
3142 }
3143 pub fn owned(&self) -> UseTreeNode {
3144 UseTreeNode { syntax: self.syntax.owned() }
3145 }
3146}
3147
3148
3688impl<'a> UseTree<'a> { 3149impl<'a> UseTree<'a> {
3689 pub fn path(self) -> Option<Path<'a>> { 3150 pub fn path(self) -> Option<Path<'a>> {
3690 super::child_opt(self) 3151 super::child_opt(self)
@@ -3696,26 +3157,11 @@ impl<'a> UseTree<'a> {
3696} 3157}
3697 3158
3698// UseTreeList 3159// UseTreeList
3699
3700#[derive(Debug, Clone)]
3701pub struct UseTreeListNode(SyntaxNode);
3702
3703impl UseTreeListNode {
3704 pub fn ast(&self) -> UseTreeList {
3705 UseTreeList::cast(self.0.borrowed()).unwrap()
3706 }
3707}
3708
3709impl<'a> From<UseTreeList<'a>> for UseTreeListNode {
3710 fn from(ast: UseTreeList<'a>) -> UseTreeListNode {
3711 let syntax = ast.syntax().owned();
3712 UseTreeListNode(syntax)
3713 }
3714}
3715#[derive(Debug, Clone, Copy)] 3160#[derive(Debug, Clone, Copy)]
3716pub struct UseTreeList<'a> { 3161pub struct UseTreeListNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3717 syntax: SyntaxNodeRef<'a>, 3162 syntax: SyntaxNode<R>,
3718} 3163}
3164pub type UseTreeList<'a> = UseTreeListNode<RefRoot<'a>>;
3719 3165
3720impl<'a> AstNode<'a> for UseTreeList<'a> { 3166impl<'a> AstNode<'a> for UseTreeList<'a> {
3721 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 3167 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3727,33 +3173,28 @@ impl<'a> AstNode<'a> for UseTreeList<'a> {
3727 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 3173 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3728} 3174}
3729 3175
3730impl<'a> UseTreeList<'a> { 3176impl<R: TreeRoot<RaTypes>> UseTreeListNode<R> {
3731 pub fn use_trees(self) -> impl Iterator<Item = UseTree<'a>> + 'a { 3177 pub fn borrowed(&self) -> UseTreeList {
3732 super::children(self) 3178 UseTreeListNode { syntax: self.syntax.borrowed() }
3179 }
3180 pub fn owned(&self) -> UseTreeListNode {
3181 UseTreeListNode { syntax: self.syntax.owned() }
3733 } 3182 }
3734} 3183}
3735 3184
3736// WhereClause
3737 3185
3738#[derive(Debug, Clone)] 3186impl<'a> UseTreeList<'a> {
3739pub struct WhereClauseNode(SyntaxNode); 3187 pub fn use_trees(self) -> impl Iterator<Item = UseTree<'a>> + 'a {
3740 3188 super::children(self)
3741impl WhereClauseNode {
3742 pub fn ast(&self) -> WhereClause {
3743 WhereClause::cast(self.0.borrowed()).unwrap()
3744 } 3189 }
3745} 3190}
3746 3191
3747impl<'a> From<WhereClause<'a>> for WhereClauseNode { 3192// WhereClause
3748 fn from(ast: WhereClause<'a>) -> WhereClauseNode {
3749 let syntax = ast.syntax().owned();
3750 WhereClauseNode(syntax)
3751 }
3752}
3753#[derive(Debug, Clone, Copy)] 3193#[derive(Debug, Clone, Copy)]
3754pub struct WhereClause<'a> { 3194pub struct WhereClauseNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3755 syntax: SyntaxNodeRef<'a>, 3195 syntax: SyntaxNode<R>,
3756} 3196}
3197pub type WhereClause<'a> = WhereClauseNode<RefRoot<'a>>;
3757 3198
3758impl<'a> AstNode<'a> for WhereClause<'a> { 3199impl<'a> AstNode<'a> for WhereClause<'a> {
3759 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 3200 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3765,29 +3206,24 @@ impl<'a> AstNode<'a> for WhereClause<'a> {
3765 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 3206 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3766} 3207}
3767 3208
3768impl<'a> WhereClause<'a> {} 3209impl<R: TreeRoot<RaTypes>> WhereClauseNode<R> {
3769 3210 pub fn borrowed(&self) -> WhereClause {
3770// WhileExpr 3211 WhereClauseNode { syntax: self.syntax.borrowed() }
3771
3772#[derive(Debug, Clone)]
3773pub struct WhileExprNode(SyntaxNode);
3774
3775impl WhileExprNode {
3776 pub fn ast(&self) -> WhileExpr {
3777 WhileExpr::cast(self.0.borrowed()).unwrap()
3778 } 3212 }
3779} 3213 pub fn owned(&self) -> WhereClauseNode {
3780 3214 WhereClauseNode { syntax: self.syntax.owned() }
3781impl<'a> From<WhileExpr<'a>> for WhileExprNode {
3782 fn from(ast: WhileExpr<'a>) -> WhileExprNode {
3783 let syntax = ast.syntax().owned();
3784 WhileExprNode(syntax)
3785 } 3215 }
3786} 3216}
3217
3218
3219impl<'a> WhereClause<'a> {}
3220
3221// WhileExpr
3787#[derive(Debug, Clone, Copy)] 3222#[derive(Debug, Clone, Copy)]
3788pub struct WhileExpr<'a> { 3223pub struct WhileExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3789 syntax: SyntaxNodeRef<'a>, 3224 syntax: SyntaxNode<R>,
3790} 3225}
3226pub type WhileExpr<'a> = WhileExprNode<RefRoot<'a>>;
3791 3227
3792impl<'a> AstNode<'a> for WhileExpr<'a> { 3228impl<'a> AstNode<'a> for WhileExpr<'a> {
3793 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 3229 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3799,6 +3235,16 @@ impl<'a> AstNode<'a> for WhileExpr<'a> {
3799 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 3235 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3800} 3236}
3801 3237
3238impl<R: TreeRoot<RaTypes>> WhileExprNode<R> {
3239 pub fn borrowed(&self) -> WhileExpr {
3240 WhileExprNode { syntax: self.syntax.borrowed() }
3241 }
3242 pub fn owned(&self) -> WhileExprNode {
3243 WhileExprNode { syntax: self.syntax.owned() }
3244 }
3245}
3246
3247
3802impl<'a> ast::LoopBodyOwner<'a> for WhileExpr<'a> {} 3248impl<'a> ast::LoopBodyOwner<'a> for WhileExpr<'a> {}
3803impl<'a> WhileExpr<'a> { 3249impl<'a> WhileExpr<'a> {
3804 pub fn condition(self) -> Option<Condition<'a>> { 3250 pub fn condition(self) -> Option<Condition<'a>> {
@@ -3807,26 +3253,11 @@ impl<'a> WhileExpr<'a> {
3807} 3253}
3808 3254
3809// Whitespace 3255// Whitespace
3810
3811#[derive(Debug, Clone)]
3812pub struct WhitespaceNode(SyntaxNode);
3813
3814impl WhitespaceNode {
3815 pub fn ast(&self) -> Whitespace {
3816 Whitespace::cast(self.0.borrowed()).unwrap()
3817 }
3818}
3819
3820impl<'a> From<Whitespace<'a>> for WhitespaceNode {
3821 fn from(ast: Whitespace<'a>) -> WhitespaceNode {
3822 let syntax = ast.syntax().owned();
3823 WhitespaceNode(syntax)
3824 }
3825}
3826#[derive(Debug, Clone, Copy)] 3256#[derive(Debug, Clone, Copy)]
3827pub struct Whitespace<'a> { 3257pub struct WhitespaceNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3828 syntax: SyntaxNodeRef<'a>, 3258 syntax: SyntaxNode<R>,
3829} 3259}
3260pub type Whitespace<'a> = WhitespaceNode<RefRoot<'a>>;
3830 3261
3831impl<'a> AstNode<'a> for Whitespace<'a> { 3262impl<'a> AstNode<'a> for Whitespace<'a> {
3832 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 3263 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3838,5 +3269,15 @@ impl<'a> AstNode<'a> for Whitespace<'a> {
3838 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 3269 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3839} 3270}
3840 3271
3272impl<R: TreeRoot<RaTypes>> WhitespaceNode<R> {
3273 pub fn borrowed(&self) -> Whitespace {
3274 WhitespaceNode { syntax: self.syntax.borrowed() }
3275 }
3276 pub fn owned(&self) -> WhitespaceNode {
3277 WhitespaceNode { syntax: self.syntax.owned() }
3278 }
3279}
3280
3281
3841impl<'a> Whitespace<'a> {} 3282impl<'a> Whitespace<'a> {}
3842 3283
diff --git a/crates/ra_syntax/src/ast/generated.rs.tera b/crates/ra_syntax/src/ast/generated.rs.tera
index 1321f0def..d4fc6b5bd 100644
--- a/crates/ra_syntax/src/ast/generated.rs.tera
+++ b/crates/ra_syntax/src/ast/generated.rs.tera
@@ -3,32 +3,23 @@ the below applies to the result of this template
3#}// This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-syntax` is run 3#}// This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-syntax` is run
4// Do not edit manually 4// Do not edit manually
5 5
6//! This module contains auto-generated Rust AST. Like `SyntaxNode`s, AST nodes
7//! are generic over ownership: `X<'a>` things are `Copy` references, `XNode`
8//! are Arc-based. You can switch between the two variants using `.owned` and
9//! `.borrowed` functions. Most of the code works with borowed mode, and only
10//! this mode has all AST accessors.
11
6#![cfg_attr(rustfmt, rustfmt_skip)] 12#![cfg_attr(rustfmt, rustfmt_skip)]
7 13
8use crate::{ 14use crate::{
9 ast, 15 ast,
10 SyntaxNode, SyntaxNodeRef, AstNode, 16 SyntaxNode, SyntaxNodeRef, AstNode,
17 yellow::{TreeRoot, RaTypes, OwnedRoot, RefRoot},
11 SyntaxKind::*, 18 SyntaxKind::*,
12}; 19};
13{% for node, methods in ast %} 20{% for node, methods in ast %}
14// {{ node }} 21// {{ node }}
15 22
16#[derive(Debug, Clone)]
17pub struct {{ node }}Node(SyntaxNode);
18
19impl {{ node }}Node {
20 pub fn ast(&self) -> {{ node }} {
21 {{ node }}::cast(self.0.borrowed()).unwrap()
22 }
23}
24
25impl<'a> From<{{ node }}<'a>> for {{ node }}Node {
26 fn from(ast: {{ node}}<'a>) -> {{ node }}Node {
27 let syntax = ast.syntax().owned();
28 {{ node }}Node(syntax)
29 }
30}
31
32{%- if methods.enum %} 23{%- if methods.enum %}
33#[derive(Debug, Clone, Copy)] 24#[derive(Debug, Clone, Copy)]
34pub enum {{ node }}<'a> { 25pub enum {{ node }}<'a> {
@@ -56,9 +47,10 @@ impl<'a> AstNode<'a> for {{ node }}<'a> {
56} 47}
57{% else %} 48{% else %}
58#[derive(Debug, Clone, Copy)] 49#[derive(Debug, Clone, Copy)]
59pub struct {{ node }}<'a> { 50pub struct {{ node }}Node<R: TreeRoot<RaTypes> = OwnedRoot> {
60 syntax: SyntaxNodeRef<'a>, 51 syntax: SyntaxNode<R>,
61} 52}
53pub type {{ node }}<'a> = {{ node }}Node<RefRoot<'a>>;
62 54
63impl<'a> AstNode<'a> for {{ node }}<'a> { 55impl<'a> AstNode<'a> for {{ node }}<'a> {
64 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 56 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -69,6 +61,16 @@ impl<'a> AstNode<'a> for {{ node }}<'a> {
69 } 61 }
70 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 62 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
71} 63}
64
65impl<R: TreeRoot<RaTypes>> {{ node }}Node<R> {
66 pub fn borrowed(&self) -> {{ node }} {
67 {{ node }}Node { syntax: self.syntax.borrowed() }
68 }
69 pub fn owned(&self) -> {{ node }}Node {
70 {{ node }}Node { syntax: self.syntax.owned() }
71 }
72}
73
72{% endif %} 74{% endif %}
73{% if methods.traits -%} 75{% if methods.traits -%}
74{%- for t in methods.traits -%} 76{%- for t in methods.traits -%}
diff --git a/crates/ra_syntax/src/ast/mod.rs b/crates/ra_syntax/src/ast/mod.rs
index 4355531d0..d93f92672 100644
--- a/crates/ra_syntax/src/ast/mod.rs
+++ b/crates/ra_syntax/src/ast/mod.rs
@@ -12,6 +12,10 @@ use crate::{
12 SyntaxNodeRef, 12 SyntaxNodeRef,
13}; 13};
14 14
15/// The main trait to go from untyped `SyntaxNode` to a typed ast. The
16/// conversion itself has zero runtime cost: ast and syntax nodes have exactly
17/// the same representation: a pointer to the tree root and a pointer to the
18/// node itself.
15pub trait AstNode<'a>: Clone + Copy + 'a { 19pub trait AstNode<'a>: Clone + Copy + 'a {
16 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> 20 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self>
17 where 21 where