aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/ast/generated.rs3011
-rw-r--r--crates/ra_syntax/src/ast/generated.rs.tera32
2 files changed, 1237 insertions, 1806 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index 75769a4e9..d473478a9 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -6,30 +6,16 @@
6use crate::{ 6use crate::{
7 ast, 7 ast,
8 SyntaxNode, SyntaxNodeRef, AstNode, 8 SyntaxNode, SyntaxNodeRef, AstNode,
9 yellow::{TreeRoot, RaTypes, OwnedRoot, RefRoot},
9 SyntaxKind::*, 10 SyntaxKind::*,
10}; 11};
11 12
12// ArgList 13// 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)] 14#[derive(Debug, Clone, Copy)]
30pub struct ArgList<'a> { 15pub struct ArgListNode<R: TreeRoot<RaTypes> = OwnedRoot> {
31 syntax: SyntaxNodeRef<'a>, 16 syntax: SyntaxNode<R>,
32} 17}
18pub type ArgList<'a> = ArgListNode<RefRoot<'a>>;
33 19
34impl<'a> AstNode<'a> for ArgList<'a> { 20impl<'a> AstNode<'a> for ArgList<'a> {
35 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 21 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -41,33 +27,28 @@ impl<'a> AstNode<'a> for ArgList<'a> {
41 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 27 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
42} 28}
43 29
44impl<'a> ArgList<'a> { 30impl<R: TreeRoot<RaTypes>> ArgListNode<R> {
45 pub fn args(self) -> impl Iterator<Item = Expr<'a>> + 'a { 31 pub fn borrowed(&self) -> ArgList {
46 super::children(self) 32 ArgListNode { syntax: self.syntax.borrowed() }
33 }
34 pub fn owned(&self) -> ArgListNode {
35 ArgListNode { syntax: self.syntax.owned() }
47 } 36 }
48} 37}
49 38
50// ArrayExpr
51
52#[derive(Debug, Clone)]
53pub struct ArrayExprNode(SyntaxNode);
54 39
55impl ArrayExprNode { 40impl<'a> ArgList<'a> {
56 pub fn ast(&self) -> ArrayExpr { 41 pub fn args(self) -> impl Iterator<Item = Expr<'a>> + 'a {
57 ArrayExpr::cast(self.0.borrowed()).unwrap() 42 super::children(self)
58 } 43 }
59} 44}
60 45
61impl<'a> From<ArrayExpr<'a>> for ArrayExprNode { 46// ArrayExpr
62 fn from(ast: ArrayExpr<'a>) -> ArrayExprNode {
63 let syntax = ast.syntax().owned();
64 ArrayExprNode(syntax)
65 }
66}
67#[derive(Debug, Clone, Copy)] 47#[derive(Debug, Clone, Copy)]
68pub struct ArrayExpr<'a> { 48pub struct ArrayExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
69 syntax: SyntaxNodeRef<'a>, 49 syntax: SyntaxNode<R>,
70} 50}
51pub type ArrayExpr<'a> = ArrayExprNode<RefRoot<'a>>;
71 52
72impl<'a> AstNode<'a> for ArrayExpr<'a> { 53impl<'a> AstNode<'a> for ArrayExpr<'a> {
73 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 54 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -79,29 +60,24 @@ impl<'a> AstNode<'a> for ArrayExpr<'a> {
79 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 60 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
80} 61}
81 62
82impl<'a> ArrayExpr<'a> {} 63impl<R: TreeRoot<RaTypes>> ArrayExprNode<R> {
83 64 pub fn borrowed(&self) -> ArrayExpr {
84// ArrayType 65 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 } 66 }
93} 67 pub fn owned(&self) -> ArrayExprNode {
94 68 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 } 69 }
100} 70}
71
72
73impl<'a> ArrayExpr<'a> {}
74
75// ArrayType
101#[derive(Debug, Clone, Copy)] 76#[derive(Debug, Clone, Copy)]
102pub struct ArrayType<'a> { 77pub struct ArrayTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
103 syntax: SyntaxNodeRef<'a>, 78 syntax: SyntaxNode<R>,
104} 79}
80pub type ArrayType<'a> = ArrayTypeNode<RefRoot<'a>>;
105 81
106impl<'a> AstNode<'a> for ArrayType<'a> { 82impl<'a> AstNode<'a> for ArrayType<'a> {
107 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 83 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -113,29 +89,24 @@ impl<'a> AstNode<'a> for ArrayType<'a> {
113 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 89 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
114} 90}
115 91
116impl<'a> ArrayType<'a> {} 92impl<R: TreeRoot<RaTypes>> ArrayTypeNode<R> {
117 93 pub fn borrowed(&self) -> ArrayType {
118// Attr 94 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 } 95 }
127} 96 pub fn owned(&self) -> ArrayTypeNode {
128 97 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 } 98 }
134} 99}
100
101
102impl<'a> ArrayType<'a> {}
103
104// Attr
135#[derive(Debug, Clone, Copy)] 105#[derive(Debug, Clone, Copy)]
136pub struct Attr<'a> { 106pub struct AttrNode<R: TreeRoot<RaTypes> = OwnedRoot> {
137 syntax: SyntaxNodeRef<'a>, 107 syntax: SyntaxNode<R>,
138} 108}
109pub type Attr<'a> = AttrNode<RefRoot<'a>>;
139 110
140impl<'a> AstNode<'a> for Attr<'a> { 111impl<'a> AstNode<'a> for Attr<'a> {
141 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 112 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -147,33 +118,28 @@ impl<'a> AstNode<'a> for Attr<'a> {
147 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 118 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
148} 119}
149 120
150impl<'a> Attr<'a> { 121impl<R: TreeRoot<RaTypes>> AttrNode<R> {
151 pub fn value(self) -> Option<TokenTree<'a>> { 122 pub fn borrowed(&self) -> Attr {
152 super::child_opt(self) 123 AttrNode { syntax: self.syntax.borrowed() }
124 }
125 pub fn owned(&self) -> AttrNode {
126 AttrNode { syntax: self.syntax.owned() }
153 } 127 }
154} 128}
155 129
156// BinExpr
157
158#[derive(Debug, Clone)]
159pub struct BinExprNode(SyntaxNode);
160 130
161impl BinExprNode { 131impl<'a> Attr<'a> {
162 pub fn ast(&self) -> BinExpr { 132 pub fn value(self) -> Option<TokenTree<'a>> {
163 BinExpr::cast(self.0.borrowed()).unwrap() 133 super::child_opt(self)
164 } 134 }
165} 135}
166 136
167impl<'a> From<BinExpr<'a>> for BinExprNode { 137// BinExpr
168 fn from(ast: BinExpr<'a>) -> BinExprNode {
169 let syntax = ast.syntax().owned();
170 BinExprNode(syntax)
171 }
172}
173#[derive(Debug, Clone, Copy)] 138#[derive(Debug, Clone, Copy)]
174pub struct BinExpr<'a> { 139pub struct BinExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
175 syntax: SyntaxNodeRef<'a>, 140 syntax: SyntaxNode<R>,
176} 141}
142pub type BinExpr<'a> = BinExprNode<RefRoot<'a>>;
177 143
178impl<'a> AstNode<'a> for BinExpr<'a> { 144impl<'a> AstNode<'a> for BinExpr<'a> {
179 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 145 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -185,29 +151,24 @@ impl<'a> AstNode<'a> for BinExpr<'a> {
185 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 151 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
186} 152}
187 153
188impl<'a> BinExpr<'a> {} 154impl<R: TreeRoot<RaTypes>> BinExprNode<R> {
189 155 pub fn borrowed(&self) -> BinExpr {
190// BindPat 156 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 } 157 }
199} 158 pub fn owned(&self) -> BinExprNode {
200 159 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 } 160 }
206} 161}
162
163
164impl<'a> BinExpr<'a> {}
165
166// BindPat
207#[derive(Debug, Clone, Copy)] 167#[derive(Debug, Clone, Copy)]
208pub struct BindPat<'a> { 168pub struct BindPatNode<R: TreeRoot<RaTypes> = OwnedRoot> {
209 syntax: SyntaxNodeRef<'a>, 169 syntax: SyntaxNode<R>,
210} 170}
171pub type BindPat<'a> = BindPatNode<RefRoot<'a>>;
211 172
212impl<'a> AstNode<'a> for BindPat<'a> { 173impl<'a> AstNode<'a> for BindPat<'a> {
213 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 174 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -219,30 +180,25 @@ impl<'a> AstNode<'a> for BindPat<'a> {
219 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 180 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
220} 181}
221 182
183impl<R: TreeRoot<RaTypes>> BindPatNode<R> {
184 pub fn borrowed(&self) -> BindPat {
185 BindPatNode { syntax: self.syntax.borrowed() }
186 }
187 pub fn owned(&self) -> BindPatNode {
188 BindPatNode { syntax: self.syntax.owned() }
189 }
190}
191
192
222impl<'a> ast::NameOwner<'a> for BindPat<'a> {} 193impl<'a> ast::NameOwner<'a> for BindPat<'a> {}
223impl<'a> BindPat<'a> {} 194impl<'a> BindPat<'a> {}
224 195
225// Block 196// 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)] 197#[derive(Debug, Clone, Copy)]
243pub struct Block<'a> { 198pub struct BlockNode<R: TreeRoot<RaTypes> = OwnedRoot> {
244 syntax: SyntaxNodeRef<'a>, 199 syntax: SyntaxNode<R>,
245} 200}
201pub type Block<'a> = BlockNode<RefRoot<'a>>;
246 202
247impl<'a> AstNode<'a> for Block<'a> { 203impl<'a> AstNode<'a> for Block<'a> {
248 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 204 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -254,6 +210,16 @@ impl<'a> AstNode<'a> for Block<'a> {
254 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 210 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
255} 211}
256 212
213impl<R: TreeRoot<RaTypes>> BlockNode<R> {
214 pub fn borrowed(&self) -> Block {
215 BlockNode { syntax: self.syntax.borrowed() }
216 }
217 pub fn owned(&self) -> BlockNode {
218 BlockNode { syntax: self.syntax.owned() }
219 }
220}
221
222
257impl<'a> Block<'a> { 223impl<'a> Block<'a> {
258 pub fn statements(self) -> impl Iterator<Item = Stmt<'a>> + 'a { 224 pub fn statements(self) -> impl Iterator<Item = Stmt<'a>> + 'a {
259 super::children(self) 225 super::children(self)
@@ -265,26 +231,11 @@ impl<'a> Block<'a> {
265} 231}
266 232
267// BlockExpr 233// 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)] 234#[derive(Debug, Clone, Copy)]
285pub struct BlockExpr<'a> { 235pub struct BlockExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
286 syntax: SyntaxNodeRef<'a>, 236 syntax: SyntaxNode<R>,
287} 237}
238pub type BlockExpr<'a> = BlockExprNode<RefRoot<'a>>;
288 239
289impl<'a> AstNode<'a> for BlockExpr<'a> { 240impl<'a> AstNode<'a> for BlockExpr<'a> {
290 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 241 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -296,33 +247,28 @@ impl<'a> AstNode<'a> for BlockExpr<'a> {
296 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 247 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
297} 248}
298 249
299impl<'a> BlockExpr<'a> { 250impl<R: TreeRoot<RaTypes>> BlockExprNode<R> {
300 pub fn block(self) -> Option<Block<'a>> { 251 pub fn borrowed(&self) -> BlockExpr {
301 super::child_opt(self) 252 BlockExprNode { syntax: self.syntax.borrowed() }
253 }
254 pub fn owned(&self) -> BlockExprNode {
255 BlockExprNode { syntax: self.syntax.owned() }
302 } 256 }
303} 257}
304 258
305// BreakExpr
306 259
307#[derive(Debug, Clone)] 260impl<'a> BlockExpr<'a> {
308pub struct BreakExprNode(SyntaxNode); 261 pub fn block(self) -> Option<Block<'a>> {
309 262 super::child_opt(self)
310impl BreakExprNode {
311 pub fn ast(&self) -> BreakExpr {
312 BreakExpr::cast(self.0.borrowed()).unwrap()
313 } 263 }
314} 264}
315 265
316impl<'a> From<BreakExpr<'a>> for BreakExprNode { 266// BreakExpr
317 fn from(ast: BreakExpr<'a>) -> BreakExprNode {
318 let syntax = ast.syntax().owned();
319 BreakExprNode(syntax)
320 }
321}
322#[derive(Debug, Clone, Copy)] 267#[derive(Debug, Clone, Copy)]
323pub struct BreakExpr<'a> { 268pub struct BreakExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
324 syntax: SyntaxNodeRef<'a>, 269 syntax: SyntaxNode<R>,
325} 270}
271pub type BreakExpr<'a> = BreakExprNode<RefRoot<'a>>;
326 272
327impl<'a> AstNode<'a> for BreakExpr<'a> { 273impl<'a> AstNode<'a> for BreakExpr<'a> {
328 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 274 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -334,29 +280,24 @@ impl<'a> AstNode<'a> for BreakExpr<'a> {
334 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 280 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
335} 281}
336 282
337impl<'a> BreakExpr<'a> {} 283impl<R: TreeRoot<RaTypes>> BreakExprNode<R> {
338 284 pub fn borrowed(&self) -> BreakExpr {
339// CallExpr 285 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 } 286 }
348} 287 pub fn owned(&self) -> BreakExprNode {
349 288 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 } 289 }
355} 290}
291
292
293impl<'a> BreakExpr<'a> {}
294
295// CallExpr
356#[derive(Debug, Clone, Copy)] 296#[derive(Debug, Clone, Copy)]
357pub struct CallExpr<'a> { 297pub struct CallExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
358 syntax: SyntaxNodeRef<'a>, 298 syntax: SyntaxNode<R>,
359} 299}
300pub type CallExpr<'a> = CallExprNode<RefRoot<'a>>;
360 301
361impl<'a> AstNode<'a> for CallExpr<'a> { 302impl<'a> AstNode<'a> for CallExpr<'a> {
362 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 303 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -368,6 +309,16 @@ impl<'a> AstNode<'a> for CallExpr<'a> {
368 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 309 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
369} 310}
370 311
312impl<R: TreeRoot<RaTypes>> CallExprNode<R> {
313 pub fn borrowed(&self) -> CallExpr {
314 CallExprNode { syntax: self.syntax.borrowed() }
315 }
316 pub fn owned(&self) -> CallExprNode {
317 CallExprNode { syntax: self.syntax.owned() }
318 }
319}
320
321
371impl<'a> ast::ArgListOwner<'a> for CallExpr<'a> {} 322impl<'a> ast::ArgListOwner<'a> for CallExpr<'a> {}
372impl<'a> CallExpr<'a> { 323impl<'a> CallExpr<'a> {
373 pub fn expr(self) -> Option<Expr<'a>> { 324 pub fn expr(self) -> Option<Expr<'a>> {
@@ -376,26 +327,11 @@ impl<'a> CallExpr<'a> {
376} 327}
377 328
378// CastExpr 329// 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)] 330#[derive(Debug, Clone, Copy)]
396pub struct CastExpr<'a> { 331pub struct CastExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
397 syntax: SyntaxNodeRef<'a>, 332 syntax: SyntaxNode<R>,
398} 333}
334pub type CastExpr<'a> = CastExprNode<RefRoot<'a>>;
399 335
400impl<'a> AstNode<'a> for CastExpr<'a> { 336impl<'a> AstNode<'a> for CastExpr<'a> {
401 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 337 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -407,29 +343,24 @@ impl<'a> AstNode<'a> for CastExpr<'a> {
407 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 343 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
408} 344}
409 345
410impl<'a> CastExpr<'a> {} 346impl<R: TreeRoot<RaTypes>> CastExprNode<R> {
411 347 pub fn borrowed(&self) -> CastExpr {
412// Char 348 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 } 349 }
421} 350 pub fn owned(&self) -> CastExprNode {
422 351 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 } 352 }
428} 353}
354
355
356impl<'a> CastExpr<'a> {}
357
358// Char
429#[derive(Debug, Clone, Copy)] 359#[derive(Debug, Clone, Copy)]
430pub struct Char<'a> { 360pub struct CharNode<R: TreeRoot<RaTypes> = OwnedRoot> {
431 syntax: SyntaxNodeRef<'a>, 361 syntax: SyntaxNode<R>,
432} 362}
363pub type Char<'a> = CharNode<RefRoot<'a>>;
433 364
434impl<'a> AstNode<'a> for Char<'a> { 365impl<'a> AstNode<'a> for Char<'a> {
435 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 366 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -441,29 +372,24 @@ impl<'a> AstNode<'a> for Char<'a> {
441 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 372 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
442} 373}
443 374
444impl<'a> Char<'a> {} 375impl<R: TreeRoot<RaTypes>> CharNode<R> {
445 376 pub fn borrowed(&self) -> Char {
446// Comment 377 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 } 378 }
455} 379 pub fn owned(&self) -> CharNode {
456 380 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 } 381 }
462} 382}
383
384
385impl<'a> Char<'a> {}
386
387// Comment
463#[derive(Debug, Clone, Copy)] 388#[derive(Debug, Clone, Copy)]
464pub struct Comment<'a> { 389pub struct CommentNode<R: TreeRoot<RaTypes> = OwnedRoot> {
465 syntax: SyntaxNodeRef<'a>, 390 syntax: SyntaxNode<R>,
466} 391}
392pub type Comment<'a> = CommentNode<RefRoot<'a>>;
467 393
468impl<'a> AstNode<'a> for Comment<'a> { 394impl<'a> AstNode<'a> for Comment<'a> {
469 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 395 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -475,29 +401,24 @@ impl<'a> AstNode<'a> for Comment<'a> {
475 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 401 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
476} 402}
477 403
478impl<'a> Comment<'a> {} 404impl<R: TreeRoot<RaTypes>> CommentNode<R> {
479 405 pub fn borrowed(&self) -> Comment {
480// Condition 406 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 } 407 }
489} 408 pub fn owned(&self) -> CommentNode {
490 409 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 } 410 }
496} 411}
412
413
414impl<'a> Comment<'a> {}
415
416// Condition
497#[derive(Debug, Clone, Copy)] 417#[derive(Debug, Clone, Copy)]
498pub struct Condition<'a> { 418pub struct ConditionNode<R: TreeRoot<RaTypes> = OwnedRoot> {
499 syntax: SyntaxNodeRef<'a>, 419 syntax: SyntaxNode<R>,
500} 420}
421pub type Condition<'a> = ConditionNode<RefRoot<'a>>;
501 422
502impl<'a> AstNode<'a> for Condition<'a> { 423impl<'a> AstNode<'a> for Condition<'a> {
503 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 424 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -509,6 +430,16 @@ impl<'a> AstNode<'a> for Condition<'a> {
509 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 430 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
510} 431}
511 432
433impl<R: TreeRoot<RaTypes>> ConditionNode<R> {
434 pub fn borrowed(&self) -> Condition {
435 ConditionNode { syntax: self.syntax.borrowed() }
436 }
437 pub fn owned(&self) -> ConditionNode {
438 ConditionNode { syntax: self.syntax.owned() }
439 }
440}
441
442
512impl<'a> Condition<'a> { 443impl<'a> Condition<'a> {
513 pub fn pat(self) -> Option<Pat<'a>> { 444 pub fn pat(self) -> Option<Pat<'a>> {
514 super::child_opt(self) 445 super::child_opt(self)
@@ -520,26 +451,11 @@ impl<'a> Condition<'a> {
520} 451}
521 452
522// ConstDef 453// 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)] 454#[derive(Debug, Clone, Copy)]
540pub struct ConstDef<'a> { 455pub struct ConstDefNode<R: TreeRoot<RaTypes> = OwnedRoot> {
541 syntax: SyntaxNodeRef<'a>, 456 syntax: SyntaxNode<R>,
542} 457}
458pub type ConstDef<'a> = ConstDefNode<RefRoot<'a>>;
543 459
544impl<'a> AstNode<'a> for ConstDef<'a> { 460impl<'a> AstNode<'a> for ConstDef<'a> {
545 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 461 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -551,32 +467,27 @@ impl<'a> AstNode<'a> for ConstDef<'a> {
551 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 467 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
552} 468}
553 469
470impl<R: TreeRoot<RaTypes>> ConstDefNode<R> {
471 pub fn borrowed(&self) -> ConstDef {
472 ConstDefNode { syntax: self.syntax.borrowed() }
473 }
474 pub fn owned(&self) -> ConstDefNode {
475 ConstDefNode { syntax: self.syntax.owned() }
476 }
477}
478
479
554impl<'a> ast::NameOwner<'a> for ConstDef<'a> {} 480impl<'a> ast::NameOwner<'a> for ConstDef<'a> {}
555impl<'a> ast::TypeParamsOwner<'a> for ConstDef<'a> {} 481impl<'a> ast::TypeParamsOwner<'a> for ConstDef<'a> {}
556impl<'a> ast::AttrsOwner<'a> for ConstDef<'a> {} 482impl<'a> ast::AttrsOwner<'a> for ConstDef<'a> {}
557impl<'a> ConstDef<'a> {} 483impl<'a> ConstDef<'a> {}
558 484
559// ContinueExpr 485// 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)] 486#[derive(Debug, Clone, Copy)]
577pub struct ContinueExpr<'a> { 487pub struct ContinueExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
578 syntax: SyntaxNodeRef<'a>, 488 syntax: SyntaxNode<R>,
579} 489}
490pub type ContinueExpr<'a> = ContinueExprNode<RefRoot<'a>>;
580 491
581impl<'a> AstNode<'a> for ContinueExpr<'a> { 492impl<'a> AstNode<'a> for ContinueExpr<'a> {
582 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 493 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -588,29 +499,24 @@ impl<'a> AstNode<'a> for ContinueExpr<'a> {
588 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 499 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
589} 500}
590 501
591impl<'a> ContinueExpr<'a> {} 502impl<R: TreeRoot<RaTypes>> ContinueExprNode<R> {
592 503 pub fn borrowed(&self) -> ContinueExpr {
593// DynTraitType 504 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 } 505 }
602} 506 pub fn owned(&self) -> ContinueExprNode {
603 507 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 } 508 }
609} 509}
510
511
512impl<'a> ContinueExpr<'a> {}
513
514// DynTraitType
610#[derive(Debug, Clone, Copy)] 515#[derive(Debug, Clone, Copy)]
611pub struct DynTraitType<'a> { 516pub struct DynTraitTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
612 syntax: SyntaxNodeRef<'a>, 517 syntax: SyntaxNode<R>,
613} 518}
519pub type DynTraitType<'a> = DynTraitTypeNode<RefRoot<'a>>;
614 520
615impl<'a> AstNode<'a> for DynTraitType<'a> { 521impl<'a> AstNode<'a> for DynTraitType<'a> {
616 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 522 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -622,29 +528,24 @@ impl<'a> AstNode<'a> for DynTraitType<'a> {
622 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 528 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
623} 529}
624 530
625impl<'a> DynTraitType<'a> {} 531impl<R: TreeRoot<RaTypes>> DynTraitTypeNode<R> {
626 532 pub fn borrowed(&self) -> DynTraitType {
627// EnumDef 533 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 } 534 }
636} 535 pub fn owned(&self) -> DynTraitTypeNode {
637 536 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 } 537 }
643} 538}
539
540
541impl<'a> DynTraitType<'a> {}
542
543// EnumDef
644#[derive(Debug, Clone, Copy)] 544#[derive(Debug, Clone, Copy)]
645pub struct EnumDef<'a> { 545pub struct EnumDefNode<R: TreeRoot<RaTypes> = OwnedRoot> {
646 syntax: SyntaxNodeRef<'a>, 546 syntax: SyntaxNode<R>,
647} 547}
548pub type EnumDef<'a> = EnumDefNode<RefRoot<'a>>;
648 549
649impl<'a> AstNode<'a> for EnumDef<'a> { 550impl<'a> AstNode<'a> for EnumDef<'a> {
650 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 551 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -656,28 +557,22 @@ impl<'a> AstNode<'a> for EnumDef<'a> {
656 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 557 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
657} 558}
658 559
560impl<R: TreeRoot<RaTypes>> EnumDefNode<R> {
561 pub fn borrowed(&self) -> EnumDef {
562 EnumDefNode { syntax: self.syntax.borrowed() }
563 }
564 pub fn owned(&self) -> EnumDefNode {
565 EnumDefNode { syntax: self.syntax.owned() }
566 }
567}
568
569
659impl<'a> ast::NameOwner<'a> for EnumDef<'a> {} 570impl<'a> ast::NameOwner<'a> for EnumDef<'a> {}
660impl<'a> ast::TypeParamsOwner<'a> for EnumDef<'a> {} 571impl<'a> ast::TypeParamsOwner<'a> for EnumDef<'a> {}
661impl<'a> ast::AttrsOwner<'a> for EnumDef<'a> {} 572impl<'a> ast::AttrsOwner<'a> for EnumDef<'a> {}
662impl<'a> EnumDef<'a> {} 573impl<'a> EnumDef<'a> {}
663 574
664// Expr 575// 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)] 576#[derive(Debug, Clone, Copy)]
682pub enum Expr<'a> { 577pub enum Expr<'a> {
683 TupleExpr(TupleExpr<'a>), 578 TupleExpr(TupleExpr<'a>),
@@ -793,26 +688,11 @@ impl<'a> AstNode<'a> for Expr<'a> {
793impl<'a> Expr<'a> {} 688impl<'a> Expr<'a> {}
794 689
795// ExprStmt 690// 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)] 691#[derive(Debug, Clone, Copy)]
813pub struct ExprStmt<'a> { 692pub struct ExprStmtNode<R: TreeRoot<RaTypes> = OwnedRoot> {
814 syntax: SyntaxNodeRef<'a>, 693 syntax: SyntaxNode<R>,
815} 694}
695pub type ExprStmt<'a> = ExprStmtNode<RefRoot<'a>>;
816 696
817impl<'a> AstNode<'a> for ExprStmt<'a> { 697impl<'a> AstNode<'a> for ExprStmt<'a> {
818 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 698 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -824,33 +704,28 @@ impl<'a> AstNode<'a> for ExprStmt<'a> {
824 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 704 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
825} 705}
826 706
827impl<'a> ExprStmt<'a> { 707impl<R: TreeRoot<RaTypes>> ExprStmtNode<R> {
828 pub fn expr(self) -> Option<Expr<'a>> { 708 pub fn borrowed(&self) -> ExprStmt {
829 super::child_opt(self) 709 ExprStmtNode { syntax: self.syntax.borrowed() }
710 }
711 pub fn owned(&self) -> ExprStmtNode {
712 ExprStmtNode { syntax: self.syntax.owned() }
830 } 713 }
831} 714}
832 715
833// ExternCrateItem
834 716
835#[derive(Debug, Clone)] 717impl<'a> ExprStmt<'a> {
836pub struct ExternCrateItemNode(SyntaxNode); 718 pub fn expr(self) -> Option<Expr<'a>> {
837 719 super::child_opt(self)
838impl ExternCrateItemNode {
839 pub fn ast(&self) -> ExternCrateItem {
840 ExternCrateItem::cast(self.0.borrowed()).unwrap()
841 } 720 }
842} 721}
843 722
844impl<'a> From<ExternCrateItem<'a>> for ExternCrateItemNode { 723// ExternCrateItem
845 fn from(ast: ExternCrateItem<'a>) -> ExternCrateItemNode {
846 let syntax = ast.syntax().owned();
847 ExternCrateItemNode(syntax)
848 }
849}
850#[derive(Debug, Clone, Copy)] 724#[derive(Debug, Clone, Copy)]
851pub struct ExternCrateItem<'a> { 725pub struct ExternCrateItemNode<R: TreeRoot<RaTypes> = OwnedRoot> {
852 syntax: SyntaxNodeRef<'a>, 726 syntax: SyntaxNode<R>,
853} 727}
728pub type ExternCrateItem<'a> = ExternCrateItemNode<RefRoot<'a>>;
854 729
855impl<'a> AstNode<'a> for ExternCrateItem<'a> { 730impl<'a> AstNode<'a> for ExternCrateItem<'a> {
856 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 731 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -862,29 +737,24 @@ impl<'a> AstNode<'a> for ExternCrateItem<'a> {
862 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 737 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
863} 738}
864 739
865impl<'a> ExternCrateItem<'a> {} 740impl<R: TreeRoot<RaTypes>> ExternCrateItemNode<R> {
866 741 pub fn borrowed(&self) -> ExternCrateItem {
867// FieldExpr 742 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 } 743 }
876} 744 pub fn owned(&self) -> ExternCrateItemNode {
877 745 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 } 746 }
883} 747}
748
749
750impl<'a> ExternCrateItem<'a> {}
751
752// FieldExpr
884#[derive(Debug, Clone, Copy)] 753#[derive(Debug, Clone, Copy)]
885pub struct FieldExpr<'a> { 754pub struct FieldExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
886 syntax: SyntaxNodeRef<'a>, 755 syntax: SyntaxNode<R>,
887} 756}
757pub type FieldExpr<'a> = FieldExprNode<RefRoot<'a>>;
888 758
889impl<'a> AstNode<'a> for FieldExpr<'a> { 759impl<'a> AstNode<'a> for FieldExpr<'a> {
890 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 760 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -896,29 +766,24 @@ impl<'a> AstNode<'a> for FieldExpr<'a> {
896 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 766 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
897} 767}
898 768
899impl<'a> FieldExpr<'a> {} 769impl<R: TreeRoot<RaTypes>> FieldExprNode<R> {
900 770 pub fn borrowed(&self) -> FieldExpr {
901// FieldPatList 771 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 } 772 }
910} 773 pub fn owned(&self) -> FieldExprNode {
911 774 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 } 775 }
917} 776}
777
778
779impl<'a> FieldExpr<'a> {}
780
781// FieldPatList
918#[derive(Debug, Clone, Copy)] 782#[derive(Debug, Clone, Copy)]
919pub struct FieldPatList<'a> { 783pub struct FieldPatListNode<R: TreeRoot<RaTypes> = OwnedRoot> {
920 syntax: SyntaxNodeRef<'a>, 784 syntax: SyntaxNode<R>,
921} 785}
786pub type FieldPatList<'a> = FieldPatListNode<RefRoot<'a>>;
922 787
923impl<'a> AstNode<'a> for FieldPatList<'a> { 788impl<'a> AstNode<'a> for FieldPatList<'a> {
924 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 789 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -930,29 +795,24 @@ impl<'a> AstNode<'a> for FieldPatList<'a> {
930 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 795 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
931} 796}
932 797
933impl<'a> FieldPatList<'a> {} 798impl<R: TreeRoot<RaTypes>> FieldPatListNode<R> {
934 799 pub fn borrowed(&self) -> FieldPatList {
935// FnDef 800 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 } 801 }
944} 802 pub fn owned(&self) -> FieldPatListNode {
945 803 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 } 804 }
951} 805}
806
807
808impl<'a> FieldPatList<'a> {}
809
810// FnDef
952#[derive(Debug, Clone, Copy)] 811#[derive(Debug, Clone, Copy)]
953pub struct FnDef<'a> { 812pub struct FnDefNode<R: TreeRoot<RaTypes> = OwnedRoot> {
954 syntax: SyntaxNodeRef<'a>, 813 syntax: SyntaxNode<R>,
955} 814}
815pub type FnDef<'a> = FnDefNode<RefRoot<'a>>;
956 816
957impl<'a> AstNode<'a> for FnDef<'a> { 817impl<'a> AstNode<'a> for FnDef<'a> {
958 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 818 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -964,6 +824,16 @@ impl<'a> AstNode<'a> for FnDef<'a> {
964 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 824 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
965} 825}
966 826
827impl<R: TreeRoot<RaTypes>> FnDefNode<R> {
828 pub fn borrowed(&self) -> FnDef {
829 FnDefNode { syntax: self.syntax.borrowed() }
830 }
831 pub fn owned(&self) -> FnDefNode {
832 FnDefNode { syntax: self.syntax.owned() }
833 }
834}
835
836
967impl<'a> ast::NameOwner<'a> for FnDef<'a> {} 837impl<'a> ast::NameOwner<'a> for FnDef<'a> {}
968impl<'a> ast::TypeParamsOwner<'a> for FnDef<'a> {} 838impl<'a> ast::TypeParamsOwner<'a> for FnDef<'a> {}
969impl<'a> ast::AttrsOwner<'a> for FnDef<'a> {} 839impl<'a> ast::AttrsOwner<'a> for FnDef<'a> {}
@@ -983,26 +853,11 @@ impl<'a> FnDef<'a> {
983} 853}
984 854
985// FnPointerType 855// 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)] 856#[derive(Debug, Clone, Copy)]
1003pub struct FnPointerType<'a> { 857pub struct FnPointerTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1004 syntax: SyntaxNodeRef<'a>, 858 syntax: SyntaxNode<R>,
1005} 859}
860pub type FnPointerType<'a> = FnPointerTypeNode<RefRoot<'a>>;
1006 861
1007impl<'a> AstNode<'a> for FnPointerType<'a> { 862impl<'a> AstNode<'a> for FnPointerType<'a> {
1008 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 863 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1014,29 +869,24 @@ impl<'a> AstNode<'a> for FnPointerType<'a> {
1014 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 869 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1015} 870}
1016 871
1017impl<'a> FnPointerType<'a> {} 872impl<R: TreeRoot<RaTypes>> FnPointerTypeNode<R> {
1018 873 pub fn borrowed(&self) -> FnPointerType {
1019// ForExpr 874 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 } 875 }
1028} 876 pub fn owned(&self) -> FnPointerTypeNode {
1029 877 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 } 878 }
1035} 879}
880
881
882impl<'a> FnPointerType<'a> {}
883
884// ForExpr
1036#[derive(Debug, Clone, Copy)] 885#[derive(Debug, Clone, Copy)]
1037pub struct ForExpr<'a> { 886pub struct ForExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1038 syntax: SyntaxNodeRef<'a>, 887 syntax: SyntaxNode<R>,
1039} 888}
889pub type ForExpr<'a> = ForExprNode<RefRoot<'a>>;
1040 890
1041impl<'a> AstNode<'a> for ForExpr<'a> { 891impl<'a> AstNode<'a> for ForExpr<'a> {
1042 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 892 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1048,6 +898,16 @@ impl<'a> AstNode<'a> for ForExpr<'a> {
1048 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 898 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1049} 899}
1050 900
901impl<R: TreeRoot<RaTypes>> ForExprNode<R> {
902 pub fn borrowed(&self) -> ForExpr {
903 ForExprNode { syntax: self.syntax.borrowed() }
904 }
905 pub fn owned(&self) -> ForExprNode {
906 ForExprNode { syntax: self.syntax.owned() }
907 }
908}
909
910
1051impl<'a> ast::LoopBodyOwner<'a> for ForExpr<'a> {} 911impl<'a> ast::LoopBodyOwner<'a> for ForExpr<'a> {}
1052impl<'a> ForExpr<'a> { 912impl<'a> ForExpr<'a> {
1053 pub fn pat(self) -> Option<Pat<'a>> { 913 pub fn pat(self) -> Option<Pat<'a>> {
@@ -1060,26 +920,11 @@ impl<'a> ForExpr<'a> {
1060} 920}
1061 921
1062// ForType 922// 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)] 923#[derive(Debug, Clone, Copy)]
1080pub struct ForType<'a> { 924pub struct ForTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1081 syntax: SyntaxNodeRef<'a>, 925 syntax: SyntaxNode<R>,
1082} 926}
927pub type ForType<'a> = ForTypeNode<RefRoot<'a>>;
1083 928
1084impl<'a> AstNode<'a> for ForType<'a> { 929impl<'a> AstNode<'a> for ForType<'a> {
1085 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 930 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1091,29 +936,24 @@ impl<'a> AstNode<'a> for ForType<'a> {
1091 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 936 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1092} 937}
1093 938
1094impl<'a> ForType<'a> {} 939impl<R: TreeRoot<RaTypes>> ForTypeNode<R> {
1095 940 pub fn borrowed(&self) -> ForType {
1096// IfExpr 941 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 } 942 }
1105} 943 pub fn owned(&self) -> ForTypeNode {
1106 944 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 } 945 }
1112} 946}
947
948
949impl<'a> ForType<'a> {}
950
951// IfExpr
1113#[derive(Debug, Clone, Copy)] 952#[derive(Debug, Clone, Copy)]
1114pub struct IfExpr<'a> { 953pub struct IfExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1115 syntax: SyntaxNodeRef<'a>, 954 syntax: SyntaxNode<R>,
1116} 955}
956pub type IfExpr<'a> = IfExprNode<RefRoot<'a>>;
1117 957
1118impl<'a> AstNode<'a> for IfExpr<'a> { 958impl<'a> AstNode<'a> for IfExpr<'a> {
1119 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 959 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1125,33 +965,28 @@ impl<'a> AstNode<'a> for IfExpr<'a> {
1125 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 965 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1126} 966}
1127 967
1128impl<'a> IfExpr<'a> { 968impl<R: TreeRoot<RaTypes>> IfExprNode<R> {
1129 pub fn condition(self) -> Option<Condition<'a>> { 969 pub fn borrowed(&self) -> IfExpr {
1130 super::child_opt(self) 970 IfExprNode { syntax: self.syntax.borrowed() }
971 }
972 pub fn owned(&self) -> IfExprNode {
973 IfExprNode { syntax: self.syntax.owned() }
1131 } 974 }
1132} 975}
1133 976
1134// ImplItem
1135
1136#[derive(Debug, Clone)]
1137pub struct ImplItemNode(SyntaxNode);
1138 977
1139impl ImplItemNode { 978impl<'a> IfExpr<'a> {
1140 pub fn ast(&self) -> ImplItem { 979 pub fn condition(self) -> Option<Condition<'a>> {
1141 ImplItem::cast(self.0.borrowed()).unwrap() 980 super::child_opt(self)
1142 } 981 }
1143} 982}
1144 983
1145impl<'a> From<ImplItem<'a>> for ImplItemNode { 984// ImplItem
1146 fn from(ast: ImplItem<'a>) -> ImplItemNode {
1147 let syntax = ast.syntax().owned();
1148 ImplItemNode(syntax)
1149 }
1150}
1151#[derive(Debug, Clone, Copy)] 985#[derive(Debug, Clone, Copy)]
1152pub struct ImplItem<'a> { 986pub struct ImplItemNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1153 syntax: SyntaxNodeRef<'a>, 987 syntax: SyntaxNode<R>,
1154} 988}
989pub type ImplItem<'a> = ImplItemNode<RefRoot<'a>>;
1155 990
1156impl<'a> AstNode<'a> for ImplItem<'a> { 991impl<'a> AstNode<'a> for ImplItem<'a> {
1157 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 992 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1163,29 +998,24 @@ impl<'a> AstNode<'a> for ImplItem<'a> {
1163 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 998 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1164} 999}
1165 1000
1166impl<'a> ImplItem<'a> {} 1001impl<R: TreeRoot<RaTypes>> ImplItemNode<R> {
1167 1002 pub fn borrowed(&self) -> ImplItem {
1168// ImplTraitType 1003 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 } 1004 }
1177} 1005 pub fn owned(&self) -> ImplItemNode {
1178 1006 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 } 1007 }
1184} 1008}
1009
1010
1011impl<'a> ImplItem<'a> {}
1012
1013// ImplTraitType
1185#[derive(Debug, Clone, Copy)] 1014#[derive(Debug, Clone, Copy)]
1186pub struct ImplTraitType<'a> { 1015pub struct ImplTraitTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1187 syntax: SyntaxNodeRef<'a>, 1016 syntax: SyntaxNode<R>,
1188} 1017}
1018pub type ImplTraitType<'a> = ImplTraitTypeNode<RefRoot<'a>>;
1189 1019
1190impl<'a> AstNode<'a> for ImplTraitType<'a> { 1020impl<'a> AstNode<'a> for ImplTraitType<'a> {
1191 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1021 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1197,29 +1027,24 @@ impl<'a> AstNode<'a> for ImplTraitType<'a> {
1197 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1027 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1198} 1028}
1199 1029
1200impl<'a> ImplTraitType<'a> {} 1030impl<R: TreeRoot<RaTypes>> ImplTraitTypeNode<R> {
1201 1031 pub fn borrowed(&self) -> ImplTraitType {
1202// IndexExpr 1032 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 } 1033 }
1211} 1034 pub fn owned(&self) -> ImplTraitTypeNode {
1212 1035 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 } 1036 }
1218} 1037}
1038
1039
1040impl<'a> ImplTraitType<'a> {}
1041
1042// IndexExpr
1219#[derive(Debug, Clone, Copy)] 1043#[derive(Debug, Clone, Copy)]
1220pub struct IndexExpr<'a> { 1044pub struct IndexExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1221 syntax: SyntaxNodeRef<'a>, 1045 syntax: SyntaxNode<R>,
1222} 1046}
1047pub type IndexExpr<'a> = IndexExprNode<RefRoot<'a>>;
1223 1048
1224impl<'a> AstNode<'a> for IndexExpr<'a> { 1049impl<'a> AstNode<'a> for IndexExpr<'a> {
1225 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1050 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1231,29 +1056,24 @@ impl<'a> AstNode<'a> for IndexExpr<'a> {
1231 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1056 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1232} 1057}
1233 1058
1234impl<'a> IndexExpr<'a> {} 1059impl<R: TreeRoot<RaTypes>> IndexExprNode<R> {
1235 1060 pub fn borrowed(&self) -> IndexExpr {
1236// ItemList 1061 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 } 1062 }
1245} 1063 pub fn owned(&self) -> IndexExprNode {
1246 1064 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 } 1065 }
1252} 1066}
1067
1068
1069impl<'a> IndexExpr<'a> {}
1070
1071// ItemList
1253#[derive(Debug, Clone, Copy)] 1072#[derive(Debug, Clone, Copy)]
1254pub struct ItemList<'a> { 1073pub struct ItemListNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1255 syntax: SyntaxNodeRef<'a>, 1074 syntax: SyntaxNode<R>,
1256} 1075}
1076pub type ItemList<'a> = ItemListNode<RefRoot<'a>>;
1257 1077
1258impl<'a> AstNode<'a> for ItemList<'a> { 1078impl<'a> AstNode<'a> for ItemList<'a> {
1259 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1079 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1265,31 +1085,26 @@ impl<'a> AstNode<'a> for ItemList<'a> {
1265 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1085 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1266} 1086}
1267 1087
1088impl<R: TreeRoot<RaTypes>> ItemListNode<R> {
1089 pub fn borrowed(&self) -> ItemList {
1090 ItemListNode { syntax: self.syntax.borrowed() }
1091 }
1092 pub fn owned(&self) -> ItemListNode {
1093 ItemListNode { syntax: self.syntax.owned() }
1094 }
1095}
1096
1097
1268impl<'a> ast::FnDefOwner<'a> for ItemList<'a> {} 1098impl<'a> ast::FnDefOwner<'a> for ItemList<'a> {}
1269impl<'a> ast::ModuleItemOwner<'a> for ItemList<'a> {} 1099impl<'a> ast::ModuleItemOwner<'a> for ItemList<'a> {}
1270impl<'a> ItemList<'a> {} 1100impl<'a> ItemList<'a> {}
1271 1101
1272// Label 1102// 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)] 1103#[derive(Debug, Clone, Copy)]
1290pub struct Label<'a> { 1104pub struct LabelNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1291 syntax: SyntaxNodeRef<'a>, 1105 syntax: SyntaxNode<R>,
1292} 1106}
1107pub type Label<'a> = LabelNode<RefRoot<'a>>;
1293 1108
1294impl<'a> AstNode<'a> for Label<'a> { 1109impl<'a> AstNode<'a> for Label<'a> {
1295 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1110 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1301,29 +1116,24 @@ impl<'a> AstNode<'a> for Label<'a> {
1301 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1116 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1302} 1117}
1303 1118
1304impl<'a> Label<'a> {} 1119impl<R: TreeRoot<RaTypes>> LabelNode<R> {
1305 1120 pub fn borrowed(&self) -> Label {
1306// LambdaExpr 1121 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 } 1122 }
1315} 1123 pub fn owned(&self) -> LabelNode {
1316 1124 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 } 1125 }
1322} 1126}
1127
1128
1129impl<'a> Label<'a> {}
1130
1131// LambdaExpr
1323#[derive(Debug, Clone, Copy)] 1132#[derive(Debug, Clone, Copy)]
1324pub struct LambdaExpr<'a> { 1133pub struct LambdaExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1325 syntax: SyntaxNodeRef<'a>, 1134 syntax: SyntaxNode<R>,
1326} 1135}
1136pub type LambdaExpr<'a> = LambdaExprNode<RefRoot<'a>>;
1327 1137
1328impl<'a> AstNode<'a> for LambdaExpr<'a> { 1138impl<'a> AstNode<'a> for LambdaExpr<'a> {
1329 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1139 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1335,6 +1145,16 @@ impl<'a> AstNode<'a> for LambdaExpr<'a> {
1335 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1145 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1336} 1146}
1337 1147
1148impl<R: TreeRoot<RaTypes>> LambdaExprNode<R> {
1149 pub fn borrowed(&self) -> LambdaExpr {
1150 LambdaExprNode { syntax: self.syntax.borrowed() }
1151 }
1152 pub fn owned(&self) -> LambdaExprNode {
1153 LambdaExprNode { syntax: self.syntax.owned() }
1154 }
1155}
1156
1157
1338impl<'a> LambdaExpr<'a> { 1158impl<'a> LambdaExpr<'a> {
1339 pub fn param_list(self) -> Option<ParamList<'a>> { 1159 pub fn param_list(self) -> Option<ParamList<'a>> {
1340 super::child_opt(self) 1160 super::child_opt(self)
@@ -1346,26 +1166,11 @@ impl<'a> LambdaExpr<'a> {
1346} 1166}
1347 1167
1348// LetStmt 1168// 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)] 1169#[derive(Debug, Clone, Copy)]
1366pub struct LetStmt<'a> { 1170pub struct LetStmtNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1367 syntax: SyntaxNodeRef<'a>, 1171 syntax: SyntaxNode<R>,
1368} 1172}
1173pub type LetStmt<'a> = LetStmtNode<RefRoot<'a>>;
1369 1174
1370impl<'a> AstNode<'a> for LetStmt<'a> { 1175impl<'a> AstNode<'a> for LetStmt<'a> {
1371 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1176 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1377,6 +1182,16 @@ impl<'a> AstNode<'a> for LetStmt<'a> {
1377 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1182 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1378} 1183}
1379 1184
1185impl<R: TreeRoot<RaTypes>> LetStmtNode<R> {
1186 pub fn borrowed(&self) -> LetStmt {
1187 LetStmtNode { syntax: self.syntax.borrowed() }
1188 }
1189 pub fn owned(&self) -> LetStmtNode {
1190 LetStmtNode { syntax: self.syntax.owned() }
1191 }
1192}
1193
1194
1380impl<'a> LetStmt<'a> { 1195impl<'a> LetStmt<'a> {
1381 pub fn pat(self) -> Option<Pat<'a>> { 1196 pub fn pat(self) -> Option<Pat<'a>> {
1382 super::child_opt(self) 1197 super::child_opt(self)
@@ -1388,26 +1203,11 @@ impl<'a> LetStmt<'a> {
1388} 1203}
1389 1204
1390// Lifetime 1205// 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)] 1206#[derive(Debug, Clone, Copy)]
1408pub struct Lifetime<'a> { 1207pub struct LifetimeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1409 syntax: SyntaxNodeRef<'a>, 1208 syntax: SyntaxNode<R>,
1410} 1209}
1210pub type Lifetime<'a> = LifetimeNode<RefRoot<'a>>;
1411 1211
1412impl<'a> AstNode<'a> for Lifetime<'a> { 1212impl<'a> AstNode<'a> for Lifetime<'a> {
1413 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1213 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1419,29 +1219,24 @@ impl<'a> AstNode<'a> for Lifetime<'a> {
1419 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1219 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1420} 1220}
1421 1221
1422impl<'a> Lifetime<'a> {} 1222impl<R: TreeRoot<RaTypes>> LifetimeNode<R> {
1423 1223 pub fn borrowed(&self) -> Lifetime {
1424// LifetimeParam 1224 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 } 1225 }
1433} 1226 pub fn owned(&self) -> LifetimeNode {
1434 1227 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 } 1228 }
1440} 1229}
1230
1231
1232impl<'a> Lifetime<'a> {}
1233
1234// LifetimeParam
1441#[derive(Debug, Clone, Copy)] 1235#[derive(Debug, Clone, Copy)]
1442pub struct LifetimeParam<'a> { 1236pub struct LifetimeParamNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1443 syntax: SyntaxNodeRef<'a>, 1237 syntax: SyntaxNode<R>,
1444} 1238}
1239pub type LifetimeParam<'a> = LifetimeParamNode<RefRoot<'a>>;
1445 1240
1446impl<'a> AstNode<'a> for LifetimeParam<'a> { 1241impl<'a> AstNode<'a> for LifetimeParam<'a> {
1447 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1242 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1453,33 +1248,28 @@ impl<'a> AstNode<'a> for LifetimeParam<'a> {
1453 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1248 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1454} 1249}
1455 1250
1456impl<'a> LifetimeParam<'a> { 1251impl<R: TreeRoot<RaTypes>> LifetimeParamNode<R> {
1457 pub fn lifetime(self) -> Option<Lifetime<'a>> { 1252 pub fn borrowed(&self) -> LifetimeParam {
1458 super::child_opt(self) 1253 LifetimeParamNode { syntax: self.syntax.borrowed() }
1254 }
1255 pub fn owned(&self) -> LifetimeParamNode {
1256 LifetimeParamNode { syntax: self.syntax.owned() }
1459 } 1257 }
1460} 1258}
1461 1259
1462// Literal
1463
1464#[derive(Debug, Clone)]
1465pub struct LiteralNode(SyntaxNode);
1466 1260
1467impl LiteralNode { 1261impl<'a> LifetimeParam<'a> {
1468 pub fn ast(&self) -> Literal { 1262 pub fn lifetime(self) -> Option<Lifetime<'a>> {
1469 Literal::cast(self.0.borrowed()).unwrap() 1263 super::child_opt(self)
1470 } 1264 }
1471} 1265}
1472 1266
1473impl<'a> From<Literal<'a>> for LiteralNode { 1267// Literal
1474 fn from(ast: Literal<'a>) -> LiteralNode {
1475 let syntax = ast.syntax().owned();
1476 LiteralNode(syntax)
1477 }
1478}
1479#[derive(Debug, Clone, Copy)] 1268#[derive(Debug, Clone, Copy)]
1480pub struct Literal<'a> { 1269pub struct LiteralNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1481 syntax: SyntaxNodeRef<'a>, 1270 syntax: SyntaxNode<R>,
1482} 1271}
1272pub type Literal<'a> = LiteralNode<RefRoot<'a>>;
1483 1273
1484impl<'a> AstNode<'a> for Literal<'a> { 1274impl<'a> AstNode<'a> for Literal<'a> {
1485 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1275 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1491,29 +1281,24 @@ impl<'a> AstNode<'a> for Literal<'a> {
1491 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1281 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1492} 1282}
1493 1283
1494impl<'a> Literal<'a> {} 1284impl<R: TreeRoot<RaTypes>> LiteralNode<R> {
1495 1285 pub fn borrowed(&self) -> Literal {
1496// LoopExpr 1286 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 } 1287 }
1505} 1288 pub fn owned(&self) -> LiteralNode {
1506 1289 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 } 1290 }
1512} 1291}
1292
1293
1294impl<'a> Literal<'a> {}
1295
1296// LoopExpr
1513#[derive(Debug, Clone, Copy)] 1297#[derive(Debug, Clone, Copy)]
1514pub struct LoopExpr<'a> { 1298pub struct LoopExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1515 syntax: SyntaxNodeRef<'a>, 1299 syntax: SyntaxNode<R>,
1516} 1300}
1301pub type LoopExpr<'a> = LoopExprNode<RefRoot<'a>>;
1517 1302
1518impl<'a> AstNode<'a> for LoopExpr<'a> { 1303impl<'a> AstNode<'a> for LoopExpr<'a> {
1519 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1304 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1525,30 +1310,25 @@ impl<'a> AstNode<'a> for LoopExpr<'a> {
1525 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1310 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1526} 1311}
1527 1312
1313impl<R: TreeRoot<RaTypes>> LoopExprNode<R> {
1314 pub fn borrowed(&self) -> LoopExpr {
1315 LoopExprNode { syntax: self.syntax.borrowed() }
1316 }
1317 pub fn owned(&self) -> LoopExprNode {
1318 LoopExprNode { syntax: self.syntax.owned() }
1319 }
1320}
1321
1322
1528impl<'a> ast::LoopBodyOwner<'a> for LoopExpr<'a> {} 1323impl<'a> ast::LoopBodyOwner<'a> for LoopExpr<'a> {}
1529impl<'a> LoopExpr<'a> {} 1324impl<'a> LoopExpr<'a> {}
1530 1325
1531// MatchArm 1326// 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)] 1327#[derive(Debug, Clone, Copy)]
1549pub struct MatchArm<'a> { 1328pub struct MatchArmNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1550 syntax: SyntaxNodeRef<'a>, 1329 syntax: SyntaxNode<R>,
1551} 1330}
1331pub type MatchArm<'a> = MatchArmNode<RefRoot<'a>>;
1552 1332
1553impl<'a> AstNode<'a> for MatchArm<'a> { 1333impl<'a> AstNode<'a> for MatchArm<'a> {
1554 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1334 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1560,6 +1340,16 @@ impl<'a> AstNode<'a> for MatchArm<'a> {
1560 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1340 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1561} 1341}
1562 1342
1343impl<R: TreeRoot<RaTypes>> MatchArmNode<R> {
1344 pub fn borrowed(&self) -> MatchArm {
1345 MatchArmNode { syntax: self.syntax.borrowed() }
1346 }
1347 pub fn owned(&self) -> MatchArmNode {
1348 MatchArmNode { syntax: self.syntax.owned() }
1349 }
1350}
1351
1352
1563impl<'a> MatchArm<'a> { 1353impl<'a> MatchArm<'a> {
1564 pub fn pats(self) -> impl Iterator<Item = Pat<'a>> + 'a { 1354 pub fn pats(self) -> impl Iterator<Item = Pat<'a>> + 'a {
1565 super::children(self) 1355 super::children(self)
@@ -1575,26 +1365,11 @@ impl<'a> MatchArm<'a> {
1575} 1365}
1576 1366
1577// MatchArmList 1367// 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)] 1368#[derive(Debug, Clone, Copy)]
1595pub struct MatchArmList<'a> { 1369pub struct MatchArmListNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1596 syntax: SyntaxNodeRef<'a>, 1370 syntax: SyntaxNode<R>,
1597} 1371}
1372pub type MatchArmList<'a> = MatchArmListNode<RefRoot<'a>>;
1598 1373
1599impl<'a> AstNode<'a> for MatchArmList<'a> { 1374impl<'a> AstNode<'a> for MatchArmList<'a> {
1600 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1375 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1606,33 +1381,28 @@ impl<'a> AstNode<'a> for MatchArmList<'a> {
1606 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1381 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1607} 1382}
1608 1383
1609impl<'a> MatchArmList<'a> { 1384impl<R: TreeRoot<RaTypes>> MatchArmListNode<R> {
1610 pub fn arms(self) -> impl Iterator<Item = MatchArm<'a>> + 'a { 1385 pub fn borrowed(&self) -> MatchArmList {
1611 super::children(self) 1386 MatchArmListNode { syntax: self.syntax.borrowed() }
1387 }
1388 pub fn owned(&self) -> MatchArmListNode {
1389 MatchArmListNode { syntax: self.syntax.owned() }
1612 } 1390 }
1613} 1391}
1614 1392
1615// MatchExpr
1616
1617#[derive(Debug, Clone)]
1618pub struct MatchExprNode(SyntaxNode);
1619 1393
1620impl MatchExprNode { 1394impl<'a> MatchArmList<'a> {
1621 pub fn ast(&self) -> MatchExpr { 1395 pub fn arms(self) -> impl Iterator<Item = MatchArm<'a>> + 'a {
1622 MatchExpr::cast(self.0.borrowed()).unwrap() 1396 super::children(self)
1623 } 1397 }
1624} 1398}
1625 1399
1626impl<'a> From<MatchExpr<'a>> for MatchExprNode { 1400// MatchExpr
1627 fn from(ast: MatchExpr<'a>) -> MatchExprNode {
1628 let syntax = ast.syntax().owned();
1629 MatchExprNode(syntax)
1630 }
1631}
1632#[derive(Debug, Clone, Copy)] 1401#[derive(Debug, Clone, Copy)]
1633pub struct MatchExpr<'a> { 1402pub struct MatchExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1634 syntax: SyntaxNodeRef<'a>, 1403 syntax: SyntaxNode<R>,
1635} 1404}
1405pub type MatchExpr<'a> = MatchExprNode<RefRoot<'a>>;
1636 1406
1637impl<'a> AstNode<'a> for MatchExpr<'a> { 1407impl<'a> AstNode<'a> for MatchExpr<'a> {
1638 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1408 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1644,6 +1414,16 @@ impl<'a> AstNode<'a> for MatchExpr<'a> {
1644 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1414 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1645} 1415}
1646 1416
1417impl<R: TreeRoot<RaTypes>> MatchExprNode<R> {
1418 pub fn borrowed(&self) -> MatchExpr {
1419 MatchExprNode { syntax: self.syntax.borrowed() }
1420 }
1421 pub fn owned(&self) -> MatchExprNode {
1422 MatchExprNode { syntax: self.syntax.owned() }
1423 }
1424}
1425
1426
1647impl<'a> MatchExpr<'a> { 1427impl<'a> MatchExpr<'a> {
1648 pub fn expr(self) -> Option<Expr<'a>> { 1428 pub fn expr(self) -> Option<Expr<'a>> {
1649 super::child_opt(self) 1429 super::child_opt(self)
@@ -1655,26 +1435,11 @@ impl<'a> MatchExpr<'a> {
1655} 1435}
1656 1436
1657// MatchGuard 1437// 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)] 1438#[derive(Debug, Clone, Copy)]
1675pub struct MatchGuard<'a> { 1439pub struct MatchGuardNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1676 syntax: SyntaxNodeRef<'a>, 1440 syntax: SyntaxNode<R>,
1677} 1441}
1442pub type MatchGuard<'a> = MatchGuardNode<RefRoot<'a>>;
1678 1443
1679impl<'a> AstNode<'a> for MatchGuard<'a> { 1444impl<'a> AstNode<'a> for MatchGuard<'a> {
1680 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1445 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1686,29 +1451,24 @@ impl<'a> AstNode<'a> for MatchGuard<'a> {
1686 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1451 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1687} 1452}
1688 1453
1689impl<'a> MatchGuard<'a> {} 1454impl<R: TreeRoot<RaTypes>> MatchGuardNode<R> {
1690 1455 pub fn borrowed(&self) -> MatchGuard {
1691// MethodCallExpr 1456 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 } 1457 }
1700} 1458 pub fn owned(&self) -> MatchGuardNode {
1701 1459 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 } 1460 }
1707} 1461}
1462
1463
1464impl<'a> MatchGuard<'a> {}
1465
1466// MethodCallExpr
1708#[derive(Debug, Clone, Copy)] 1467#[derive(Debug, Clone, Copy)]
1709pub struct MethodCallExpr<'a> { 1468pub struct MethodCallExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1710 syntax: SyntaxNodeRef<'a>, 1469 syntax: SyntaxNode<R>,
1711} 1470}
1471pub type MethodCallExpr<'a> = MethodCallExprNode<RefRoot<'a>>;
1712 1472
1713impl<'a> AstNode<'a> for MethodCallExpr<'a> { 1473impl<'a> AstNode<'a> for MethodCallExpr<'a> {
1714 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1474 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1720,6 +1480,16 @@ impl<'a> AstNode<'a> for MethodCallExpr<'a> {
1720 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1480 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1721} 1481}
1722 1482
1483impl<R: TreeRoot<RaTypes>> MethodCallExprNode<R> {
1484 pub fn borrowed(&self) -> MethodCallExpr {
1485 MethodCallExprNode { syntax: self.syntax.borrowed() }
1486 }
1487 pub fn owned(&self) -> MethodCallExprNode {
1488 MethodCallExprNode { syntax: self.syntax.owned() }
1489 }
1490}
1491
1492
1723impl<'a> ast::ArgListOwner<'a> for MethodCallExpr<'a> {} 1493impl<'a> ast::ArgListOwner<'a> for MethodCallExpr<'a> {}
1724impl<'a> MethodCallExpr<'a> { 1494impl<'a> MethodCallExpr<'a> {
1725 pub fn expr(self) -> Option<Expr<'a>> { 1495 pub fn expr(self) -> Option<Expr<'a>> {
@@ -1728,26 +1498,11 @@ impl<'a> MethodCallExpr<'a> {
1728} 1498}
1729 1499
1730// Module 1500// 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)] 1501#[derive(Debug, Clone, Copy)]
1748pub struct Module<'a> { 1502pub struct ModuleNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1749 syntax: SyntaxNodeRef<'a>, 1503 syntax: SyntaxNode<R>,
1750} 1504}
1505pub type Module<'a> = ModuleNode<RefRoot<'a>>;
1751 1506
1752impl<'a> AstNode<'a> for Module<'a> { 1507impl<'a> AstNode<'a> for Module<'a> {
1753 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1508 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1759,6 +1514,16 @@ impl<'a> AstNode<'a> for Module<'a> {
1759 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1514 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1760} 1515}
1761 1516
1517impl<R: TreeRoot<RaTypes>> ModuleNode<R> {
1518 pub fn borrowed(&self) -> Module {
1519 ModuleNode { syntax: self.syntax.borrowed() }
1520 }
1521 pub fn owned(&self) -> ModuleNode {
1522 ModuleNode { syntax: self.syntax.owned() }
1523 }
1524}
1525
1526
1762impl<'a> ast::NameOwner<'a> for Module<'a> {} 1527impl<'a> ast::NameOwner<'a> for Module<'a> {}
1763impl<'a> ast::AttrsOwner<'a> for Module<'a> {} 1528impl<'a> ast::AttrsOwner<'a> for Module<'a> {}
1764impl<'a> Module<'a> { 1529impl<'a> Module<'a> {
@@ -1768,22 +1533,6 @@ impl<'a> Module<'a> {
1768} 1533}
1769 1534
1770// ModuleItem 1535// 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)] 1536#[derive(Debug, Clone, Copy)]
1788pub enum ModuleItem<'a> { 1537pub enum ModuleItem<'a> {
1789 StructDef(StructDef<'a>), 1538 StructDef(StructDef<'a>),
@@ -1836,26 +1585,11 @@ impl<'a> AstNode<'a> for ModuleItem<'a> {
1836impl<'a> ModuleItem<'a> {} 1585impl<'a> ModuleItem<'a> {}
1837 1586
1838// Name 1587// 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)] 1588#[derive(Debug, Clone, Copy)]
1856pub struct Name<'a> { 1589pub struct NameNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1857 syntax: SyntaxNodeRef<'a>, 1590 syntax: SyntaxNode<R>,
1858} 1591}
1592pub type Name<'a> = NameNode<RefRoot<'a>>;
1859 1593
1860impl<'a> AstNode<'a> for Name<'a> { 1594impl<'a> AstNode<'a> for Name<'a> {
1861 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1595 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1867,29 +1601,24 @@ impl<'a> AstNode<'a> for Name<'a> {
1867 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1601 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1868} 1602}
1869 1603
1870impl<'a> Name<'a> {} 1604impl<R: TreeRoot<RaTypes>> NameNode<R> {
1871 1605 pub fn borrowed(&self) -> Name {
1872// NameRef 1606 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 } 1607 }
1881} 1608 pub fn owned(&self) -> NameNode {
1882 1609 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 } 1610 }
1888} 1611}
1612
1613
1614impl<'a> Name<'a> {}
1615
1616// NameRef
1889#[derive(Debug, Clone, Copy)] 1617#[derive(Debug, Clone, Copy)]
1890pub struct NameRef<'a> { 1618pub struct NameRefNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1891 syntax: SyntaxNodeRef<'a>, 1619 syntax: SyntaxNode<R>,
1892} 1620}
1621pub type NameRef<'a> = NameRefNode<RefRoot<'a>>;
1893 1622
1894impl<'a> AstNode<'a> for NameRef<'a> { 1623impl<'a> AstNode<'a> for NameRef<'a> {
1895 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1624 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1901,29 +1630,24 @@ impl<'a> AstNode<'a> for NameRef<'a> {
1901 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1630 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1902} 1631}
1903 1632
1904impl<'a> NameRef<'a> {} 1633impl<R: TreeRoot<RaTypes>> NameRefNode<R> {
1905 1634 pub fn borrowed(&self) -> NameRef {
1906// NamedField 1635 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 } 1636 }
1915} 1637 pub fn owned(&self) -> NameRefNode {
1916 1638 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 } 1639 }
1922} 1640}
1641
1642
1643impl<'a> NameRef<'a> {}
1644
1645// NamedField
1923#[derive(Debug, Clone, Copy)] 1646#[derive(Debug, Clone, Copy)]
1924pub struct NamedField<'a> { 1647pub struct NamedFieldNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1925 syntax: SyntaxNodeRef<'a>, 1648 syntax: SyntaxNode<R>,
1926} 1649}
1650pub type NamedField<'a> = NamedFieldNode<RefRoot<'a>>;
1927 1651
1928impl<'a> AstNode<'a> for NamedField<'a> { 1652impl<'a> AstNode<'a> for NamedField<'a> {
1929 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1653 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1935,29 +1659,24 @@ impl<'a> AstNode<'a> for NamedField<'a> {
1935 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1659 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1936} 1660}
1937 1661
1938impl<'a> NamedField<'a> {} 1662impl<R: TreeRoot<RaTypes>> NamedFieldNode<R> {
1939 1663 pub fn borrowed(&self) -> NamedField {
1940// NamedFieldDef 1664 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 } 1665 }
1949} 1666 pub fn owned(&self) -> NamedFieldNode {
1950 1667 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 } 1668 }
1956} 1669}
1670
1671
1672impl<'a> NamedField<'a> {}
1673
1674// NamedFieldDef
1957#[derive(Debug, Clone, Copy)] 1675#[derive(Debug, Clone, Copy)]
1958pub struct NamedFieldDef<'a> { 1676pub struct NamedFieldDefNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1959 syntax: SyntaxNodeRef<'a>, 1677 syntax: SyntaxNode<R>,
1960} 1678}
1679pub type NamedFieldDef<'a> = NamedFieldDefNode<RefRoot<'a>>;
1961 1680
1962impl<'a> AstNode<'a> for NamedFieldDef<'a> { 1681impl<'a> AstNode<'a> for NamedFieldDef<'a> {
1963 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1682 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -1969,31 +1688,26 @@ impl<'a> AstNode<'a> for NamedFieldDef<'a> {
1969 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1688 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1970} 1689}
1971 1690
1691impl<R: TreeRoot<RaTypes>> NamedFieldDefNode<R> {
1692 pub fn borrowed(&self) -> NamedFieldDef {
1693 NamedFieldDefNode { syntax: self.syntax.borrowed() }
1694 }
1695 pub fn owned(&self) -> NamedFieldDefNode {
1696 NamedFieldDefNode { syntax: self.syntax.owned() }
1697 }
1698}
1699
1700
1972impl<'a> ast::NameOwner<'a> for NamedFieldDef<'a> {} 1701impl<'a> ast::NameOwner<'a> for NamedFieldDef<'a> {}
1973impl<'a> ast::AttrsOwner<'a> for NamedFieldDef<'a> {} 1702impl<'a> ast::AttrsOwner<'a> for NamedFieldDef<'a> {}
1974impl<'a> NamedFieldDef<'a> {} 1703impl<'a> NamedFieldDef<'a> {}
1975 1704
1976// NamedFieldList 1705// 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)] 1706#[derive(Debug, Clone, Copy)]
1994pub struct NamedFieldList<'a> { 1707pub struct NamedFieldListNode<R: TreeRoot<RaTypes> = OwnedRoot> {
1995 syntax: SyntaxNodeRef<'a>, 1708 syntax: SyntaxNode<R>,
1996} 1709}
1710pub type NamedFieldList<'a> = NamedFieldListNode<RefRoot<'a>>;
1997 1711
1998impl<'a> AstNode<'a> for NamedFieldList<'a> { 1712impl<'a> AstNode<'a> for NamedFieldList<'a> {
1999 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1713 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2005,29 +1719,24 @@ impl<'a> AstNode<'a> for NamedFieldList<'a> {
2005 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1719 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2006} 1720}
2007 1721
2008impl<'a> NamedFieldList<'a> {} 1722impl<R: TreeRoot<RaTypes>> NamedFieldListNode<R> {
2009 1723 pub fn borrowed(&self) -> NamedFieldList {
2010// NeverType 1724 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 } 1725 }
2019} 1726 pub fn owned(&self) -> NamedFieldListNode {
2020 1727 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 } 1728 }
2026} 1729}
1730
1731
1732impl<'a> NamedFieldList<'a> {}
1733
1734// NeverType
2027#[derive(Debug, Clone, Copy)] 1735#[derive(Debug, Clone, Copy)]
2028pub struct NeverType<'a> { 1736pub struct NeverTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2029 syntax: SyntaxNodeRef<'a>, 1737 syntax: SyntaxNode<R>,
2030} 1738}
1739pub type NeverType<'a> = NeverTypeNode<RefRoot<'a>>;
2031 1740
2032impl<'a> AstNode<'a> for NeverType<'a> { 1741impl<'a> AstNode<'a> for NeverType<'a> {
2033 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1742 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2039,25 +1748,19 @@ impl<'a> AstNode<'a> for NeverType<'a> {
2039 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1748 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2040} 1749}
2041 1750
2042impl<'a> NeverType<'a> {} 1751impl<R: TreeRoot<RaTypes>> NeverTypeNode<R> {
2043 1752 pub fn borrowed(&self) -> NeverType {
2044// NominalDef 1753 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 } 1754 }
2053} 1755 pub fn owned(&self) -> NeverTypeNode {
2054 1756 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 } 1757 }
2060} 1758}
1759
1760
1761impl<'a> NeverType<'a> {}
1762
1763// NominalDef
2061#[derive(Debug, Clone, Copy)] 1764#[derive(Debug, Clone, Copy)]
2062pub enum NominalDef<'a> { 1765pub enum NominalDef<'a> {
2063 StructDef(StructDef<'a>), 1766 StructDef(StructDef<'a>),
@@ -2086,26 +1789,11 @@ impl<'a> ast::AttrsOwner<'a> for NominalDef<'a> {}
2086impl<'a> NominalDef<'a> {} 1789impl<'a> NominalDef<'a> {}
2087 1790
2088// Param 1791// 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)] 1792#[derive(Debug, Clone, Copy)]
2106pub struct Param<'a> { 1793pub struct ParamNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2107 syntax: SyntaxNodeRef<'a>, 1794 syntax: SyntaxNode<R>,
2108} 1795}
1796pub type Param<'a> = ParamNode<RefRoot<'a>>;
2109 1797
2110impl<'a> AstNode<'a> for Param<'a> { 1798impl<'a> AstNode<'a> for Param<'a> {
2111 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1799 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2117,33 +1805,28 @@ impl<'a> AstNode<'a> for Param<'a> {
2117 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1805 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2118} 1806}
2119 1807
2120impl<'a> Param<'a> { 1808impl<R: TreeRoot<RaTypes>> ParamNode<R> {
2121 pub fn pat(self) -> Option<Pat<'a>> { 1809 pub fn borrowed(&self) -> Param {
2122 super::child_opt(self) 1810 ParamNode { syntax: self.syntax.borrowed() }
1811 }
1812 pub fn owned(&self) -> ParamNode {
1813 ParamNode { syntax: self.syntax.owned() }
2123 } 1814 }
2124} 1815}
2125 1816
2126// ParamList
2127
2128#[derive(Debug, Clone)]
2129pub struct ParamListNode(SyntaxNode);
2130 1817
2131impl ParamListNode { 1818impl<'a> Param<'a> {
2132 pub fn ast(&self) -> ParamList { 1819 pub fn pat(self) -> Option<Pat<'a>> {
2133 ParamList::cast(self.0.borrowed()).unwrap() 1820 super::child_opt(self)
2134 } 1821 }
2135} 1822}
2136 1823
2137impl<'a> From<ParamList<'a>> for ParamListNode { 1824// ParamList
2138 fn from(ast: ParamList<'a>) -> ParamListNode {
2139 let syntax = ast.syntax().owned();
2140 ParamListNode(syntax)
2141 }
2142}
2143#[derive(Debug, Clone, Copy)] 1825#[derive(Debug, Clone, Copy)]
2144pub struct ParamList<'a> { 1826pub struct ParamListNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2145 syntax: SyntaxNodeRef<'a>, 1827 syntax: SyntaxNode<R>,
2146} 1828}
1829pub type ParamList<'a> = ParamListNode<RefRoot<'a>>;
2147 1830
2148impl<'a> AstNode<'a> for ParamList<'a> { 1831impl<'a> AstNode<'a> for ParamList<'a> {
2149 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1832 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2155,6 +1838,16 @@ impl<'a> AstNode<'a> for ParamList<'a> {
2155 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1838 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2156} 1839}
2157 1840
1841impl<R: TreeRoot<RaTypes>> ParamListNode<R> {
1842 pub fn borrowed(&self) -> ParamList {
1843 ParamListNode { syntax: self.syntax.borrowed() }
1844 }
1845 pub fn owned(&self) -> ParamListNode {
1846 ParamListNode { syntax: self.syntax.owned() }
1847 }
1848}
1849
1850
2158impl<'a> ParamList<'a> { 1851impl<'a> ParamList<'a> {
2159 pub fn params(self) -> impl Iterator<Item = Param<'a>> + 'a { 1852 pub fn params(self) -> impl Iterator<Item = Param<'a>> + 'a {
2160 super::children(self) 1853 super::children(self)
@@ -2166,26 +1859,11 @@ impl<'a> ParamList<'a> {
2166} 1859}
2167 1860
2168// ParenExpr 1861// 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)] 1862#[derive(Debug, Clone, Copy)]
2186pub struct ParenExpr<'a> { 1863pub struct ParenExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2187 syntax: SyntaxNodeRef<'a>, 1864 syntax: SyntaxNode<R>,
2188} 1865}
1866pub type ParenExpr<'a> = ParenExprNode<RefRoot<'a>>;
2189 1867
2190impl<'a> AstNode<'a> for ParenExpr<'a> { 1868impl<'a> AstNode<'a> for ParenExpr<'a> {
2191 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1869 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2197,29 +1875,24 @@ impl<'a> AstNode<'a> for ParenExpr<'a> {
2197 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1875 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2198} 1876}
2199 1877
2200impl<'a> ParenExpr<'a> {} 1878impl<R: TreeRoot<RaTypes>> ParenExprNode<R> {
2201 1879 pub fn borrowed(&self) -> ParenExpr {
2202// ParenType 1880 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 } 1881 }
2211} 1882 pub fn owned(&self) -> ParenExprNode {
2212 1883 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 } 1884 }
2218} 1885}
1886
1887
1888impl<'a> ParenExpr<'a> {}
1889
1890// ParenType
2219#[derive(Debug, Clone, Copy)] 1891#[derive(Debug, Clone, Copy)]
2220pub struct ParenType<'a> { 1892pub struct ParenTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2221 syntax: SyntaxNodeRef<'a>, 1893 syntax: SyntaxNode<R>,
2222} 1894}
1895pub type ParenType<'a> = ParenTypeNode<RefRoot<'a>>;
2223 1896
2224impl<'a> AstNode<'a> for ParenType<'a> { 1897impl<'a> AstNode<'a> for ParenType<'a> {
2225 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1898 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2231,25 +1904,19 @@ impl<'a> AstNode<'a> for ParenType<'a> {
2231 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1904 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2232} 1905}
2233 1906
2234impl<'a> ParenType<'a> {} 1907impl<R: TreeRoot<RaTypes>> ParenTypeNode<R> {
2235 1908 pub fn borrowed(&self) -> ParenType {
2236// Pat 1909 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 } 1910 }
2245} 1911 pub fn owned(&self) -> ParenTypeNode {
2246 1912 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 } 1913 }
2252} 1914}
1915
1916
1917impl<'a> ParenType<'a> {}
1918
1919// Pat
2253#[derive(Debug, Clone, Copy)] 1920#[derive(Debug, Clone, Copy)]
2254pub enum Pat<'a> { 1921pub enum Pat<'a> {
2255 RefPat(RefPat<'a>), 1922 RefPat(RefPat<'a>),
@@ -2299,26 +1966,11 @@ impl<'a> AstNode<'a> for Pat<'a> {
2299impl<'a> Pat<'a> {} 1966impl<'a> Pat<'a> {}
2300 1967
2301// Path 1968// 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)] 1969#[derive(Debug, Clone, Copy)]
2319pub struct Path<'a> { 1970pub struct PathNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2320 syntax: SyntaxNodeRef<'a>, 1971 syntax: SyntaxNode<R>,
2321} 1972}
1973pub type Path<'a> = PathNode<RefRoot<'a>>;
2322 1974
2323impl<'a> AstNode<'a> for Path<'a> { 1975impl<'a> AstNode<'a> for Path<'a> {
2324 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 1976 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2330,6 +1982,16 @@ impl<'a> AstNode<'a> for Path<'a> {
2330 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 1982 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2331} 1983}
2332 1984
1985impl<R: TreeRoot<RaTypes>> PathNode<R> {
1986 pub fn borrowed(&self) -> Path {
1987 PathNode { syntax: self.syntax.borrowed() }
1988 }
1989 pub fn owned(&self) -> PathNode {
1990 PathNode { syntax: self.syntax.owned() }
1991 }
1992}
1993
1994
2333impl<'a> Path<'a> { 1995impl<'a> Path<'a> {
2334 pub fn segment(self) -> Option<PathSegment<'a>> { 1996 pub fn segment(self) -> Option<PathSegment<'a>> {
2335 super::child_opt(self) 1997 super::child_opt(self)
@@ -2341,26 +2003,11 @@ impl<'a> Path<'a> {
2341} 2003}
2342 2004
2343// PathExpr 2005// 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)] 2006#[derive(Debug, Clone, Copy)]
2361pub struct PathExpr<'a> { 2007pub struct PathExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2362 syntax: SyntaxNodeRef<'a>, 2008 syntax: SyntaxNode<R>,
2363} 2009}
2010pub type PathExpr<'a> = PathExprNode<RefRoot<'a>>;
2364 2011
2365impl<'a> AstNode<'a> for PathExpr<'a> { 2012impl<'a> AstNode<'a> for PathExpr<'a> {
2366 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2013 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2372,33 +2019,28 @@ impl<'a> AstNode<'a> for PathExpr<'a> {
2372 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2019 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2373} 2020}
2374 2021
2375impl<'a> PathExpr<'a> { 2022impl<R: TreeRoot<RaTypes>> PathExprNode<R> {
2376 pub fn path(self) -> Option<Path<'a>> { 2023 pub fn borrowed(&self) -> PathExpr {
2377 super::child_opt(self) 2024 PathExprNode { syntax: self.syntax.borrowed() }
2025 }
2026 pub fn owned(&self) -> PathExprNode {
2027 PathExprNode { syntax: self.syntax.owned() }
2378 } 2028 }
2379} 2029}
2380 2030
2381// PathPat
2382
2383#[derive(Debug, Clone)]
2384pub struct PathPatNode(SyntaxNode);
2385 2031
2386impl PathPatNode { 2032impl<'a> PathExpr<'a> {
2387 pub fn ast(&self) -> PathPat { 2033 pub fn path(self) -> Option<Path<'a>> {
2388 PathPat::cast(self.0.borrowed()).unwrap() 2034 super::child_opt(self)
2389 } 2035 }
2390} 2036}
2391 2037
2392impl<'a> From<PathPat<'a>> for PathPatNode { 2038// PathPat
2393 fn from(ast: PathPat<'a>) -> PathPatNode {
2394 let syntax = ast.syntax().owned();
2395 PathPatNode(syntax)
2396 }
2397}
2398#[derive(Debug, Clone, Copy)] 2039#[derive(Debug, Clone, Copy)]
2399pub struct PathPat<'a> { 2040pub struct PathPatNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2400 syntax: SyntaxNodeRef<'a>, 2041 syntax: SyntaxNode<R>,
2401} 2042}
2043pub type PathPat<'a> = PathPatNode<RefRoot<'a>>;
2402 2044
2403impl<'a> AstNode<'a> for PathPat<'a> { 2045impl<'a> AstNode<'a> for PathPat<'a> {
2404 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2046 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2410,29 +2052,24 @@ impl<'a> AstNode<'a> for PathPat<'a> {
2410 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2052 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2411} 2053}
2412 2054
2413impl<'a> PathPat<'a> {} 2055impl<R: TreeRoot<RaTypes>> PathPatNode<R> {
2414 2056 pub fn borrowed(&self) -> PathPat {
2415// PathSegment 2057 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 } 2058 }
2424} 2059 pub fn owned(&self) -> PathPatNode {
2425 2060 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 } 2061 }
2431} 2062}
2063
2064
2065impl<'a> PathPat<'a> {}
2066
2067// PathSegment
2432#[derive(Debug, Clone, Copy)] 2068#[derive(Debug, Clone, Copy)]
2433pub struct PathSegment<'a> { 2069pub struct PathSegmentNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2434 syntax: SyntaxNodeRef<'a>, 2070 syntax: SyntaxNode<R>,
2435} 2071}
2072pub type PathSegment<'a> = PathSegmentNode<RefRoot<'a>>;
2436 2073
2437impl<'a> AstNode<'a> for PathSegment<'a> { 2074impl<'a> AstNode<'a> for PathSegment<'a> {
2438 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2075 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2444,33 +2081,28 @@ impl<'a> AstNode<'a> for PathSegment<'a> {
2444 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2081 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2445} 2082}
2446 2083
2447impl<'a> PathSegment<'a> { 2084impl<R: TreeRoot<RaTypes>> PathSegmentNode<R> {
2448 pub fn name_ref(self) -> Option<NameRef<'a>> { 2085 pub fn borrowed(&self) -> PathSegment {
2449 super::child_opt(self) 2086 PathSegmentNode { syntax: self.syntax.borrowed() }
2087 }
2088 pub fn owned(&self) -> PathSegmentNode {
2089 PathSegmentNode { syntax: self.syntax.owned() }
2450 } 2090 }
2451} 2091}
2452 2092
2453// PathType
2454
2455#[derive(Debug, Clone)]
2456pub struct PathTypeNode(SyntaxNode);
2457 2093
2458impl PathTypeNode { 2094impl<'a> PathSegment<'a> {
2459 pub fn ast(&self) -> PathType { 2095 pub fn name_ref(self) -> Option<NameRef<'a>> {
2460 PathType::cast(self.0.borrowed()).unwrap() 2096 super::child_opt(self)
2461 } 2097 }
2462} 2098}
2463 2099
2464impl<'a> From<PathType<'a>> for PathTypeNode { 2100// PathType
2465 fn from(ast: PathType<'a>) -> PathTypeNode {
2466 let syntax = ast.syntax().owned();
2467 PathTypeNode(syntax)
2468 }
2469}
2470#[derive(Debug, Clone, Copy)] 2101#[derive(Debug, Clone, Copy)]
2471pub struct PathType<'a> { 2102pub struct PathTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2472 syntax: SyntaxNodeRef<'a>, 2103 syntax: SyntaxNode<R>,
2473} 2104}
2105pub type PathType<'a> = PathTypeNode<RefRoot<'a>>;
2474 2106
2475impl<'a> AstNode<'a> for PathType<'a> { 2107impl<'a> AstNode<'a> for PathType<'a> {
2476 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2108 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2482,29 +2114,24 @@ impl<'a> AstNode<'a> for PathType<'a> {
2482 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2114 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2483} 2115}
2484 2116
2485impl<'a> PathType<'a> {} 2117impl<R: TreeRoot<RaTypes>> PathTypeNode<R> {
2486 2118 pub fn borrowed(&self) -> PathType {
2487// PlaceholderPat 2119 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 } 2120 }
2496} 2121 pub fn owned(&self) -> PathTypeNode {
2497 2122 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 } 2123 }
2503} 2124}
2125
2126
2127impl<'a> PathType<'a> {}
2128
2129// PlaceholderPat
2504#[derive(Debug, Clone, Copy)] 2130#[derive(Debug, Clone, Copy)]
2505pub struct PlaceholderPat<'a> { 2131pub struct PlaceholderPatNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2506 syntax: SyntaxNodeRef<'a>, 2132 syntax: SyntaxNode<R>,
2507} 2133}
2134pub type PlaceholderPat<'a> = PlaceholderPatNode<RefRoot<'a>>;
2508 2135
2509impl<'a> AstNode<'a> for PlaceholderPat<'a> { 2136impl<'a> AstNode<'a> for PlaceholderPat<'a> {
2510 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2137 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2516,29 +2143,24 @@ impl<'a> AstNode<'a> for PlaceholderPat<'a> {
2516 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2143 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2517} 2144}
2518 2145
2519impl<'a> PlaceholderPat<'a> {} 2146impl<R: TreeRoot<RaTypes>> PlaceholderPatNode<R> {
2520 2147 pub fn borrowed(&self) -> PlaceholderPat {
2521// PlaceholderType 2148 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 } 2149 }
2530} 2150 pub fn owned(&self) -> PlaceholderPatNode {
2531 2151 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 } 2152 }
2537} 2153}
2154
2155
2156impl<'a> PlaceholderPat<'a> {}
2157
2158// PlaceholderType
2538#[derive(Debug, Clone, Copy)] 2159#[derive(Debug, Clone, Copy)]
2539pub struct PlaceholderType<'a> { 2160pub struct PlaceholderTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2540 syntax: SyntaxNodeRef<'a>, 2161 syntax: SyntaxNode<R>,
2541} 2162}
2163pub type PlaceholderType<'a> = PlaceholderTypeNode<RefRoot<'a>>;
2542 2164
2543impl<'a> AstNode<'a> for PlaceholderType<'a> { 2165impl<'a> AstNode<'a> for PlaceholderType<'a> {
2544 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2166 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2550,29 +2172,24 @@ impl<'a> AstNode<'a> for PlaceholderType<'a> {
2550 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2172 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2551} 2173}
2552 2174
2553impl<'a> PlaceholderType<'a> {} 2175impl<R: TreeRoot<RaTypes>> PlaceholderTypeNode<R> {
2554 2176 pub fn borrowed(&self) -> PlaceholderType {
2555// PointerType 2177 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 } 2178 }
2564} 2179 pub fn owned(&self) -> PlaceholderTypeNode {
2565 2180 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 } 2181 }
2571} 2182}
2183
2184
2185impl<'a> PlaceholderType<'a> {}
2186
2187// PointerType
2572#[derive(Debug, Clone, Copy)] 2188#[derive(Debug, Clone, Copy)]
2573pub struct PointerType<'a> { 2189pub struct PointerTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2574 syntax: SyntaxNodeRef<'a>, 2190 syntax: SyntaxNode<R>,
2575} 2191}
2192pub type PointerType<'a> = PointerTypeNode<RefRoot<'a>>;
2576 2193
2577impl<'a> AstNode<'a> for PointerType<'a> { 2194impl<'a> AstNode<'a> for PointerType<'a> {
2578 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2195 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2584,29 +2201,24 @@ impl<'a> AstNode<'a> for PointerType<'a> {
2584 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2201 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2585} 2202}
2586 2203
2587impl<'a> PointerType<'a> {} 2204impl<R: TreeRoot<RaTypes>> PointerTypeNode<R> {
2588 2205 pub fn borrowed(&self) -> PointerType {
2589// PrefixExpr 2206 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 } 2207 }
2598} 2208 pub fn owned(&self) -> PointerTypeNode {
2599 2209 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 } 2210 }
2605} 2211}
2212
2213
2214impl<'a> PointerType<'a> {}
2215
2216// PrefixExpr
2606#[derive(Debug, Clone, Copy)] 2217#[derive(Debug, Clone, Copy)]
2607pub struct PrefixExpr<'a> { 2218pub struct PrefixExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2608 syntax: SyntaxNodeRef<'a>, 2219 syntax: SyntaxNode<R>,
2609} 2220}
2221pub type PrefixExpr<'a> = PrefixExprNode<RefRoot<'a>>;
2610 2222
2611impl<'a> AstNode<'a> for PrefixExpr<'a> { 2223impl<'a> AstNode<'a> for PrefixExpr<'a> {
2612 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2224 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2618,29 +2230,24 @@ impl<'a> AstNode<'a> for PrefixExpr<'a> {
2618 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2230 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2619} 2231}
2620 2232
2621impl<'a> PrefixExpr<'a> {} 2233impl<R: TreeRoot<RaTypes>> PrefixExprNode<R> {
2622 2234 pub fn borrowed(&self) -> PrefixExpr {
2623// RangeExpr 2235 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 } 2236 }
2632} 2237 pub fn owned(&self) -> PrefixExprNode {
2633 2238 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 } 2239 }
2639} 2240}
2241
2242
2243impl<'a> PrefixExpr<'a> {}
2244
2245// RangeExpr
2640#[derive(Debug, Clone, Copy)] 2246#[derive(Debug, Clone, Copy)]
2641pub struct RangeExpr<'a> { 2247pub struct RangeExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2642 syntax: SyntaxNodeRef<'a>, 2248 syntax: SyntaxNode<R>,
2643} 2249}
2250pub type RangeExpr<'a> = RangeExprNode<RefRoot<'a>>;
2644 2251
2645impl<'a> AstNode<'a> for RangeExpr<'a> { 2252impl<'a> AstNode<'a> for RangeExpr<'a> {
2646 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2253 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2652,29 +2259,24 @@ impl<'a> AstNode<'a> for RangeExpr<'a> {
2652 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2259 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2653} 2260}
2654 2261
2655impl<'a> RangeExpr<'a> {} 2262impl<R: TreeRoot<RaTypes>> RangeExprNode<R> {
2656 2263 pub fn borrowed(&self) -> RangeExpr {
2657// RangePat 2264 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 } 2265 }
2666} 2266 pub fn owned(&self) -> RangeExprNode {
2667 2267 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 } 2268 }
2673} 2269}
2270
2271
2272impl<'a> RangeExpr<'a> {}
2273
2274// RangePat
2674#[derive(Debug, Clone, Copy)] 2275#[derive(Debug, Clone, Copy)]
2675pub struct RangePat<'a> { 2276pub struct RangePatNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2676 syntax: SyntaxNodeRef<'a>, 2277 syntax: SyntaxNode<R>,
2677} 2278}
2279pub type RangePat<'a> = RangePatNode<RefRoot<'a>>;
2678 2280
2679impl<'a> AstNode<'a> for RangePat<'a> { 2281impl<'a> AstNode<'a> for RangePat<'a> {
2680 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2282 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2686,29 +2288,24 @@ impl<'a> AstNode<'a> for RangePat<'a> {
2686 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2288 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2687} 2289}
2688 2290
2689impl<'a> RangePat<'a> {} 2291impl<R: TreeRoot<RaTypes>> RangePatNode<R> {
2690 2292 pub fn borrowed(&self) -> RangePat {
2691// RefExpr 2293 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 } 2294 }
2700} 2295 pub fn owned(&self) -> RangePatNode {
2701 2296 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 } 2297 }
2707} 2298}
2299
2300
2301impl<'a> RangePat<'a> {}
2302
2303// RefExpr
2708#[derive(Debug, Clone, Copy)] 2304#[derive(Debug, Clone, Copy)]
2709pub struct RefExpr<'a> { 2305pub struct RefExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2710 syntax: SyntaxNodeRef<'a>, 2306 syntax: SyntaxNode<R>,
2711} 2307}
2308pub type RefExpr<'a> = RefExprNode<RefRoot<'a>>;
2712 2309
2713impl<'a> AstNode<'a> for RefExpr<'a> { 2310impl<'a> AstNode<'a> for RefExpr<'a> {
2714 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2311 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2720,29 +2317,24 @@ impl<'a> AstNode<'a> for RefExpr<'a> {
2720 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2317 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2721} 2318}
2722 2319
2723impl<'a> RefExpr<'a> {} 2320impl<R: TreeRoot<RaTypes>> RefExprNode<R> {
2724 2321 pub fn borrowed(&self) -> RefExpr {
2725// RefPat 2322 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 } 2323 }
2734} 2324 pub fn owned(&self) -> RefExprNode {
2735 2325 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 } 2326 }
2741} 2327}
2328
2329
2330impl<'a> RefExpr<'a> {}
2331
2332// RefPat
2742#[derive(Debug, Clone, Copy)] 2333#[derive(Debug, Clone, Copy)]
2743pub struct RefPat<'a> { 2334pub struct RefPatNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2744 syntax: SyntaxNodeRef<'a>, 2335 syntax: SyntaxNode<R>,
2745} 2336}
2337pub type RefPat<'a> = RefPatNode<RefRoot<'a>>;
2746 2338
2747impl<'a> AstNode<'a> for RefPat<'a> { 2339impl<'a> AstNode<'a> for RefPat<'a> {
2748 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2340 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2754,29 +2346,24 @@ impl<'a> AstNode<'a> for RefPat<'a> {
2754 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2346 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2755} 2347}
2756 2348
2757impl<'a> RefPat<'a> {} 2349impl<R: TreeRoot<RaTypes>> RefPatNode<R> {
2758 2350 pub fn borrowed(&self) -> RefPat {
2759// ReferenceType 2351 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 } 2352 }
2768} 2353 pub fn owned(&self) -> RefPatNode {
2769 2354 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 } 2355 }
2775} 2356}
2357
2358
2359impl<'a> RefPat<'a> {}
2360
2361// ReferenceType
2776#[derive(Debug, Clone, Copy)] 2362#[derive(Debug, Clone, Copy)]
2777pub struct ReferenceType<'a> { 2363pub struct ReferenceTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2778 syntax: SyntaxNodeRef<'a>, 2364 syntax: SyntaxNode<R>,
2779} 2365}
2366pub type ReferenceType<'a> = ReferenceTypeNode<RefRoot<'a>>;
2780 2367
2781impl<'a> AstNode<'a> for ReferenceType<'a> { 2368impl<'a> AstNode<'a> for ReferenceType<'a> {
2782 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2369 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2788,29 +2375,24 @@ impl<'a> AstNode<'a> for ReferenceType<'a> {
2788 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2375 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2789} 2376}
2790 2377
2791impl<'a> ReferenceType<'a> {} 2378impl<R: TreeRoot<RaTypes>> ReferenceTypeNode<R> {
2792 2379 pub fn borrowed(&self) -> ReferenceType {
2793// RetType 2380 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 } 2381 }
2802} 2382 pub fn owned(&self) -> ReferenceTypeNode {
2803 2383 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 } 2384 }
2809} 2385}
2386
2387
2388impl<'a> ReferenceType<'a> {}
2389
2390// RetType
2810#[derive(Debug, Clone, Copy)] 2391#[derive(Debug, Clone, Copy)]
2811pub struct RetType<'a> { 2392pub struct RetTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2812 syntax: SyntaxNodeRef<'a>, 2393 syntax: SyntaxNode<R>,
2813} 2394}
2395pub type RetType<'a> = RetTypeNode<RefRoot<'a>>;
2814 2396
2815impl<'a> AstNode<'a> for RetType<'a> { 2397impl<'a> AstNode<'a> for RetType<'a> {
2816 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2398 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2822,29 +2404,24 @@ impl<'a> AstNode<'a> for RetType<'a> {
2822 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2404 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2823} 2405}
2824 2406
2825impl<'a> RetType<'a> {} 2407impl<R: TreeRoot<RaTypes>> RetTypeNode<R> {
2826 2408 pub fn borrowed(&self) -> RetType {
2827// ReturnExpr 2409 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 } 2410 }
2836} 2411 pub fn owned(&self) -> RetTypeNode {
2837 2412 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 } 2413 }
2843} 2414}
2415
2416
2417impl<'a> RetType<'a> {}
2418
2419// ReturnExpr
2844#[derive(Debug, Clone, Copy)] 2420#[derive(Debug, Clone, Copy)]
2845pub struct ReturnExpr<'a> { 2421pub struct ReturnExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2846 syntax: SyntaxNodeRef<'a>, 2422 syntax: SyntaxNode<R>,
2847} 2423}
2424pub type ReturnExpr<'a> = ReturnExprNode<RefRoot<'a>>;
2848 2425
2849impl<'a> AstNode<'a> for ReturnExpr<'a> { 2426impl<'a> AstNode<'a> for ReturnExpr<'a> {
2850 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2427 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2856,29 +2433,24 @@ impl<'a> AstNode<'a> for ReturnExpr<'a> {
2856 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2433 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2857} 2434}
2858 2435
2859impl<'a> ReturnExpr<'a> {} 2436impl<R: TreeRoot<RaTypes>> ReturnExprNode<R> {
2860 2437 pub fn borrowed(&self) -> ReturnExpr {
2861// Root 2438 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 } 2439 }
2870} 2440 pub fn owned(&self) -> ReturnExprNode {
2871 2441 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 } 2442 }
2877} 2443}
2444
2445
2446impl<'a> ReturnExpr<'a> {}
2447
2448// Root
2878#[derive(Debug, Clone, Copy)] 2449#[derive(Debug, Clone, Copy)]
2879pub struct Root<'a> { 2450pub struct RootNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2880 syntax: SyntaxNodeRef<'a>, 2451 syntax: SyntaxNode<R>,
2881} 2452}
2453pub type Root<'a> = RootNode<RefRoot<'a>>;
2882 2454
2883impl<'a> AstNode<'a> for Root<'a> { 2455impl<'a> AstNode<'a> for Root<'a> {
2884 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2456 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2890,6 +2462,16 @@ impl<'a> AstNode<'a> for Root<'a> {
2890 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2462 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2891} 2463}
2892 2464
2465impl<R: TreeRoot<RaTypes>> RootNode<R> {
2466 pub fn borrowed(&self) -> Root {
2467 RootNode { syntax: self.syntax.borrowed() }
2468 }
2469 pub fn owned(&self) -> RootNode {
2470 RootNode { syntax: self.syntax.owned() }
2471 }
2472}
2473
2474
2893impl<'a> ast::ModuleItemOwner<'a> for Root<'a> {} 2475impl<'a> ast::ModuleItemOwner<'a> for Root<'a> {}
2894impl<'a> ast::FnDefOwner<'a> for Root<'a> {} 2476impl<'a> ast::FnDefOwner<'a> for Root<'a> {}
2895impl<'a> Root<'a> { 2477impl<'a> Root<'a> {
@@ -2899,26 +2481,11 @@ impl<'a> Root<'a> {
2899} 2481}
2900 2482
2901// SelfParam 2483// 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)] 2484#[derive(Debug, Clone, Copy)]
2919pub struct SelfParam<'a> { 2485pub struct SelfParamNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2920 syntax: SyntaxNodeRef<'a>, 2486 syntax: SyntaxNode<R>,
2921} 2487}
2488pub type SelfParam<'a> = SelfParamNode<RefRoot<'a>>;
2922 2489
2923impl<'a> AstNode<'a> for SelfParam<'a> { 2490impl<'a> AstNode<'a> for SelfParam<'a> {
2924 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2491 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2930,29 +2497,24 @@ impl<'a> AstNode<'a> for SelfParam<'a> {
2930 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2497 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2931} 2498}
2932 2499
2933impl<'a> SelfParam<'a> {} 2500impl<R: TreeRoot<RaTypes>> SelfParamNode<R> {
2934 2501 pub fn borrowed(&self) -> SelfParam {
2935// SlicePat 2502 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 } 2503 }
2944} 2504 pub fn owned(&self) -> SelfParamNode {
2945 2505 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 } 2506 }
2951} 2507}
2508
2509
2510impl<'a> SelfParam<'a> {}
2511
2512// SlicePat
2952#[derive(Debug, Clone, Copy)] 2513#[derive(Debug, Clone, Copy)]
2953pub struct SlicePat<'a> { 2514pub struct SlicePatNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2954 syntax: SyntaxNodeRef<'a>, 2515 syntax: SyntaxNode<R>,
2955} 2516}
2517pub type SlicePat<'a> = SlicePatNode<RefRoot<'a>>;
2956 2518
2957impl<'a> AstNode<'a> for SlicePat<'a> { 2519impl<'a> AstNode<'a> for SlicePat<'a> {
2958 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2520 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2964,29 +2526,24 @@ impl<'a> AstNode<'a> for SlicePat<'a> {
2964 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2526 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2965} 2527}
2966 2528
2967impl<'a> SlicePat<'a> {} 2529impl<R: TreeRoot<RaTypes>> SlicePatNode<R> {
2968 2530 pub fn borrowed(&self) -> SlicePat {
2969// SliceType 2531 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 } 2532 }
2978} 2533 pub fn owned(&self) -> SlicePatNode {
2979 2534 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 } 2535 }
2985} 2536}
2537
2538
2539impl<'a> SlicePat<'a> {}
2540
2541// SliceType
2986#[derive(Debug, Clone, Copy)] 2542#[derive(Debug, Clone, Copy)]
2987pub struct SliceType<'a> { 2543pub struct SliceTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2988 syntax: SyntaxNodeRef<'a>, 2544 syntax: SyntaxNode<R>,
2989} 2545}
2546pub type SliceType<'a> = SliceTypeNode<RefRoot<'a>>;
2990 2547
2991impl<'a> AstNode<'a> for SliceType<'a> { 2548impl<'a> AstNode<'a> for SliceType<'a> {
2992 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2549 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -2998,29 +2555,24 @@ impl<'a> AstNode<'a> for SliceType<'a> {
2998 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2555 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2999} 2556}
3000 2557
3001impl<'a> SliceType<'a> {} 2558impl<R: TreeRoot<RaTypes>> SliceTypeNode<R> {
3002 2559 pub fn borrowed(&self) -> SliceType {
3003// StaticDef 2560 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 } 2561 }
3012} 2562 pub fn owned(&self) -> SliceTypeNode {
3013 2563 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 } 2564 }
3019} 2565}
2566
2567
2568impl<'a> SliceType<'a> {}
2569
2570// StaticDef
3020#[derive(Debug, Clone, Copy)] 2571#[derive(Debug, Clone, Copy)]
3021pub struct StaticDef<'a> { 2572pub struct StaticDefNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3022 syntax: SyntaxNodeRef<'a>, 2573 syntax: SyntaxNode<R>,
3023} 2574}
2575pub type StaticDef<'a> = StaticDefNode<RefRoot<'a>>;
3024 2576
3025impl<'a> AstNode<'a> for StaticDef<'a> { 2577impl<'a> AstNode<'a> for StaticDef<'a> {
3026 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2578 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3032,28 +2584,22 @@ impl<'a> AstNode<'a> for StaticDef<'a> {
3032 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2584 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3033} 2585}
3034 2586
2587impl<R: TreeRoot<RaTypes>> StaticDefNode<R> {
2588 pub fn borrowed(&self) -> StaticDef {
2589 StaticDefNode { syntax: self.syntax.borrowed() }
2590 }
2591 pub fn owned(&self) -> StaticDefNode {
2592 StaticDefNode { syntax: self.syntax.owned() }
2593 }
2594}
2595
2596
3035impl<'a> ast::NameOwner<'a> for StaticDef<'a> {} 2597impl<'a> ast::NameOwner<'a> for StaticDef<'a> {}
3036impl<'a> ast::TypeParamsOwner<'a> for StaticDef<'a> {} 2598impl<'a> ast::TypeParamsOwner<'a> for StaticDef<'a> {}
3037impl<'a> ast::AttrsOwner<'a> for StaticDef<'a> {} 2599impl<'a> ast::AttrsOwner<'a> for StaticDef<'a> {}
3038impl<'a> StaticDef<'a> {} 2600impl<'a> StaticDef<'a> {}
3039 2601
3040// Stmt 2602// 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)] 2603#[derive(Debug, Clone, Copy)]
3058pub enum Stmt<'a> { 2604pub enum Stmt<'a> {
3059 ExprStmt(ExprStmt<'a>), 2605 ExprStmt(ExprStmt<'a>),
@@ -3079,26 +2625,11 @@ impl<'a> AstNode<'a> for Stmt<'a> {
3079impl<'a> Stmt<'a> {} 2625impl<'a> Stmt<'a> {}
3080 2626
3081// StructDef 2627// 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)] 2628#[derive(Debug, Clone, Copy)]
3099pub struct StructDef<'a> { 2629pub struct StructDefNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3100 syntax: SyntaxNodeRef<'a>, 2630 syntax: SyntaxNode<R>,
3101} 2631}
2632pub type StructDef<'a> = StructDefNode<RefRoot<'a>>;
3102 2633
3103impl<'a> AstNode<'a> for StructDef<'a> { 2634impl<'a> AstNode<'a> for StructDef<'a> {
3104 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2635 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3110,6 +2641,16 @@ impl<'a> AstNode<'a> for StructDef<'a> {
3110 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2641 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3111} 2642}
3112 2643
2644impl<R: TreeRoot<RaTypes>> StructDefNode<R> {
2645 pub fn borrowed(&self) -> StructDef {
2646 StructDefNode { syntax: self.syntax.borrowed() }
2647 }
2648 pub fn owned(&self) -> StructDefNode {
2649 StructDefNode { syntax: self.syntax.owned() }
2650 }
2651}
2652
2653
3113impl<'a> ast::NameOwner<'a> for StructDef<'a> {} 2654impl<'a> ast::NameOwner<'a> for StructDef<'a> {}
3114impl<'a> ast::TypeParamsOwner<'a> for StructDef<'a> {} 2655impl<'a> ast::TypeParamsOwner<'a> for StructDef<'a> {}
3115impl<'a> ast::AttrsOwner<'a> for StructDef<'a> {} 2656impl<'a> ast::AttrsOwner<'a> for StructDef<'a> {}
@@ -3120,26 +2661,11 @@ impl<'a> StructDef<'a> {
3120} 2661}
3121 2662
3122// StructLit 2663// 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)] 2664#[derive(Debug, Clone, Copy)]
3140pub struct StructLit<'a> { 2665pub struct StructLitNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3141 syntax: SyntaxNodeRef<'a>, 2666 syntax: SyntaxNode<R>,
3142} 2667}
2668pub type StructLit<'a> = StructLitNode<RefRoot<'a>>;
3143 2669
3144impl<'a> AstNode<'a> for StructLit<'a> { 2670impl<'a> AstNode<'a> for StructLit<'a> {
3145 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2671 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3151,29 +2677,24 @@ impl<'a> AstNode<'a> for StructLit<'a> {
3151 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2677 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3152} 2678}
3153 2679
3154impl<'a> StructLit<'a> {} 2680impl<R: TreeRoot<RaTypes>> StructLitNode<R> {
3155 2681 pub fn borrowed(&self) -> StructLit {
3156// StructPat 2682 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 } 2683 }
3165} 2684 pub fn owned(&self) -> StructLitNode {
3166 2685 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 } 2686 }
3172} 2687}
2688
2689
2690impl<'a> StructLit<'a> {}
2691
2692// StructPat
3173#[derive(Debug, Clone, Copy)] 2693#[derive(Debug, Clone, Copy)]
3174pub struct StructPat<'a> { 2694pub struct StructPatNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3175 syntax: SyntaxNodeRef<'a>, 2695 syntax: SyntaxNode<R>,
3176} 2696}
2697pub type StructPat<'a> = StructPatNode<RefRoot<'a>>;
3177 2698
3178impl<'a> AstNode<'a> for StructPat<'a> { 2699impl<'a> AstNode<'a> for StructPat<'a> {
3179 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2700 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3185,29 +2706,24 @@ impl<'a> AstNode<'a> for StructPat<'a> {
3185 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2706 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3186} 2707}
3187 2708
3188impl<'a> StructPat<'a> {} 2709impl<R: TreeRoot<RaTypes>> StructPatNode<R> {
3189 2710 pub fn borrowed(&self) -> StructPat {
3190// TokenTree 2711 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 } 2712 }
3199} 2713 pub fn owned(&self) -> StructPatNode {
3200 2714 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 } 2715 }
3206} 2716}
2717
2718
2719impl<'a> StructPat<'a> {}
2720
2721// TokenTree
3207#[derive(Debug, Clone, Copy)] 2722#[derive(Debug, Clone, Copy)]
3208pub struct TokenTree<'a> { 2723pub struct TokenTreeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3209 syntax: SyntaxNodeRef<'a>, 2724 syntax: SyntaxNode<R>,
3210} 2725}
2726pub type TokenTree<'a> = TokenTreeNode<RefRoot<'a>>;
3211 2727
3212impl<'a> AstNode<'a> for TokenTree<'a> { 2728impl<'a> AstNode<'a> for TokenTree<'a> {
3213 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2729 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3219,29 +2735,24 @@ impl<'a> AstNode<'a> for TokenTree<'a> {
3219 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2735 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3220} 2736}
3221 2737
3222impl<'a> TokenTree<'a> {} 2738impl<R: TreeRoot<RaTypes>> TokenTreeNode<R> {
3223 2739 pub fn borrowed(&self) -> TokenTree {
3224// TraitDef 2740 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 } 2741 }
3233} 2742 pub fn owned(&self) -> TokenTreeNode {
3234 2743 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 } 2744 }
3240} 2745}
2746
2747
2748impl<'a> TokenTree<'a> {}
2749
2750// TraitDef
3241#[derive(Debug, Clone, Copy)] 2751#[derive(Debug, Clone, Copy)]
3242pub struct TraitDef<'a> { 2752pub struct TraitDefNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3243 syntax: SyntaxNodeRef<'a>, 2753 syntax: SyntaxNode<R>,
3244} 2754}
2755pub type TraitDef<'a> = TraitDefNode<RefRoot<'a>>;
3245 2756
3246impl<'a> AstNode<'a> for TraitDef<'a> { 2757impl<'a> AstNode<'a> for TraitDef<'a> {
3247 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2758 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3253,31 +2764,26 @@ impl<'a> AstNode<'a> for TraitDef<'a> {
3253 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2764 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3254} 2765}
3255 2766
2767impl<R: TreeRoot<RaTypes>> TraitDefNode<R> {
2768 pub fn borrowed(&self) -> TraitDef {
2769 TraitDefNode { syntax: self.syntax.borrowed() }
2770 }
2771 pub fn owned(&self) -> TraitDefNode {
2772 TraitDefNode { syntax: self.syntax.owned() }
2773 }
2774}
2775
2776
3256impl<'a> ast::NameOwner<'a> for TraitDef<'a> {} 2777impl<'a> ast::NameOwner<'a> for TraitDef<'a> {}
3257impl<'a> ast::AttrsOwner<'a> for TraitDef<'a> {} 2778impl<'a> ast::AttrsOwner<'a> for TraitDef<'a> {}
3258impl<'a> TraitDef<'a> {} 2779impl<'a> TraitDef<'a> {}
3259 2780
3260// TryExpr 2781// 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)] 2782#[derive(Debug, Clone, Copy)]
3278pub struct TryExpr<'a> { 2783pub struct TryExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3279 syntax: SyntaxNodeRef<'a>, 2784 syntax: SyntaxNode<R>,
3280} 2785}
2786pub type TryExpr<'a> = TryExprNode<RefRoot<'a>>;
3281 2787
3282impl<'a> AstNode<'a> for TryExpr<'a> { 2788impl<'a> AstNode<'a> for TryExpr<'a> {
3283 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2789 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3289,29 +2795,24 @@ impl<'a> AstNode<'a> for TryExpr<'a> {
3289 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2795 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3290} 2796}
3291 2797
3292impl<'a> TryExpr<'a> {} 2798impl<R: TreeRoot<RaTypes>> TryExprNode<R> {
3293 2799 pub fn borrowed(&self) -> TryExpr {
3294// TupleExpr 2800 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 } 2801 }
3303} 2802 pub fn owned(&self) -> TryExprNode {
3304 2803 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 } 2804 }
3310} 2805}
2806
2807
2808impl<'a> TryExpr<'a> {}
2809
2810// TupleExpr
3311#[derive(Debug, Clone, Copy)] 2811#[derive(Debug, Clone, Copy)]
3312pub struct TupleExpr<'a> { 2812pub struct TupleExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3313 syntax: SyntaxNodeRef<'a>, 2813 syntax: SyntaxNode<R>,
3314} 2814}
2815pub type TupleExpr<'a> = TupleExprNode<RefRoot<'a>>;
3315 2816
3316impl<'a> AstNode<'a> for TupleExpr<'a> { 2817impl<'a> AstNode<'a> for TupleExpr<'a> {
3317 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2818 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3323,29 +2824,24 @@ impl<'a> AstNode<'a> for TupleExpr<'a> {
3323 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2824 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3324} 2825}
3325 2826
3326impl<'a> TupleExpr<'a> {} 2827impl<R: TreeRoot<RaTypes>> TupleExprNode<R> {
3327 2828 pub fn borrowed(&self) -> TupleExpr {
3328// TuplePat 2829 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 } 2830 }
3337} 2831 pub fn owned(&self) -> TupleExprNode {
3338 2832 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 } 2833 }
3344} 2834}
2835
2836
2837impl<'a> TupleExpr<'a> {}
2838
2839// TuplePat
3345#[derive(Debug, Clone, Copy)] 2840#[derive(Debug, Clone, Copy)]
3346pub struct TuplePat<'a> { 2841pub struct TuplePatNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3347 syntax: SyntaxNodeRef<'a>, 2842 syntax: SyntaxNode<R>,
3348} 2843}
2844pub type TuplePat<'a> = TuplePatNode<RefRoot<'a>>;
3349 2845
3350impl<'a> AstNode<'a> for TuplePat<'a> { 2846impl<'a> AstNode<'a> for TuplePat<'a> {
3351 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2847 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3357,29 +2853,24 @@ impl<'a> AstNode<'a> for TuplePat<'a> {
3357 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2853 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3358} 2854}
3359 2855
3360impl<'a> TuplePat<'a> {} 2856impl<R: TreeRoot<RaTypes>> TuplePatNode<R> {
3361 2857 pub fn borrowed(&self) -> TuplePat {
3362// TupleStructPat 2858 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 } 2859 }
3371} 2860 pub fn owned(&self) -> TuplePatNode {
3372 2861 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 } 2862 }
3378} 2863}
2864
2865
2866impl<'a> TuplePat<'a> {}
2867
2868// TupleStructPat
3379#[derive(Debug, Clone, Copy)] 2869#[derive(Debug, Clone, Copy)]
3380pub struct TupleStructPat<'a> { 2870pub struct TupleStructPatNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3381 syntax: SyntaxNodeRef<'a>, 2871 syntax: SyntaxNode<R>,
3382} 2872}
2873pub type TupleStructPat<'a> = TupleStructPatNode<RefRoot<'a>>;
3383 2874
3384impl<'a> AstNode<'a> for TupleStructPat<'a> { 2875impl<'a> AstNode<'a> for TupleStructPat<'a> {
3385 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2876 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3391,29 +2882,24 @@ impl<'a> AstNode<'a> for TupleStructPat<'a> {
3391 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2882 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3392} 2883}
3393 2884
3394impl<'a> TupleStructPat<'a> {} 2885impl<R: TreeRoot<RaTypes>> TupleStructPatNode<R> {
3395 2886 pub fn borrowed(&self) -> TupleStructPat {
3396// TupleType 2887 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 } 2888 }
3405} 2889 pub fn owned(&self) -> TupleStructPatNode {
3406 2890 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 } 2891 }
3412} 2892}
2893
2894
2895impl<'a> TupleStructPat<'a> {}
2896
2897// TupleType
3413#[derive(Debug, Clone, Copy)] 2898#[derive(Debug, Clone, Copy)]
3414pub struct TupleType<'a> { 2899pub struct TupleTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3415 syntax: SyntaxNodeRef<'a>, 2900 syntax: SyntaxNode<R>,
3416} 2901}
2902pub type TupleType<'a> = TupleTypeNode<RefRoot<'a>>;
3417 2903
3418impl<'a> AstNode<'a> for TupleType<'a> { 2904impl<'a> AstNode<'a> for TupleType<'a> {
3419 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2905 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3425,29 +2911,24 @@ impl<'a> AstNode<'a> for TupleType<'a> {
3425 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2911 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3426} 2912}
3427 2913
3428impl<'a> TupleType<'a> {} 2914impl<R: TreeRoot<RaTypes>> TupleTypeNode<R> {
3429 2915 pub fn borrowed(&self) -> TupleType {
3430// TypeDef 2916 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 } 2917 }
3439} 2918 pub fn owned(&self) -> TupleTypeNode {
3440 2919 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 } 2920 }
3446} 2921}
2922
2923
2924impl<'a> TupleType<'a> {}
2925
2926// TypeDef
3447#[derive(Debug, Clone, Copy)] 2927#[derive(Debug, Clone, Copy)]
3448pub struct TypeDef<'a> { 2928pub struct TypeDefNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3449 syntax: SyntaxNodeRef<'a>, 2929 syntax: SyntaxNode<R>,
3450} 2930}
2931pub type TypeDef<'a> = TypeDefNode<RefRoot<'a>>;
3451 2932
3452impl<'a> AstNode<'a> for TypeDef<'a> { 2933impl<'a> AstNode<'a> for TypeDef<'a> {
3453 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2934 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3459,32 +2940,27 @@ impl<'a> AstNode<'a> for TypeDef<'a> {
3459 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2940 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3460} 2941}
3461 2942
2943impl<R: TreeRoot<RaTypes>> TypeDefNode<R> {
2944 pub fn borrowed(&self) -> TypeDef {
2945 TypeDefNode { syntax: self.syntax.borrowed() }
2946 }
2947 pub fn owned(&self) -> TypeDefNode {
2948 TypeDefNode { syntax: self.syntax.owned() }
2949 }
2950}
2951
2952
3462impl<'a> ast::NameOwner<'a> for TypeDef<'a> {} 2953impl<'a> ast::NameOwner<'a> for TypeDef<'a> {}
3463impl<'a> ast::TypeParamsOwner<'a> for TypeDef<'a> {} 2954impl<'a> ast::TypeParamsOwner<'a> for TypeDef<'a> {}
3464impl<'a> ast::AttrsOwner<'a> for TypeDef<'a> {} 2955impl<'a> ast::AttrsOwner<'a> for TypeDef<'a> {}
3465impl<'a> TypeDef<'a> {} 2956impl<'a> TypeDef<'a> {}
3466 2957
3467// TypeParam 2958// 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)] 2959#[derive(Debug, Clone, Copy)]
3485pub struct TypeParam<'a> { 2960pub struct TypeParamNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3486 syntax: SyntaxNodeRef<'a>, 2961 syntax: SyntaxNode<R>,
3487} 2962}
2963pub type TypeParam<'a> = TypeParamNode<RefRoot<'a>>;
3488 2964
3489impl<'a> AstNode<'a> for TypeParam<'a> { 2965impl<'a> AstNode<'a> for TypeParam<'a> {
3490 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2966 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3496,30 +2972,25 @@ impl<'a> AstNode<'a> for TypeParam<'a> {
3496 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 2972 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3497} 2973}
3498 2974
2975impl<R: TreeRoot<RaTypes>> TypeParamNode<R> {
2976 pub fn borrowed(&self) -> TypeParam {
2977 TypeParamNode { syntax: self.syntax.borrowed() }
2978 }
2979 pub fn owned(&self) -> TypeParamNode {
2980 TypeParamNode { syntax: self.syntax.owned() }
2981 }
2982}
2983
2984
3499impl<'a> ast::NameOwner<'a> for TypeParam<'a> {} 2985impl<'a> ast::NameOwner<'a> for TypeParam<'a> {}
3500impl<'a> TypeParam<'a> {} 2986impl<'a> TypeParam<'a> {}
3501 2987
3502// TypeParamList 2988// 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)] 2989#[derive(Debug, Clone, Copy)]
3520pub struct TypeParamList<'a> { 2990pub struct TypeParamListNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3521 syntax: SyntaxNodeRef<'a>, 2991 syntax: SyntaxNode<R>,
3522} 2992}
2993pub type TypeParamList<'a> = TypeParamListNode<RefRoot<'a>>;
3523 2994
3524impl<'a> AstNode<'a> for TypeParamList<'a> { 2995impl<'a> AstNode<'a> for TypeParamList<'a> {
3525 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 2996 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3531,6 +3002,16 @@ impl<'a> AstNode<'a> for TypeParamList<'a> {
3531 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 3002 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3532} 3003}
3533 3004
3005impl<R: TreeRoot<RaTypes>> TypeParamListNode<R> {
3006 pub fn borrowed(&self) -> TypeParamList {
3007 TypeParamListNode { syntax: self.syntax.borrowed() }
3008 }
3009 pub fn owned(&self) -> TypeParamListNode {
3010 TypeParamListNode { syntax: self.syntax.owned() }
3011 }
3012}
3013
3014
3534impl<'a> TypeParamList<'a> { 3015impl<'a> TypeParamList<'a> {
3535 pub fn type_params(self) -> impl Iterator<Item = TypeParam<'a>> + 'a { 3016 pub fn type_params(self) -> impl Iterator<Item = TypeParam<'a>> + 'a {
3536 super::children(self) 3017 super::children(self)
@@ -3542,22 +3023,6 @@ impl<'a> TypeParamList<'a> {
3542} 3023}
3543 3024
3544// TypeRef 3025// 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)] 3026#[derive(Debug, Clone, Copy)]
3562pub enum TypeRef<'a> { 3027pub enum TypeRef<'a> {
3563 ParenType(ParenType<'a>), 3028 ParenType(ParenType<'a>),
@@ -3616,26 +3081,11 @@ impl<'a> AstNode<'a> for TypeRef<'a> {
3616impl<'a> TypeRef<'a> {} 3081impl<'a> TypeRef<'a> {}
3617 3082
3618// UseItem 3083// 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)] 3084#[derive(Debug, Clone, Copy)]
3636pub struct UseItem<'a> { 3085pub struct UseItemNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3637 syntax: SyntaxNodeRef<'a>, 3086 syntax: SyntaxNode<R>,
3638} 3087}
3088pub type UseItem<'a> = UseItemNode<RefRoot<'a>>;
3639 3089
3640impl<'a> AstNode<'a> for UseItem<'a> { 3090impl<'a> AstNode<'a> for UseItem<'a> {
3641 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 3091 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3647,33 +3097,28 @@ impl<'a> AstNode<'a> for UseItem<'a> {
3647 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 3097 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3648} 3098}
3649 3099
3650impl<'a> UseItem<'a> { 3100impl<R: TreeRoot<RaTypes>> UseItemNode<R> {
3651 pub fn use_tree(self) -> Option<UseTree<'a>> { 3101 pub fn borrowed(&self) -> UseItem {
3652 super::child_opt(self) 3102 UseItemNode { syntax: self.syntax.borrowed() }
3103 }
3104 pub fn owned(&self) -> UseItemNode {
3105 UseItemNode { syntax: self.syntax.owned() }
3653 } 3106 }
3654} 3107}
3655 3108
3656// UseTree
3657 3109
3658#[derive(Debug, Clone)] 3110impl<'a> UseItem<'a> {
3659pub struct UseTreeNode(SyntaxNode); 3111 pub fn use_tree(self) -> Option<UseTree<'a>> {
3660 3112 super::child_opt(self)
3661impl UseTreeNode {
3662 pub fn ast(&self) -> UseTree {
3663 UseTree::cast(self.0.borrowed()).unwrap()
3664 } 3113 }
3665} 3114}
3666 3115
3667impl<'a> From<UseTree<'a>> for UseTreeNode { 3116// UseTree
3668 fn from(ast: UseTree<'a>) -> UseTreeNode {
3669 let syntax = ast.syntax().owned();
3670 UseTreeNode(syntax)
3671 }
3672}
3673#[derive(Debug, Clone, Copy)] 3117#[derive(Debug, Clone, Copy)]
3674pub struct UseTree<'a> { 3118pub struct UseTreeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3675 syntax: SyntaxNodeRef<'a>, 3119 syntax: SyntaxNode<R>,
3676} 3120}
3121pub type UseTree<'a> = UseTreeNode<RefRoot<'a>>;
3677 3122
3678impl<'a> AstNode<'a> for UseTree<'a> { 3123impl<'a> AstNode<'a> for UseTree<'a> {
3679 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 3124 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3685,6 +3130,16 @@ impl<'a> AstNode<'a> for UseTree<'a> {
3685 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 3130 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3686} 3131}
3687 3132
3133impl<R: TreeRoot<RaTypes>> UseTreeNode<R> {
3134 pub fn borrowed(&self) -> UseTree {
3135 UseTreeNode { syntax: self.syntax.borrowed() }
3136 }
3137 pub fn owned(&self) -> UseTreeNode {
3138 UseTreeNode { syntax: self.syntax.owned() }
3139 }
3140}
3141
3142
3688impl<'a> UseTree<'a> { 3143impl<'a> UseTree<'a> {
3689 pub fn path(self) -> Option<Path<'a>> { 3144 pub fn path(self) -> Option<Path<'a>> {
3690 super::child_opt(self) 3145 super::child_opt(self)
@@ -3696,26 +3151,11 @@ impl<'a> UseTree<'a> {
3696} 3151}
3697 3152
3698// UseTreeList 3153// 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)] 3154#[derive(Debug, Clone, Copy)]
3716pub struct UseTreeList<'a> { 3155pub struct UseTreeListNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3717 syntax: SyntaxNodeRef<'a>, 3156 syntax: SyntaxNode<R>,
3718} 3157}
3158pub type UseTreeList<'a> = UseTreeListNode<RefRoot<'a>>;
3719 3159
3720impl<'a> AstNode<'a> for UseTreeList<'a> { 3160impl<'a> AstNode<'a> for UseTreeList<'a> {
3721 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 3161 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3727,33 +3167,28 @@ impl<'a> AstNode<'a> for UseTreeList<'a> {
3727 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 3167 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3728} 3168}
3729 3169
3730impl<'a> UseTreeList<'a> { 3170impl<R: TreeRoot<RaTypes>> UseTreeListNode<R> {
3731 pub fn use_trees(self) -> impl Iterator<Item = UseTree<'a>> + 'a { 3171 pub fn borrowed(&self) -> UseTreeList {
3732 super::children(self) 3172 UseTreeListNode { syntax: self.syntax.borrowed() }
3173 }
3174 pub fn owned(&self) -> UseTreeListNode {
3175 UseTreeListNode { syntax: self.syntax.owned() }
3733 } 3176 }
3734} 3177}
3735 3178
3736// WhereClause
3737 3179
3738#[derive(Debug, Clone)] 3180impl<'a> UseTreeList<'a> {
3739pub struct WhereClauseNode(SyntaxNode); 3181 pub fn use_trees(self) -> impl Iterator<Item = UseTree<'a>> + 'a {
3740 3182 super::children(self)
3741impl WhereClauseNode {
3742 pub fn ast(&self) -> WhereClause {
3743 WhereClause::cast(self.0.borrowed()).unwrap()
3744 } 3183 }
3745} 3184}
3746 3185
3747impl<'a> From<WhereClause<'a>> for WhereClauseNode { 3186// WhereClause
3748 fn from(ast: WhereClause<'a>) -> WhereClauseNode {
3749 let syntax = ast.syntax().owned();
3750 WhereClauseNode(syntax)
3751 }
3752}
3753#[derive(Debug, Clone, Copy)] 3187#[derive(Debug, Clone, Copy)]
3754pub struct WhereClause<'a> { 3188pub struct WhereClauseNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3755 syntax: SyntaxNodeRef<'a>, 3189 syntax: SyntaxNode<R>,
3756} 3190}
3191pub type WhereClause<'a> = WhereClauseNode<RefRoot<'a>>;
3757 3192
3758impl<'a> AstNode<'a> for WhereClause<'a> { 3193impl<'a> AstNode<'a> for WhereClause<'a> {
3759 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 3194 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3765,29 +3200,24 @@ impl<'a> AstNode<'a> for WhereClause<'a> {
3765 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 3200 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3766} 3201}
3767 3202
3768impl<'a> WhereClause<'a> {} 3203impl<R: TreeRoot<RaTypes>> WhereClauseNode<R> {
3769 3204 pub fn borrowed(&self) -> WhereClause {
3770// WhileExpr 3205 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 } 3206 }
3779} 3207 pub fn owned(&self) -> WhereClauseNode {
3780 3208 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 } 3209 }
3786} 3210}
3211
3212
3213impl<'a> WhereClause<'a> {}
3214
3215// WhileExpr
3787#[derive(Debug, Clone, Copy)] 3216#[derive(Debug, Clone, Copy)]
3788pub struct WhileExpr<'a> { 3217pub struct WhileExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3789 syntax: SyntaxNodeRef<'a>, 3218 syntax: SyntaxNode<R>,
3790} 3219}
3220pub type WhileExpr<'a> = WhileExprNode<RefRoot<'a>>;
3791 3221
3792impl<'a> AstNode<'a> for WhileExpr<'a> { 3222impl<'a> AstNode<'a> for WhileExpr<'a> {
3793 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 3223 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3799,6 +3229,16 @@ impl<'a> AstNode<'a> for WhileExpr<'a> {
3799 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 3229 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3800} 3230}
3801 3231
3232impl<R: TreeRoot<RaTypes>> WhileExprNode<R> {
3233 pub fn borrowed(&self) -> WhileExpr {
3234 WhileExprNode { syntax: self.syntax.borrowed() }
3235 }
3236 pub fn owned(&self) -> WhileExprNode {
3237 WhileExprNode { syntax: self.syntax.owned() }
3238 }
3239}
3240
3241
3802impl<'a> ast::LoopBodyOwner<'a> for WhileExpr<'a> {} 3242impl<'a> ast::LoopBodyOwner<'a> for WhileExpr<'a> {}
3803impl<'a> WhileExpr<'a> { 3243impl<'a> WhileExpr<'a> {
3804 pub fn condition(self) -> Option<Condition<'a>> { 3244 pub fn condition(self) -> Option<Condition<'a>> {
@@ -3807,26 +3247,11 @@ impl<'a> WhileExpr<'a> {
3807} 3247}
3808 3248
3809// Whitespace 3249// 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)] 3250#[derive(Debug, Clone, Copy)]
3827pub struct Whitespace<'a> { 3251pub struct WhitespaceNode<R: TreeRoot<RaTypes> = OwnedRoot> {
3828 syntax: SyntaxNodeRef<'a>, 3252 syntax: SyntaxNode<R>,
3829} 3253}
3254pub type Whitespace<'a> = WhitespaceNode<RefRoot<'a>>;
3830 3255
3831impl<'a> AstNode<'a> for Whitespace<'a> { 3256impl<'a> AstNode<'a> for Whitespace<'a> {
3832 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 3257 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -3838,5 +3263,15 @@ impl<'a> AstNode<'a> for Whitespace<'a> {
3838 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 3263 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
3839} 3264}
3840 3265
3266impl<R: TreeRoot<RaTypes>> WhitespaceNode<R> {
3267 pub fn borrowed(&self) -> Whitespace {
3268 WhitespaceNode { syntax: self.syntax.borrowed() }
3269 }
3270 pub fn owned(&self) -> WhitespaceNode {
3271 WhitespaceNode { syntax: self.syntax.owned() }
3272 }
3273}
3274
3275
3841impl<'a> Whitespace<'a> {} 3276impl<'a> Whitespace<'a> {}
3842 3277
diff --git a/crates/ra_syntax/src/ast/generated.rs.tera b/crates/ra_syntax/src/ast/generated.rs.tera
index 1321f0def..6e28575b2 100644
--- a/crates/ra_syntax/src/ast/generated.rs.tera
+++ b/crates/ra_syntax/src/ast/generated.rs.tera
@@ -8,27 +8,12 @@ the below applies to the result of this template
8use crate::{ 8use crate::{
9 ast, 9 ast,
10 SyntaxNode, SyntaxNodeRef, AstNode, 10 SyntaxNode, SyntaxNodeRef, AstNode,
11 yellow::{TreeRoot, RaTypes, OwnedRoot, RefRoot},
11 SyntaxKind::*, 12 SyntaxKind::*,
12}; 13};
13{% for node, methods in ast %} 14{% for node, methods in ast %}
14// {{ node }} 15// {{ node }}
15 16
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 %} 17{%- if methods.enum %}
33#[derive(Debug, Clone, Copy)] 18#[derive(Debug, Clone, Copy)]
34pub enum {{ node }}<'a> { 19pub enum {{ node }}<'a> {
@@ -56,9 +41,10 @@ impl<'a> AstNode<'a> for {{ node }}<'a> {
56} 41}
57{% else %} 42{% else %}
58#[derive(Debug, Clone, Copy)] 43#[derive(Debug, Clone, Copy)]
59pub struct {{ node }}<'a> { 44pub struct {{ node }}Node<R: TreeRoot<RaTypes> = OwnedRoot> {
60 syntax: SyntaxNodeRef<'a>, 45 syntax: SyntaxNode<R>,
61} 46}
47pub type {{ node }}<'a> = {{ node }}Node<RefRoot<'a>>;
62 48
63impl<'a> AstNode<'a> for {{ node }}<'a> { 49impl<'a> AstNode<'a> for {{ node }}<'a> {
64 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { 50 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
@@ -69,6 +55,16 @@ impl<'a> AstNode<'a> for {{ node }}<'a> {
69 } 55 }
70 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 56 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
71} 57}
58
59impl<R: TreeRoot<RaTypes>> {{ node }}Node<R> {
60 pub fn borrowed(&self) -> {{ node }} {
61 {{ node }}Node { syntax: self.syntax.borrowed() }
62 }
63 pub fn owned(&self) -> {{ node }}Node {
64 {{ node }}Node { syntax: self.syntax.owned() }
65 }
66}
67
72{% endif %} 68{% endif %}
73{% if methods.traits -%} 69{% if methods.traits -%}
74{%- for t in methods.traits -%} 70{%- for t in methods.traits -%}