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