aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/ast.rs22
-rw-r--r--crates/ra_syntax/src/ast/edit.rs46
-rw-r--r--crates/ra_syntax/src/ast/expr_ext.rs (renamed from crates/ra_syntax/src/ast/expr_extensions.rs)13
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs3812
-rw-r--r--crates/ra_syntax/src/ast/make.rs14
-rw-r--r--crates/ra_syntax/src/ast/node_ext.rs (renamed from crates/ra_syntax/src/ast/extensions.rs)91
-rw-r--r--crates/ra_syntax/src/ast/token_ext.rs (renamed from crates/ra_syntax/src/ast/tokens.rs)20
-rw-r--r--crates/ra_syntax/src/ast/traits.rs12
-rw-r--r--crates/ra_syntax/src/lib.rs12
-rw-r--r--crates/ra_syntax/src/parsing/text_tree_sink.rs9
-rw-r--r--crates/ra_syntax/src/ptr.rs2
-rw-r--r--crates/ra_syntax/src/syntax_node.rs4
-rw-r--r--crates/ra_syntax/src/tests.rs118
-rw-r--r--crates/ra_syntax/src/validation.rs8
-rw-r--r--crates/ra_syntax/src/validation/block.rs2
15 files changed, 1425 insertions, 2760 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index 9d02aeef3..fd426ece9 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -2,9 +2,9 @@
2 2
3mod generated; 3mod generated;
4mod traits; 4mod traits;
5mod tokens; 5mod token_ext;
6mod extensions; 6mod node_ext;
7mod expr_extensions; 7mod expr_ext;
8pub mod edit; 8pub mod edit;
9pub mod make; 9pub mod make;
10 10
@@ -16,13 +16,13 @@ use crate::{
16}; 16};
17 17
18pub use self::{ 18pub use self::{
19 expr_extensions::{ArrayExprKind, BinOp, Effect, ElseBranch, LiteralKind, PrefixOp, RangeOp}, 19 expr_ext::{ArrayExprKind, BinOp, Effect, ElseBranch, LiteralKind, PrefixOp, RangeOp},
20 extensions::{ 20 generated::{nodes::*, tokens::*},
21 node_ext::{
21 AttrKind, FieldKind, NameOrNameRef, PathSegmentKind, SelfParamKind, SlicePatComponents, 22 AttrKind, FieldKind, NameOrNameRef, PathSegmentKind, SelfParamKind, SlicePatComponents,
22 StructKind, TypeBoundKind, VisibilityKind, 23 StructKind, TypeBoundKind, VisibilityKind,
23 }, 24 },
24 generated::{nodes::*, tokens::*}, 25 token_ext::*,
25 tokens::*,
26 traits::*, 26 traits::*,
27}; 27};
28 28
@@ -139,7 +139,7 @@ fn test_doc_comment_of_statics() {
139 ) 139 )
140 .ok() 140 .ok()
141 .unwrap(); 141 .unwrap();
142 let st = file.syntax().descendants().find_map(StaticDef::cast).unwrap(); 142 let st = file.syntax().descendants().find_map(Static::cast).unwrap();
143 assert_eq!("Number of levels", st.doc_comment_text().unwrap()); 143 assert_eq!("Number of levels", st.doc_comment_text().unwrap());
144} 144}
145 145
@@ -235,7 +235,7 @@ fn test_comments_preserve_trailing_whitespace() {
235 ) 235 )
236 .ok() 236 .ok()
237 .unwrap(); 237 .unwrap();
238 let def = file.syntax().descendants().find_map(StructDef::cast).unwrap(); 238 let def = file.syntax().descendants().find_map(Struct::cast).unwrap();
239 assert_eq!( 239 assert_eq!(
240 "Representation of a Realm. \nIn the specification these are called Realm Records.", 240 "Representation of a Realm. \nIn the specification these are called Realm Records.",
241 def.doc_comment_text().unwrap() 241 def.doc_comment_text().unwrap()
@@ -286,7 +286,7 @@ where
286 let mut bounds = pred.type_bound_list().unwrap().bounds(); 286 let mut bounds = pred.type_bound_list().unwrap().bounds();
287 287
288 assert!(pred.for_token().is_none()); 288 assert!(pred.for_token().is_none());
289 assert!(pred.type_param_list().is_none()); 289 assert!(pred.generic_param_list().is_none());
290 assert_eq!("T", pred.type_ref().unwrap().syntax().text().to_string()); 290 assert_eq!("T", pred.type_ref().unwrap().syntax().text().to_string());
291 assert_bound("Clone", bounds.next()); 291 assert_bound("Clone", bounds.next());
292 assert_bound("Copy", bounds.next()); 292 assert_bound("Copy", bounds.next());
@@ -325,7 +325,7 @@ where
325 let mut bounds = pred.type_bound_list().unwrap().bounds(); 325 let mut bounds = pred.type_bound_list().unwrap().bounds();
326 326
327 assert!(pred.for_token().is_some()); 327 assert!(pred.for_token().is_some());
328 assert_eq!("<'a>", pred.type_param_list().unwrap().syntax().text().to_string()); 328 assert_eq!("<'a>", pred.generic_param_list().unwrap().syntax().text().to_string());
329 assert_eq!("F", pred.type_ref().unwrap().syntax().text().to_string()); 329 assert_eq!("F", pred.type_ref().unwrap().syntax().text().to_string());
330 assert_bound("Fn(&'a str)", bounds.next()); 330 assert_bound("Fn(&'a str)", bounds.next());
331} 331}
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs
index 2ef173a03..8d3e42f25 100644
--- a/crates/ra_syntax/src/ast/edit.rs
+++ b/crates/ra_syntax/src/ast/edit.rs
@@ -29,9 +29,9 @@ impl ast::BinExpr {
29 } 29 }
30} 30}
31 31
32impl ast::FnDef { 32impl ast::Fn {
33 #[must_use] 33 #[must_use]
34 pub fn with_body(&self, body: ast::BlockExpr) -> ast::FnDef { 34 pub fn with_body(&self, body: ast::BlockExpr) -> ast::Fn {
35 let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new(); 35 let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new();
36 let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() { 36 let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() {
37 old_body.syntax().clone().into() 37 old_body.syntax().clone().into()
@@ -80,9 +80,12 @@ where
80 } 80 }
81} 81}
82 82
83impl ast::ItemList { 83impl ast::AssocItemList {
84 #[must_use] 84 #[must_use]
85 pub fn append_items(&self, items: impl IntoIterator<Item = ast::AssocItem>) -> ast::ItemList { 85 pub fn append_items(
86 &self,
87 items: impl IntoIterator<Item = ast::AssocItem>,
88 ) -> ast::AssocItemList {
86 let mut res = self.clone(); 89 let mut res = self.clone();
87 if !self.syntax().text().contains_char('\n') { 90 if !self.syntax().text().contains_char('\n') {
88 res = make_multiline(res); 91 res = make_multiline(res);
@@ -92,7 +95,7 @@ impl ast::ItemList {
92 } 95 }
93 96
94 #[must_use] 97 #[must_use]
95 pub fn append_item(&self, item: ast::AssocItem) -> ast::ItemList { 98 pub fn append_item(&self, item: ast::AssocItem) -> ast::AssocItemList {
96 let (indent, position) = match self.assoc_items().last() { 99 let (indent, position) = match self.assoc_items().last() {
97 Some(it) => ( 100 Some(it) => (
98 leading_indent(it.syntax()).unwrap_or_default().to_string(), 101 leading_indent(it.syntax()).unwrap_or_default().to_string(),
@@ -113,18 +116,18 @@ impl ast::ItemList {
113 } 116 }
114} 117}
115 118
116impl ast::RecordFieldList { 119impl ast::RecordExprFieldList {
117 #[must_use] 120 #[must_use]
118 pub fn append_field(&self, field: &ast::RecordField) -> ast::RecordFieldList { 121 pub fn append_field(&self, field: &ast::RecordExprField) -> ast::RecordExprFieldList {
119 self.insert_field(InsertPosition::Last, field) 122 self.insert_field(InsertPosition::Last, field)
120 } 123 }
121 124
122 #[must_use] 125 #[must_use]
123 pub fn insert_field( 126 pub fn insert_field(
124 &self, 127 &self,
125 position: InsertPosition<&'_ ast::RecordField>, 128 position: InsertPosition<&'_ ast::RecordExprField>,
126 field: &ast::RecordField, 129 field: &ast::RecordExprField,
127 ) -> ast::RecordFieldList { 130 ) -> ast::RecordExprFieldList {
128 let is_multiline = self.syntax().text().contains_char('\n'); 131 let is_multiline = self.syntax().text().contains_char('\n');
129 let ws; 132 let ws;
130 let space = if is_multiline { 133 let space = if is_multiline {
@@ -189,6 +192,21 @@ impl ast::RecordFieldList {
189 } 192 }
190} 193}
191 194
195impl ast::TypeAlias {
196 #[must_use]
197 pub fn remove_bounds(&self) -> ast::TypeAlias {
198 let colon = match self.colon_token() {
199 Some(it) => it,
200 None => return self.clone(),
201 };
202 let end = match self.type_bound_list() {
203 Some(it) => it.syntax().clone().into(),
204 None => colon.clone().into(),
205 };
206 self.replace_children(colon.into()..=end, iter::empty())
207 }
208}
209
192impl ast::TypeParam { 210impl ast::TypeParam {
193 #[must_use] 211 #[must_use]
194 pub fn remove_bounds(&self) -> ast::TypeParam { 212 pub fn remove_bounds(&self) -> ast::TypeParam {
@@ -244,9 +262,9 @@ impl ast::PathSegment {
244 } 262 }
245} 263}
246 264
247impl ast::UseItem { 265impl ast::Use {
248 #[must_use] 266 #[must_use]
249 pub fn with_use_tree(&self, use_tree: ast::UseTree) -> ast::UseItem { 267 pub fn with_use_tree(&self, use_tree: ast::UseTree) -> ast::Use {
250 if let Some(old) = self.use_tree() { 268 if let Some(old) = self.use_tree() {
251 return self.replace_descendant(old, use_tree); 269 return self.replace_descendant(old, use_tree);
252 } 270 }
@@ -300,9 +318,9 @@ impl ast::UseTree {
300 None => return self.clone(), 318 None => return self.clone(),
301 }; 319 };
302 let use_tree = make::use_tree( 320 let use_tree = make::use_tree(
303 suffix.clone(), 321 suffix,
304 self.use_tree_list(), 322 self.use_tree_list(),
305 self.alias(), 323 self.rename(),
306 self.star_token().is_some(), 324 self.star_token().is_some(),
307 ); 325 );
308 let nested = make::use_tree_list(iter::once(use_tree)); 326 let nested = make::use_tree_list(iter::once(use_tree));
diff --git a/crates/ra_syntax/src/ast/expr_extensions.rs b/crates/ra_syntax/src/ast/expr_ext.rs
index db5438d68..f5ba87223 100644
--- a/crates/ra_syntax/src/ast/expr_extensions.rs
+++ b/crates/ra_syntax/src/ast/expr_ext.rs
@@ -7,6 +7,8 @@ use crate::{
7 SyntaxToken, T, 7 SyntaxToken, T,
8}; 8};
9 9
10impl ast::AttrsOwner for ast::Expr {}
11
10impl ast::Expr { 12impl ast::Expr {
11 pub fn is_block_like(&self) -> bool { 13 pub fn is_block_like(&self) -> bool {
12 match self { 14 match self {
@@ -331,13 +333,12 @@ impl ast::Literal {
331 333
332 match token.kind() { 334 match token.kind() {
333 INT_NUMBER => { 335 INT_NUMBER => {
334 // FYI: there was a bug here previously, thus an if statement bellow is necessary. 336 // FYI: there was a bug here previously, thus the if statement below is necessary.
335 // The lexer treats e.g. `1f64` as an integer literal. See 337 // The lexer treats e.g. `1f64` as an integer literal. See
336 // https://github.com/rust-analyzer/rust-analyzer/issues/1592 338 // https://github.com/rust-analyzer/rust-analyzer/issues/1592
337 // and the comments on the linked PR. 339 // and the comments on the linked PR.
338 340
339 let text = token.text(); 341 let text = token.text();
340
341 if let suffix @ Some(_) = Self::find_suffix(&text, &FLOAT_SUFFIXES) { 342 if let suffix @ Some(_) = Self::find_suffix(&text, &FLOAT_SUFFIXES) {
342 LiteralKind::FloatNumber { suffix } 343 LiteralKind::FloatNumber { suffix }
343 } else { 344 } else {
@@ -399,7 +400,7 @@ impl ast::BlockExpr {
399 Some(it) => it, 400 Some(it) => it,
400 None => return true, 401 None => return true,
401 }; 402 };
402 !matches!(parent.kind(), FN_DEF | IF_EXPR | WHILE_EXPR | LOOP_EXPR | EFFECT_EXPR) 403 !matches!(parent.kind(), FN | IF_EXPR | WHILE_EXPR | LOOP_EXPR | EFFECT_EXPR)
403 } 404 }
404} 405}
405 406
@@ -410,8 +411,8 @@ fn test_literal_with_attr() {
410 assert_eq!(lit.token().text(), r#""Hello""#); 411 assert_eq!(lit.token().text(), r#""Hello""#);
411} 412}
412 413
413impl ast::RecordField { 414impl ast::RecordExprField {
414 pub fn parent_record_lit(&self) -> ast::RecordLit { 415 pub fn parent_record_lit(&self) -> ast::RecordExpr {
415 self.syntax().ancestors().find_map(ast::RecordLit::cast).unwrap() 416 self.syntax().ancestors().find_map(ast::RecordExpr::cast).unwrap()
416 } 417 }
417} 418}
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs
index 58141da11..4306efe13 100644
--- a/crates/ra_syntax/src/ast/generated/nodes.rs
+++ b/crates/ra_syntax/src/ast/generated/nodes.rs
@@ -5,557 +5,529 @@ use crate::{
5 SyntaxKind::{self, *}, 5 SyntaxKind::{self, *},
6 SyntaxNode, SyntaxToken, T, 6 SyntaxNode, SyntaxToken, T,
7}; 7};
8/// The entire Rust source file. Includes all top-level inner attributes and module items.
9///
10/// [Reference](https://doc.rust-lang.org/reference/crates-and-source-files.html)
11#[derive(Debug, Clone, PartialEq, Eq, Hash)] 8#[derive(Debug, Clone, PartialEq, Eq, Hash)]
12pub struct SourceFile { 9pub struct SourceFile {
13 pub(crate) syntax: SyntaxNode, 10 pub(crate) syntax: SyntaxNode,
14} 11}
15impl ast::ModuleItemOwner for SourceFile {}
16impl ast::AttrsOwner for SourceFile {} 12impl ast::AttrsOwner for SourceFile {}
17impl ast::DocCommentsOwner for SourceFile {} 13impl ast::ModuleItemOwner for SourceFile {}
18impl SourceFile { 14impl SourceFile {
19 pub fn modules(&self) -> AstChildren<Module> { support::children(&self.syntax) } 15 pub fn shebang_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![shebang]) }
20} 16}
21/// Function definition either with body or not. 17#[derive(Debug, Clone, PartialEq, Eq, Hash)]
22/// Includes all of its attributes and doc comments. 18pub struct Attr {
23///
24/// ```
25/// ❰
26/// /// Docs
27/// #[attr]
28/// pub extern "C" fn foo<T>(#[attr] Patern {p}: Pattern) -> u32
29/// where
30/// T: Debug
31/// {
32/// 42
33/// }
34/// ❱
35///
36/// extern "C" {
37/// ❰ fn fn_decl(also_variadic_ffi: u32, ...) -> u32; ❱
38/// }
39/// ```
40///
41/// - [Reference](https://doc.rust-lang.org/reference/items/functions.html)
42/// - [Nomicon](https://doc.rust-lang.org/nomicon/ffi.html#variadic-functions)
43#[derive(Debug, Clone, PartialEq, Eq, Hash)]
44pub struct FnDef {
45 pub(crate) syntax: SyntaxNode, 19 pub(crate) syntax: SyntaxNode,
46} 20}
47impl ast::VisibilityOwner for FnDef {} 21impl Attr {
48impl ast::NameOwner for FnDef {} 22 pub fn pound_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![#]) }
49impl ast::TypeParamsOwner for FnDef {} 23 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
50impl ast::DocCommentsOwner for FnDef {} 24 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
51impl ast::AttrsOwner for FnDef {} 25 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
52impl FnDef { 26 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
53 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) } 27 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) }
28 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
29 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
30}
31#[derive(Debug, Clone, PartialEq, Eq, Hash)]
32pub struct Const {
33 pub(crate) syntax: SyntaxNode,
34}
35impl ast::AttrsOwner for Const {}
36impl ast::NameOwner for Const {}
37impl ast::VisibilityOwner for Const {}
38impl Const {
39 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
54 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 40 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
41 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
42 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
43 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
44 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
45 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
46 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
47}
48#[derive(Debug, Clone, PartialEq, Eq, Hash)]
49pub struct Enum {
50 pub(crate) syntax: SyntaxNode,
51}
52impl ast::AttrsOwner for Enum {}
53impl ast::NameOwner for Enum {}
54impl ast::VisibilityOwner for Enum {}
55impl ast::GenericParamsOwner for Enum {}
56impl Enum {
57 pub fn enum_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![enum]) }
58 pub fn variant_list(&self) -> Option<VariantList> { support::child(&self.syntax) }
59}
60#[derive(Debug, Clone, PartialEq, Eq, Hash)]
61pub struct ExternBlock {
62 pub(crate) syntax: SyntaxNode,
63}
64impl ast::AttrsOwner for ExternBlock {}
65impl ExternBlock {
66 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
67 pub fn extern_item_list(&self) -> Option<ExternItemList> { support::child(&self.syntax) }
68}
69#[derive(Debug, Clone, PartialEq, Eq, Hash)]
70pub struct ExternCrate {
71 pub(crate) syntax: SyntaxNode,
72}
73impl ast::AttrsOwner for ExternCrate {}
74impl ast::VisibilityOwner for ExternCrate {}
75impl ExternCrate {
76 pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) }
77 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
78 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
79 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
80 pub fn rename(&self) -> Option<Rename> { support::child(&self.syntax) }
81 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
82}
83#[derive(Debug, Clone, PartialEq, Eq, Hash)]
84pub struct Fn {
85 pub(crate) syntax: SyntaxNode,
86}
87impl ast::AttrsOwner for Fn {}
88impl ast::NameOwner for Fn {}
89impl ast::VisibilityOwner for Fn {}
90impl ast::GenericParamsOwner for Fn {}
91impl Fn {
55 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } 92 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
56 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) } 93 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
94 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
57 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } 95 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
96 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
58 pub fn fn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![fn]) } 97 pub fn fn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![fn]) }
59 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } 98 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
60 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } 99 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
61 pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) } 100 pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
62 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 101 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
63} 102}
64/// Return type annotation.
65///
66/// ```
67/// fn foo(a: u32) ❰ -> Option<u32> ❱ { Some(a) }
68/// ```
69///
70/// [Reference](https://doc.rust-lang.org/reference/items/functions.html)
71#[derive(Debug, Clone, PartialEq, Eq, Hash)] 103#[derive(Debug, Clone, PartialEq, Eq, Hash)]
72pub struct RetType { 104pub struct Impl {
73 pub(crate) syntax: SyntaxNode, 105 pub(crate) syntax: SyntaxNode,
74} 106}
75impl RetType { 107impl ast::AttrsOwner for Impl {}
76 pub fn thin_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![->]) } 108impl ast::VisibilityOwner for Impl {}
109impl ast::GenericParamsOwner for Impl {}
110impl Impl {
111 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
112 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
113 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) }
114 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
77 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 115 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
116 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
117 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
118 pub fn assoc_item_list(&self) -> Option<AssocItemList> { support::child(&self.syntax) }
119}
120#[derive(Debug, Clone, PartialEq, Eq, Hash)]
121pub struct MacroCall {
122 pub(crate) syntax: SyntaxNode,
123}
124impl ast::AttrsOwner for MacroCall {}
125impl ast::NameOwner for MacroCall {}
126impl MacroCall {
127 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
128 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
129 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
130 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
131}
132#[derive(Debug, Clone, PartialEq, Eq, Hash)]
133pub struct Module {
134 pub(crate) syntax: SyntaxNode,
135}
136impl ast::AttrsOwner for Module {}
137impl ast::NameOwner for Module {}
138impl ast::VisibilityOwner for Module {}
139impl Module {
140 pub fn mod_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mod]) }
141 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
142 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
143}
144#[derive(Debug, Clone, PartialEq, Eq, Hash)]
145pub struct Static {
146 pub(crate) syntax: SyntaxNode,
147}
148impl ast::AttrsOwner for Static {}
149impl ast::NameOwner for Static {}
150impl ast::VisibilityOwner for Static {}
151impl Static {
152 pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) }
153 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
154 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
155 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
156 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
157 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
158 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
78} 159}
79/// Struct definition. 160#[derive(Debug, Clone, PartialEq, Eq, Hash)]
80/// Includes all of its attributes and doc comments. 161pub struct Struct {
81///
82/// ```
83/// ❰
84/// /// Docs
85/// #[attr]
86/// struct Foo<T> where T: Debug {
87/// /// Docs
88/// #[attr]
89/// pub a: u32,
90/// b: T,
91/// }
92/// ❱
93///
94/// ❰ struct Foo; ❱
95/// ❰ struct Foo<T>(#[attr] T) where T: Debug; ❱
96/// ```
97///
98/// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
99#[derive(Debug, Clone, PartialEq, Eq, Hash)]
100pub struct StructDef {
101 pub(crate) syntax: SyntaxNode, 162 pub(crate) syntax: SyntaxNode,
102} 163}
103impl ast::VisibilityOwner for StructDef {} 164impl ast::AttrsOwner for Struct {}
104impl ast::NameOwner for StructDef {} 165impl ast::NameOwner for Struct {}
105impl ast::TypeParamsOwner for StructDef {} 166impl ast::VisibilityOwner for Struct {}
106impl ast::AttrsOwner for StructDef {} 167impl ast::GenericParamsOwner for Struct {}
107impl ast::DocCommentsOwner for StructDef {} 168impl Struct {
108impl StructDef {
109 pub fn struct_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![struct]) } 169 pub fn struct_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![struct]) }
110 pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) }
111 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 170 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
171 pub fn field_list(&self) -> Option<FieldList> { support::child(&self.syntax) }
112} 172}
113/// Union definition. 173#[derive(Debug, Clone, PartialEq, Eq, Hash)]
114/// Includes all of its attributes and doc comments. 174pub struct Trait {
115/// 175 pub(crate) syntax: SyntaxNode,
116/// ``` 176}
117/// ❰ 177impl ast::AttrsOwner for Trait {}
118/// /// Docs 178impl ast::NameOwner for Trait {}
119/// #[attr] 179impl ast::VisibilityOwner for Trait {}
120/// pub union Foo<T> where T: Debug { 180impl ast::GenericParamsOwner for Trait {}
121/// /// Docs 181impl ast::TypeBoundsOwner for Trait {}
122/// #[attr] 182impl Trait {
123/// a: T, 183 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
124/// b: u32, 184 pub fn auto_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![auto]) }
125/// } 185 pub fn trait_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![trait]) }
126/// ❱ 186 pub fn assoc_item_list(&self) -> Option<AssocItemList> { support::child(&self.syntax) }
127/// ``` 187}
128/// 188#[derive(Debug, Clone, PartialEq, Eq, Hash)]
129/// [Reference](https://doc.rust-lang.org/reference/items/unions.html) 189pub struct TypeAlias {
130#[derive(Debug, Clone, PartialEq, Eq, Hash)]
131pub struct UnionDef {
132 pub(crate) syntax: SyntaxNode, 190 pub(crate) syntax: SyntaxNode,
133} 191}
134impl ast::VisibilityOwner for UnionDef {} 192impl ast::AttrsOwner for TypeAlias {}
135impl ast::NameOwner for UnionDef {} 193impl ast::NameOwner for TypeAlias {}
136impl ast::TypeParamsOwner for UnionDef {} 194impl ast::VisibilityOwner for TypeAlias {}
137impl ast::AttrsOwner for UnionDef {} 195impl ast::GenericParamsOwner for TypeAlias {}
138impl ast::DocCommentsOwner for UnionDef {} 196impl ast::TypeBoundsOwner for TypeAlias {}
139impl UnionDef { 197impl TypeAlias {
198 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
199 pub fn type_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![type]) }
200 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
201 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
202 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
203}
204#[derive(Debug, Clone, PartialEq, Eq, Hash)]
205pub struct Union {
206 pub(crate) syntax: SyntaxNode,
207}
208impl ast::AttrsOwner for Union {}
209impl ast::NameOwner for Union {}
210impl ast::VisibilityOwner for Union {}
211impl ast::GenericParamsOwner for Union {}
212impl Union {
140 pub fn union_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![union]) } 213 pub fn union_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![union]) }
141 pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> { 214 pub fn record_field_list(&self) -> Option<RecordFieldList> { support::child(&self.syntax) }
142 support::child(&self.syntax) 215}
143 } 216#[derive(Debug, Clone, PartialEq, Eq, Hash)]
217pub struct Use {
218 pub(crate) syntax: SyntaxNode,
219}
220impl ast::AttrsOwner for Use {}
221impl ast::VisibilityOwner for Use {}
222impl Use {
223 pub fn use_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![use]) }
224 pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) }
225 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
226}
227#[derive(Debug, Clone, PartialEq, Eq, Hash)]
228pub struct Visibility {
229 pub(crate) syntax: SyntaxNode,
230}
231impl Visibility {
232 pub fn pub_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![pub]) }
233 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
234 pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) }
235 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
236 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
237 pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) }
238 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
239 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
240}
241#[derive(Debug, Clone, PartialEq, Eq, Hash)]
242pub struct Name {
243 pub(crate) syntax: SyntaxNode,
244}
245impl Name {
246 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) }
247}
248#[derive(Debug, Clone, PartialEq, Eq, Hash)]
249pub struct ItemList {
250 pub(crate) syntax: SyntaxNode,
251}
252impl ast::AttrsOwner for ItemList {}
253impl ast::ModuleItemOwner for ItemList {}
254impl ItemList {
255 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
256 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
257}
258#[derive(Debug, Clone, PartialEq, Eq, Hash)]
259pub struct NameRef {
260 pub(crate) syntax: SyntaxNode,
144} 261}
145/// Record field definition list including enclosing curly braces. 262impl NameRef {
146/// 263 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) }
147/// ``` 264}
148/// struct Foo // same for union 265#[derive(Debug, Clone, PartialEq, Eq, Hash)]
149/// ❰ 266pub struct Rename {
150/// { 267 pub(crate) syntax: SyntaxNode,
151/// a: u32, 268}
152/// b: bool, 269impl ast::NameOwner for Rename {}
153/// } 270impl Rename {
154/// ❱ 271 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
155/// ``` 272 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
156/// 273}
157/// [Reference](https://doc.rust-lang.org/reference/items/structs.html) 274#[derive(Debug, Clone, PartialEq, Eq, Hash)]
158#[derive(Debug, Clone, PartialEq, Eq, Hash)] 275pub struct UseTree {
159pub struct RecordFieldDefList { 276 pub(crate) syntax: SyntaxNode,
277}
278impl UseTree {
279 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
280 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
281 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) }
282 pub fn use_tree_list(&self) -> Option<UseTreeList> { support::child(&self.syntax) }
283 pub fn rename(&self) -> Option<Rename> { support::child(&self.syntax) }
284}
285#[derive(Debug, Clone, PartialEq, Eq, Hash)]
286pub struct Path {
287 pub(crate) syntax: SyntaxNode,
288}
289impl Path {
290 pub fn qualifier(&self) -> Option<Path> { support::child(&self.syntax) }
291 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
292 pub fn segment(&self) -> Option<PathSegment> { support::child(&self.syntax) }
293}
294#[derive(Debug, Clone, PartialEq, Eq, Hash)]
295pub struct UseTreeList {
160 pub(crate) syntax: SyntaxNode, 296 pub(crate) syntax: SyntaxNode,
161} 297}
162impl RecordFieldDefList { 298impl UseTreeList {
163 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 299 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
164 pub fn fields(&self) -> AstChildren<RecordFieldDef> { support::children(&self.syntax) } 300 pub fn use_trees(&self) -> AstChildren<UseTree> { support::children(&self.syntax) }
165 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 301 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
166} 302}
167/// Record field definition including its attributes and doc comments. 303#[derive(Debug, Clone, PartialEq, Eq, Hash)]
168/// 304pub struct Abi {
169/// ` ``
170/// same for union
171/// struct Foo {
172/// ❰
173/// /// Docs
174/// #[attr]
175/// pub a: u32
176/// ❱
177///
178/// ❰ b: bool ❱
179/// }
180/// ```
181///
182/// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
183#[derive(Debug, Clone, PartialEq, Eq, Hash)]
184pub struct RecordFieldDef {
185 pub(crate) syntax: SyntaxNode, 305 pub(crate) syntax: SyntaxNode,
186} 306}
187impl ast::VisibilityOwner for RecordFieldDef {} 307impl Abi {
188impl ast::NameOwner for RecordFieldDef {} 308 pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) }
189impl ast::AttrsOwner for RecordFieldDef {} 309}
190impl ast::DocCommentsOwner for RecordFieldDef {} 310#[derive(Debug, Clone, PartialEq, Eq, Hash)]
191impl ast::TypeAscriptionOwner for RecordFieldDef {} 311pub struct GenericParamList {
192impl RecordFieldDef {} 312 pub(crate) syntax: SyntaxNode,
193/// Tuple field definition list including enclosing parens. 313}
194/// 314impl GenericParamList {
195/// ``` 315 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
196/// struct Foo ❰ (u32, String, Vec<u32>) ❱; 316 pub fn generic_params(&self) -> AstChildren<GenericParam> { support::children(&self.syntax) }
197/// ``` 317 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
198/// 318}
199/// [Reference](https://doc.rust-lang.org/reference/items/structs.html) 319#[derive(Debug, Clone, PartialEq, Eq, Hash)]
200#[derive(Debug, Clone, PartialEq, Eq, Hash)] 320pub struct ParamList {
201pub struct TupleFieldDefList {
202 pub(crate) syntax: SyntaxNode, 321 pub(crate) syntax: SyntaxNode,
203} 322}
204impl TupleFieldDefList { 323impl ParamList {
205 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } 324 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
206 pub fn fields(&self) -> AstChildren<TupleFieldDef> { support::children(&self.syntax) } 325 pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) }
326 pub fn comma_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![,]) }
327 pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) }
207 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 328 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
208} 329}
209/// Tuple field definition including its attributes.
210///
211/// ```
212/// struct Foo(❰ #[attr] u32 ❱);
213/// ```
214///
215/// [Reference](https://doc.rust-lang.org/reference/items/structs.html)
216#[derive(Debug, Clone, PartialEq, Eq, Hash)] 330#[derive(Debug, Clone, PartialEq, Eq, Hash)]
217pub struct TupleFieldDef { 331pub struct RetType {
218 pub(crate) syntax: SyntaxNode, 332 pub(crate) syntax: SyntaxNode,
219} 333}
220impl ast::VisibilityOwner for TupleFieldDef {} 334impl RetType {
221impl ast::AttrsOwner for TupleFieldDef {} 335 pub fn thin_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![->]) }
222impl TupleFieldDef { 336 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
223 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
224} 337}
225/// Enum definition. 338#[derive(Debug, Clone, PartialEq, Eq, Hash)]
226/// Includes all of its attributes and doc comments. 339pub struct WhereClause {
227///
228/// ```
229/// ❰
230/// /// Docs
231/// #[attr]
232/// pub enum Foo<T> where T: Debug {
233/// /// Docs
234/// #[attr]
235/// Bar,
236/// Baz(#[attr] u32),
237/// Bruh {
238/// a: u32,
239/// /// Docs
240/// #[attr]
241/// b: T,
242/// }
243/// }
244/// ❱
245/// ```
246///
247/// [Reference](https://doc.rust-lang.org/reference/items/enumerations.html)
248#[derive(Debug, Clone, PartialEq, Eq, Hash)]
249pub struct EnumDef {
250 pub(crate) syntax: SyntaxNode, 340 pub(crate) syntax: SyntaxNode,
251} 341}
252impl ast::VisibilityOwner for EnumDef {} 342impl WhereClause {
253impl ast::NameOwner for EnumDef {} 343 pub fn where_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![where]) }
254impl ast::TypeParamsOwner for EnumDef {} 344 pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) }
255impl ast::AttrsOwner for EnumDef {} 345}
256impl ast::DocCommentsOwner for EnumDef {} 346#[derive(Debug, Clone, PartialEq, Eq, Hash)]
257impl EnumDef { 347pub struct BlockExpr {
258 pub fn enum_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![enum]) }
259 pub fn variant_list(&self) -> Option<EnumVariantList> { support::child(&self.syntax) }
260}
261/// Enum variant definition list including enclosing curly braces.
262///
263/// ```
264/// enum Foo
265/// ❰
266/// {
267/// Bar,
268/// Baz(u32),
269/// Bruh {
270/// a: u32
271/// }
272/// }
273/// ❱
274/// ```
275///
276/// [Reference](https://doc.rust-lang.org/reference/items/enumerations.html)
277#[derive(Debug, Clone, PartialEq, Eq, Hash)]
278pub struct EnumVariantList {
279 pub(crate) syntax: SyntaxNode, 348 pub(crate) syntax: SyntaxNode,
280} 349}
281impl EnumVariantList { 350impl ast::AttrsOwner for BlockExpr {}
351impl ast::ModuleItemOwner for BlockExpr {}
352impl BlockExpr {
353 pub fn label(&self) -> Option<Label> { support::child(&self.syntax) }
282 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 354 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
283 pub fn variants(&self) -> AstChildren<EnumVariant> { support::children(&self.syntax) } 355 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) }
356 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
284 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 357 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
285} 358}
286/// Enum variant definition including its attributes and discriminant value definition. 359#[derive(Debug, Clone, PartialEq, Eq, Hash)]
287/// 360pub struct SelfParam {
288/// ```
289/// enum Foo {
290/// ❰
291/// /// Docs
292/// #[attr]
293/// Bar
294/// ❱
295///
296/// // same for tuple and record variants
297/// }
298/// ```
299///
300/// [Reference](https://doc.rust-lang.org/reference/items/enumerations.html)
301#[derive(Debug, Clone, PartialEq, Eq, Hash)]
302pub struct EnumVariant {
303 pub(crate) syntax: SyntaxNode, 361 pub(crate) syntax: SyntaxNode,
304} 362}
305impl ast::VisibilityOwner for EnumVariant {} 363impl ast::AttrsOwner for SelfParam {}
306impl ast::NameOwner for EnumVariant {} 364impl SelfParam {
307impl ast::DocCommentsOwner for EnumVariant {} 365 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
308impl ast::AttrsOwner for EnumVariant {} 366 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
309impl EnumVariant { 367 support::token(&self.syntax, T![lifetime])
310 pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) } 368 }
311 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 369 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
312 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 370 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
371 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
372 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
313} 373}
314/// Trait definition. 374#[derive(Debug, Clone, PartialEq, Eq, Hash)]
315/// Includes all of its attributes and doc comments. 375pub struct Param {
316///
317/// ```
318/// ❰
319/// /// Docs
320/// #[attr]
321/// pub unsafe trait Foo<T>: Debug where T: Debug {
322/// // ...
323/// }
324/// ❱
325/// ```
326///
327/// [Reference](https://doc.rust-lang.org/reference/items/traits.html)
328#[derive(Debug, Clone, PartialEq, Eq, Hash)]
329pub struct TraitDef {
330 pub(crate) syntax: SyntaxNode, 376 pub(crate) syntax: SyntaxNode,
331} 377}
332impl ast::VisibilityOwner for TraitDef {} 378impl ast::AttrsOwner for Param {}
333impl ast::NameOwner for TraitDef {} 379impl Param {
334impl ast::AttrsOwner for TraitDef {} 380 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
335impl ast::DocCommentsOwner for TraitDef {} 381 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
336impl ast::TypeParamsOwner for TraitDef {} 382 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
337impl ast::TypeBoundsOwner for TraitDef {} 383 pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) }
338impl TraitDef {
339 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
340 pub fn auto_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![auto]) }
341 pub fn trait_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![trait]) }
342 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
343} 384}
344/// Module definition either with body or not.
345/// Includes all of its inner and outer attributes, module items, doc comments.
346///
347/// ```
348/// ❰
349/// /// Docs
350/// #[attr]
351/// pub mod foo;
352/// ❱
353///
354/// ❰
355/// /// Docs
356/// #[attr]
357/// pub mod bar {
358/// //! Inner docs
359/// #![inner_attr]
360/// }
361/// ❱
362/// ```
363///
364/// [Reference](https://doc.rust-lang.org/reference/items/modules.html)
365#[derive(Debug, Clone, PartialEq, Eq, Hash)] 385#[derive(Debug, Clone, PartialEq, Eq, Hash)]
366pub struct Module { 386pub struct TypeBoundList {
367 pub(crate) syntax: SyntaxNode, 387 pub(crate) syntax: SyntaxNode,
368} 388}
369impl ast::VisibilityOwner for Module {} 389impl TypeBoundList {
370impl ast::NameOwner for Module {} 390 pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) }
371impl ast::AttrsOwner for Module {}
372impl ast::DocCommentsOwner for Module {}
373impl Module {
374 pub fn mod_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mod]) }
375 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
376 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
377} 391}
378/// Item defintion list.
379/// This is used for both top-level items and impl block items.
380///
381/// ```
382/// ❰
383/// fn foo {}
384/// struct Bar;
385/// enum Baz;
386/// trait Bruh;
387/// const BRUUH: u32 = 42;
388/// ❱
389///
390/// impl Foo
391/// ❰
392/// {
393/// fn bar() {}
394/// const BAZ: u32 = 42;
395/// }
396/// ❱
397/// ```
398///
399/// [Reference](https://doc.rust-lang.org/reference/items.html)
400#[derive(Debug, Clone, PartialEq, Eq, Hash)] 392#[derive(Debug, Clone, PartialEq, Eq, Hash)]
401pub struct ItemList { 393pub struct RecordFieldList {
402 pub(crate) syntax: SyntaxNode, 394 pub(crate) syntax: SyntaxNode,
403} 395}
404impl ast::ModuleItemOwner for ItemList {} 396impl RecordFieldList {
405impl ItemList {
406 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 397 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
407 pub fn assoc_items(&self) -> AstChildren<AssocItem> { support::children(&self.syntax) } 398 pub fn fields(&self) -> AstChildren<RecordField> { support::children(&self.syntax) }
408 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 399 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
409} 400}
410/// Constant variable definition. 401#[derive(Debug, Clone, PartialEq, Eq, Hash)]
411/// Includes all of its attributes and doc comments. 402pub struct TupleFieldList {
412///
413/// ```
414/// ❰
415/// /// Docs
416/// #[attr]
417/// pub const FOO: u32 = 42;
418/// ❱
419/// ```
420///
421/// [Reference](https://doc.rust-lang.org/reference/items/constant-items.html)
422#[derive(Debug, Clone, PartialEq, Eq, Hash)]
423pub struct ConstDef {
424 pub(crate) syntax: SyntaxNode, 403 pub(crate) syntax: SyntaxNode,
425} 404}
426impl ast::VisibilityOwner for ConstDef {} 405impl TupleFieldList {
427impl ast::NameOwner for ConstDef {} 406 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
428impl ast::TypeParamsOwner for ConstDef {} 407 pub fn fields(&self) -> AstChildren<TupleField> { support::children(&self.syntax) }
429impl ast::AttrsOwner for ConstDef {} 408 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
430impl ast::DocCommentsOwner for ConstDef {} 409}
431impl ast::TypeAscriptionOwner for ConstDef {} 410#[derive(Debug, Clone, PartialEq, Eq, Hash)]
432impl ConstDef { 411pub struct RecordField {
433 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } 412 pub(crate) syntax: SyntaxNode,
434 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 413}
435 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 414impl ast::AttrsOwner for RecordField {}
436 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } 415impl ast::NameOwner for RecordField {}
437 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 416impl ast::VisibilityOwner for RecordField {}
417impl RecordField {
418 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
419 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
438} 420}
439/// Static variable definition. 421#[derive(Debug, Clone, PartialEq, Eq, Hash)]
440/// Includes all of its attributes and doc comments. 422pub struct TupleField {
441///
442/// ```
443/// ❰
444/// /// Docs
445/// #[attr]
446/// pub static mut FOO: u32 = 42;
447/// ❱
448/// ```
449///
450/// [Reference](https://doc.rust-lang.org/reference/items/static-items.html)
451#[derive(Debug, Clone, PartialEq, Eq, Hash)]
452pub struct StaticDef {
453 pub(crate) syntax: SyntaxNode, 423 pub(crate) syntax: SyntaxNode,
454} 424}
455impl ast::VisibilityOwner for StaticDef {} 425impl ast::AttrsOwner for TupleField {}
456impl ast::NameOwner for StaticDef {} 426impl ast::VisibilityOwner for TupleField {}
457impl ast::TypeParamsOwner for StaticDef {} 427impl TupleField {
458impl ast::AttrsOwner for StaticDef {} 428 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
459impl ast::DocCommentsOwner for StaticDef {} 429}
460impl ast::TypeAscriptionOwner for StaticDef {} 430#[derive(Debug, Clone, PartialEq, Eq, Hash)]
461impl StaticDef { 431pub struct VariantList {
462 pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) } 432 pub(crate) syntax: SyntaxNode,
463 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 433}
434impl VariantList {
435 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
436 pub fn variants(&self) -> AstChildren<Variant> { support::children(&self.syntax) }
437 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
438}
439#[derive(Debug, Clone, PartialEq, Eq, Hash)]
440pub struct Variant {
441 pub(crate) syntax: SyntaxNode,
442}
443impl ast::AttrsOwner for Variant {}
444impl ast::NameOwner for Variant {}
445impl ast::VisibilityOwner for Variant {}
446impl Variant {
447 pub fn field_list(&self) -> Option<FieldList> { support::child(&self.syntax) }
464 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 448 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
465 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } 449 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
466 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
467} 450}
468/// Type alias definition. 451#[derive(Debug, Clone, PartialEq, Eq, Hash)]
469/// Includes associated type clauses with type bounds. 452pub struct AssocItemList {
470///
471/// ```
472/// ❰
473/// /// Docs
474/// #[attr]
475/// pub type Foo<T> where T: Debug = T;
476/// ❱
477///
478/// trait Bar {
479/// ❰ type Baz: Debug; ❱
480/// ❰ type Bruh = String; ❱
481/// ❰ type Bruuh: Debug = u32; ❱
482/// }
483/// ```
484///
485/// [Reference](https://doc.rust-lang.org/reference/items/type-aliases.html)
486#[derive(Debug, Clone, PartialEq, Eq, Hash)]
487pub struct TypeAliasDef {
488 pub(crate) syntax: SyntaxNode, 453 pub(crate) syntax: SyntaxNode,
489} 454}
490impl ast::VisibilityOwner for TypeAliasDef {} 455impl ast::AttrsOwner for AssocItemList {}
491impl ast::NameOwner for TypeAliasDef {} 456impl AssocItemList {
492impl ast::TypeParamsOwner for TypeAliasDef {} 457 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
493impl ast::AttrsOwner for TypeAliasDef {} 458 pub fn assoc_items(&self) -> AstChildren<AssocItem> { support::children(&self.syntax) }
494impl ast::DocCommentsOwner for TypeAliasDef {} 459 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
495impl ast::TypeBoundsOwner for TypeAliasDef {} 460}
496impl TypeAliasDef { 461#[derive(Debug, Clone, PartialEq, Eq, Hash)]
497 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } 462pub struct ExternItemList {
498 pub fn type_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![type]) } 463 pub(crate) syntax: SyntaxNode,
464}
465impl ast::AttrsOwner for ExternItemList {}
466impl ExternItemList {
467 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
468 pub fn extern_items(&self) -> AstChildren<ExternItem> { support::children(&self.syntax) }
469 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
470}
471#[derive(Debug, Clone, PartialEq, Eq, Hash)]
472pub struct LifetimeParam {
473 pub(crate) syntax: SyntaxNode,
474}
475impl ast::AttrsOwner for LifetimeParam {}
476impl LifetimeParam {
477 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
478 support::token(&self.syntax, T![lifetime])
479 }
480}
481#[derive(Debug, Clone, PartialEq, Eq, Hash)]
482pub struct TypeParam {
483 pub(crate) syntax: SyntaxNode,
484}
485impl ast::AttrsOwner for TypeParam {}
486impl ast::NameOwner for TypeParam {}
487impl ast::TypeBoundsOwner for TypeParam {}
488impl TypeParam {
499 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 489 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
500 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 490 pub fn default_type(&self) -> Option<TypeRef> { support::child(&self.syntax) }
501 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
502} 491}
503/// Inherent and trait impl definition. 492#[derive(Debug, Clone, PartialEq, Eq, Hash)]
504/// Includes all of its inner and outer attributes. 493pub struct ConstParam {
505///
506/// ```
507/// ❰
508/// #[attr]
509/// unsafe impl<T> const !Foo for Bar where T: Debug {
510/// #![inner_attr]
511/// // ...
512/// }
513/// ❱
514/// ```
515///
516/// [Reference](https://doc.rust-lang.org/reference/items/implementations.html)
517#[derive(Debug, Clone, PartialEq, Eq, Hash)]
518pub struct ImplDef {
519 pub(crate) syntax: SyntaxNode, 494 pub(crate) syntax: SyntaxNode,
520} 495}
521impl ast::TypeParamsOwner for ImplDef {} 496impl ast::AttrsOwner for ConstParam {}
522impl ast::AttrsOwner for ImplDef {} 497impl ast::NameOwner for ConstParam {}
523impl ast::DocCommentsOwner for ImplDef {} 498impl ConstParam {
524impl ImplDef {
525 pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) }
526 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 499 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
527 pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } 500 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
528 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) } 501 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
529 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) } 502 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
530 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } 503 pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) }
531 pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } 504}
505#[derive(Debug, Clone, PartialEq, Eq, Hash)]
506pub struct Literal {
507 pub(crate) syntax: SyntaxNode,
508}
509impl Literal {}
510#[derive(Debug, Clone, PartialEq, Eq, Hash)]
511pub struct TokenTree {
512 pub(crate) syntax: SyntaxNode,
513}
514impl TokenTree {
515 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
516 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
517 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
518 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
519 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
520 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
532} 521}
533/// Parenthesized type reference.
534/// Note: parens are only used for grouping, this is not a tuple type.
535///
536/// ```
537/// // This is effectively just `u32`.
538/// // Single-item tuple must be defined with a trailing comma: `(u32,)`
539/// type Foo = ❰ (u32) ❱;
540///
541/// let bar: &'static ❰ (dyn Debug) ❱ = "bruh";
542/// ```
543#[derive(Debug, Clone, PartialEq, Eq, Hash)] 522#[derive(Debug, Clone, PartialEq, Eq, Hash)]
544pub struct ParenType { 523pub struct ParenType {
545 pub(crate) syntax: SyntaxNode, 524 pub(crate) syntax: SyntaxNode,
546} 525}
547impl ParenType { 526impl ParenType {
548 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } 527 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
549 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 528 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
550 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 529 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
551} 530}
552/// Unnamed tuple type.
553///
554/// ```
555/// let foo: ❰ (u32, bool) ❱ = (42, true);
556/// ```
557///
558/// [Reference](https://doc.rust-lang.org/reference/types/tuple.html)
559#[derive(Debug, Clone, PartialEq, Eq, Hash)] 531#[derive(Debug, Clone, PartialEq, Eq, Hash)]
560pub struct TupleType { 532pub struct TupleType {
561 pub(crate) syntax: SyntaxNode, 533 pub(crate) syntax: SyntaxNode,
@@ -565,17 +537,6 @@ impl TupleType {
565 pub fn fields(&self) -> AstChildren<TypeRef> { support::children(&self.syntax) } 537 pub fn fields(&self) -> AstChildren<TypeRef> { support::children(&self.syntax) }
566 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 538 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
567} 539}
568/// The never type (i.e. the exclamation point).
569///
570/// ```
571/// type T = ❰ ! ❱;
572///
573/// fn no_return() -> ❰ ! ❱ {
574/// loop {}
575/// }
576/// ```
577///
578/// [Reference](https://doc.rust-lang.org/reference/types/never.html)
579#[derive(Debug, Clone, PartialEq, Eq, Hash)] 540#[derive(Debug, Clone, PartialEq, Eq, Hash)]
580pub struct NeverType { 541pub struct NeverType {
581 pub(crate) syntax: SyntaxNode, 542 pub(crate) syntax: SyntaxNode,
@@ -583,17 +544,6 @@ pub struct NeverType {
583impl NeverType { 544impl NeverType {
584 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) } 545 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
585} 546}
586/// Path to a type.
587/// Includes single identifier type names and elaborate paths with
588/// generic parameters.
589///
590/// ```
591/// type Foo = ❰ String ❱;
592/// type Bar = ❰ std::vec::Vec<T> ❱;
593/// type Baz = ❰ ::bruh::<Bruuh as Iterator>::Item ❱;
594/// ```
595///
596/// [Reference](https://doc.rust-lang.org/reference/paths.html)
597#[derive(Debug, Clone, PartialEq, Eq, Hash)] 547#[derive(Debug, Clone, PartialEq, Eq, Hash)]
598pub struct PathType { 548pub struct PathType {
599 pub(crate) syntax: SyntaxNode, 549 pub(crate) syntax: SyntaxNode,
@@ -601,14 +551,6 @@ pub struct PathType {
601impl PathType { 551impl PathType {
602 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 552 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
603} 553}
604/// Raw pointer type.
605///
606/// ```
607/// type Foo = ❰ *const u32 ❱;
608/// type Bar = ❰ *mut u32 ❱;
609/// ```
610///
611/// [Reference](https://doc.rust-lang.org/reference/types/pointer.html#raw-pointers-const-and-mut)
612#[derive(Debug, Clone, PartialEq, Eq, Hash)] 554#[derive(Debug, Clone, PartialEq, Eq, Hash)]
613pub struct PointerType { 555pub struct PointerType {
614 pub(crate) syntax: SyntaxNode, 556 pub(crate) syntax: SyntaxNode,
@@ -617,49 +559,28 @@ impl PointerType {
617 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) } 559 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) }
618 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 560 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
619 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 561 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
620 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 562 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
621} 563}
622/// Array type.
623///
624/// ```
625/// type Foo = ❰ [u32; 24 - 3] ❱;
626/// ```
627///
628/// [Reference](https://doc.rust-lang.org/reference/types/array.html)
629#[derive(Debug, Clone, PartialEq, Eq, Hash)] 564#[derive(Debug, Clone, PartialEq, Eq, Hash)]
630pub struct ArrayType { 565pub struct ArrayType {
631 pub(crate) syntax: SyntaxNode, 566 pub(crate) syntax: SyntaxNode,
632} 567}
633impl ArrayType { 568impl ArrayType {
634 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } 569 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
635 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 570 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
636 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 571 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
637 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 572 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
638 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 573 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
639} 574}
640/// Slice type.
641///
642/// ```
643/// type Foo = ❰ [u8] ❱;
644/// ```
645///
646/// [Reference](https://doc.rust-lang.org/reference/types/slice.html)
647#[derive(Debug, Clone, PartialEq, Eq, Hash)] 575#[derive(Debug, Clone, PartialEq, Eq, Hash)]
648pub struct SliceType { 576pub struct SliceType {
649 pub(crate) syntax: SyntaxNode, 577 pub(crate) syntax: SyntaxNode,
650} 578}
651impl SliceType { 579impl SliceType {
652 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } 580 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
653 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 581 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
654 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 582 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
655} 583}
656/// Reference type.
657///
658/// ```
659/// type Foo = ❰ &'static str ❱;
660/// ```
661///
662/// [Reference](https://doc.rust-lang.org/reference/types/pointer.html)
663#[derive(Debug, Clone, PartialEq, Eq, Hash)] 584#[derive(Debug, Clone, PartialEq, Eq, Hash)]
664pub struct ReferenceType { 585pub struct ReferenceType {
665 pub(crate) syntax: SyntaxNode, 586 pub(crate) syntax: SyntaxNode,
@@ -670,15 +591,8 @@ impl ReferenceType {
670 support::token(&self.syntax, T![lifetime]) 591 support::token(&self.syntax, T![lifetime])
671 } 592 }
672 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 593 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
673 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 594 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
674} 595}
675/// Placeholder type (i.e. the underscore).
676///
677/// ```
678/// let foo: ❰ _ ❱ = 42_u32;
679/// ```
680///
681/// [Reference](https://doc.rust-lang.org/reference/types/inferred.html)
682#[derive(Debug, Clone, PartialEq, Eq, Hash)] 596#[derive(Debug, Clone, PartialEq, Eq, Hash)]
683pub struct PlaceholderType { 597pub struct PlaceholderType {
684 pub(crate) syntax: SyntaxNode, 598 pub(crate) syntax: SyntaxNode,
@@ -686,15 +600,6 @@ pub struct PlaceholderType {
686impl PlaceholderType { 600impl PlaceholderType {
687 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) } 601 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
688} 602}
689/// Function pointer type (not to be confused with `Fn*` family of traits).
690///
691/// ```
692/// type Foo = ❰ async fn(#[attr] u32, named: bool) -> u32 ❱;
693///
694/// type Bar = ❰ extern "C" fn(variadic: u32, #[attr] ...) ❱;
695/// ```
696///
697/// [Reference](https://doc.rust-lang.org/reference/types/function-pointer.html)
698#[derive(Debug, Clone, PartialEq, Eq, Hash)] 603#[derive(Debug, Clone, PartialEq, Eq, Hash)]
699pub struct FnPointerType { 604pub struct FnPointerType {
700 pub(crate) syntax: SyntaxNode, 605 pub(crate) syntax: SyntaxNode,
@@ -706,59 +611,31 @@ impl FnPointerType {
706 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } 611 pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
707 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } 612 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
708} 613}
709/// Higher order type.
710///
711/// ```
712/// type Foo = ❰ for<'a> fn(&'a str) ❱;
713/// ```
714///
715/// [Reference](https://doc.rust-lang.org/nomicon/hrtb.html)
716#[derive(Debug, Clone, PartialEq, Eq, Hash)] 614#[derive(Debug, Clone, PartialEq, Eq, Hash)]
717pub struct ForType { 615pub struct ForType {
718 pub(crate) syntax: SyntaxNode, 616 pub(crate) syntax: SyntaxNode,
719} 617}
720impl ForType { 618impl ForType {
721 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } 619 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
722 pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) } 620 pub fn generic_param_list(&self) -> Option<GenericParamList> { support::child(&self.syntax) }
723 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 621 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
724} 622}
725/// Opaque `impl Trait` type.
726///
727/// ```
728/// fn foo(bar: ❰ impl Debug + Eq ❱) {}
729/// ```
730///
731/// [Reference](https://doc.rust-lang.org/reference/types/impl-trait.html)
732#[derive(Debug, Clone, PartialEq, Eq, Hash)] 623#[derive(Debug, Clone, PartialEq, Eq, Hash)]
733pub struct ImplTraitType { 624pub struct ImplTraitType {
734 pub(crate) syntax: SyntaxNode, 625 pub(crate) syntax: SyntaxNode,
735} 626}
736impl ast::TypeBoundsOwner for ImplTraitType {}
737impl ImplTraitType { 627impl ImplTraitType {
738 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) } 628 pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) }
629 pub fn type_bound_list(&self) -> Option<TypeBoundList> { support::child(&self.syntax) }
739} 630}
740/// Trait object type.
741///
742/// ```
743/// type Foo = ❰ dyn Debug ❱;
744/// ```
745///
746/// [Reference](https://doc.rust-lang.org/reference/types/trait-object.html)
747#[derive(Debug, Clone, PartialEq, Eq, Hash)] 631#[derive(Debug, Clone, PartialEq, Eq, Hash)]
748pub struct DynTraitType { 632pub struct DynTraitType {
749 pub(crate) syntax: SyntaxNode, 633 pub(crate) syntax: SyntaxNode,
750} 634}
751impl ast::TypeBoundsOwner for DynTraitType {}
752impl DynTraitType { 635impl DynTraitType {
753 pub fn dyn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![dyn]) } 636 pub fn dyn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![dyn]) }
637 pub fn type_bound_list(&self) -> Option<TypeBoundList> { support::child(&self.syntax) }
754} 638}
755/// Tuple literal.
756///
757/// ```
758/// ❰ (42, true) ❱;
759/// ```
760///
761/// [Reference](https://doc.rust-lang.org/reference/expressions/tuple-expr.html)
762#[derive(Debug, Clone, PartialEq, Eq, Hash)] 639#[derive(Debug, Clone, PartialEq, Eq, Hash)]
763pub struct TupleExpr { 640pub struct TupleExpr {
764 pub(crate) syntax: SyntaxNode, 641 pub(crate) syntax: SyntaxNode,
@@ -769,15 +646,6 @@ impl TupleExpr {
769 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) } 646 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
770 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 647 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
771} 648}
772/// Array literal.
773///
774/// ```
775/// ❰ [#![inner_attr] true, false, true] ❱;
776///
777/// ❰ ["baz"; 24] ❱;
778/// ```
779///
780/// [Reference](https://doc.rust-lang.org/reference/expressions/array-expr.html)
781#[derive(Debug, Clone, PartialEq, Eq, Hash)] 649#[derive(Debug, Clone, PartialEq, Eq, Hash)]
782pub struct ArrayExpr { 650pub struct ArrayExpr {
783 pub(crate) syntax: SyntaxNode, 651 pub(crate) syntax: SyntaxNode,
@@ -786,17 +654,10 @@ impl ast::AttrsOwner for ArrayExpr {}
786impl ArrayExpr { 654impl ArrayExpr {
787 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } 655 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
788 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) } 656 pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
657 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
789 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 658 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
790 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 659 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
791} 660}
792/// Parenthesized expression.
793/// Note: parens are only used for grouping, this is not a tuple literal.
794///
795/// ```
796/// ❰ (#![inner_attr] 2 + 2) ❱ * 2;
797/// ```
798///
799/// [Reference](https://doc.rust-lang.org/reference/expressions/grouped-expr.html)
800#[derive(Debug, Clone, PartialEq, Eq, Hash)] 661#[derive(Debug, Clone, PartialEq, Eq, Hash)]
801pub struct ParenExpr { 662pub struct ParenExpr {
802 pub(crate) syntax: SyntaxNode, 663 pub(crate) syntax: SyntaxNode,
@@ -807,19 +668,6 @@ impl ParenExpr {
807 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 668 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
808 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 669 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
809} 670}
810/// Path to a symbol in expression context.
811/// Includes single identifier variable names and elaborate paths with
812/// generic parameters.
813///
814/// ```
815/// ❰ Some::<i32> ❱;
816/// ❰ foo ❱ + 42;
817/// ❰ Vec::<i32>::push ❱;
818/// ❰ <[i32]>::reverse ❱;
819/// ❰ <String as std::borrow::Borrow<str>>::borrow ❱;
820/// ```
821///
822/// [Reference](https://doc.rust-lang.org/reference/expressions/path-expr.html)
823#[derive(Debug, Clone, PartialEq, Eq, Hash)] 671#[derive(Debug, Clone, PartialEq, Eq, Hash)]
824pub struct PathExpr { 672pub struct PathExpr {
825 pub(crate) syntax: SyntaxNode, 673 pub(crate) syntax: SyntaxNode,
@@ -827,17 +675,6 @@ pub struct PathExpr {
827impl PathExpr { 675impl PathExpr {
828 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 676 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
829} 677}
830/// Anonymous callable object literal a.k.a. closure, lambda or functor.
831///
832/// ```
833/// ❰ || 42 ❱;
834/// ❰ |a: u32| val + 1 ❱;
835/// ❰ async |#[attr] Pattern(_): Pattern| { bar } ❱;
836/// ❰ move || baz ❱;
837/// ❰ || -> u32 { closure_with_ret_type_annotation_requires_block_expr } ❱
838/// ```
839///
840/// [Reference](https://doc.rust-lang.org/reference/expressions/closure-expr.html)
841#[derive(Debug, Clone, PartialEq, Eq, Hash)] 678#[derive(Debug, Clone, PartialEq, Eq, Hash)]
842pub struct LambdaExpr { 679pub struct LambdaExpr {
843 pub(crate) syntax: SyntaxNode, 680 pub(crate) syntax: SyntaxNode,
@@ -851,25 +688,6 @@ impl LambdaExpr {
851 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } 688 pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
852 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } 689 pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
853} 690}
854/// If expression. Includes both regular `if` and `if let` forms.
855/// Beware that `else if` is a special case syntax sugar, because in general
856/// there has to be block expression after `else`.
857///
858/// ```
859/// ❰ if bool_cond { 42 } ❱
860/// ❰ if bool_cond { 42 } else { 24 } ❱
861/// ❰ if bool_cond { 42 } else if bool_cond2 { 42 } ❱
862///
863/// ❰
864/// if let Pattern(foo) = bar {
865/// foo
866/// } else {
867/// panic!();
868/// }
869/// ❱
870/// ```
871///
872/// [Reference](https://doc.rust-lang.org/reference/expressions/if-expr.html)
873#[derive(Debug, Clone, PartialEq, Eq, Hash)] 691#[derive(Debug, Clone, PartialEq, Eq, Hash)]
874pub struct IfExpr { 692pub struct IfExpr {
875 pub(crate) syntax: SyntaxNode, 693 pub(crate) syntax: SyntaxNode,
@@ -879,40 +697,16 @@ impl IfExpr {
879 pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) } 697 pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) }
880 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } 698 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
881} 699}
882/// Unconditional loop expression.
883///
884/// ```
885/// ❰
886/// loop {
887/// // yeah, it's that simple...
888/// }
889/// ❱
890/// ```
891///
892/// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html)
893#[derive(Debug, Clone, PartialEq, Eq, Hash)] 700#[derive(Debug, Clone, PartialEq, Eq, Hash)]
894pub struct LoopExpr { 701pub struct Condition {
895 pub(crate) syntax: SyntaxNode, 702 pub(crate) syntax: SyntaxNode,
896} 703}
897impl ast::AttrsOwner for LoopExpr {} 704impl Condition {
898impl ast::LoopBodyOwner for LoopExpr {} 705 pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) }
899impl LoopExpr { 706 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
900 pub fn loop_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![loop]) } 707 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
708 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
901} 709}
902/// Block expression with an optional prefix (label, try ketword,
903/// unsafe keyword, async keyword...).
904///
905/// ```
906/// ❰
907/// 'label: try {
908/// None?
909/// }
910/// ❱
911/// ```
912///
913/// - [try block](https://doc.rust-lang.org/unstable-book/language-features/try-blocks.html)
914/// - [unsafe block](https://doc.rust-lang.org/reference/expressions/block-expr.html#unsafe-blocks)
915/// - [async block](https://doc.rust-lang.org/reference/expressions/block-expr.html#async-blocks)
916#[derive(Debug, Clone, PartialEq, Eq, Hash)] 710#[derive(Debug, Clone, PartialEq, Eq, Hash)]
917pub struct EffectExpr { 711pub struct EffectExpr {
918 pub(crate) syntax: SyntaxNode, 712 pub(crate) syntax: SyntaxNode,
@@ -925,19 +719,24 @@ impl EffectExpr {
925 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) } 719 pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
926 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) } 720 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
927} 721}
928/// For loop expression. 722#[derive(Debug, Clone, PartialEq, Eq, Hash)]
929/// Note: record struct literals are not valid as iterable expression 723pub struct Label {
930/// due to ambiguity. 724 pub(crate) syntax: SyntaxNode,
931/// 725}
932/// ``` 726impl Label {
933/// ❰ 727 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
934/// for i in (0..4) { 728 support::token(&self.syntax, T![lifetime])
935/// dbg!(i); 729 }
936/// } 730}
937/// ❱ 731#[derive(Debug, Clone, PartialEq, Eq, Hash)]
938/// ``` 732pub struct LoopExpr {
939/// 733 pub(crate) syntax: SyntaxNode,
940/// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#iterator-loops) 734}
735impl ast::AttrsOwner for LoopExpr {}
736impl ast::LoopBodyOwner for LoopExpr {}
737impl LoopExpr {
738 pub fn loop_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![loop]) }
739}
941#[derive(Debug, Clone, PartialEq, Eq, Hash)] 740#[derive(Debug, Clone, PartialEq, Eq, Hash)]
942pub struct ForExpr { 741pub struct ForExpr {
943 pub(crate) syntax: SyntaxNode, 742 pub(crate) syntax: SyntaxNode,
@@ -950,22 +749,6 @@ impl ForExpr {
950 pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) } 749 pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) }
951 pub fn iterable(&self) -> Option<Expr> { support::child(&self.syntax) } 750 pub fn iterable(&self) -> Option<Expr> { support::child(&self.syntax) }
952} 751}
953/// While loop expression. Includes both regular `while` and `while let` forms.
954///
955/// ```
956/// ❰
957/// while bool_cond {
958/// 42;
959/// }
960/// ❱
961/// ❰
962/// while let Pattern(foo) = bar {
963/// bar += 1;
964/// }
965/// ❱
966/// ```
967///
968/// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#predicate-loops)
969#[derive(Debug, Clone, PartialEq, Eq, Hash)] 752#[derive(Debug, Clone, PartialEq, Eq, Hash)]
970pub struct WhileExpr { 753pub struct WhileExpr {
971 pub(crate) syntax: SyntaxNode, 754 pub(crate) syntax: SyntaxNode,
@@ -976,22 +759,6 @@ impl WhileExpr {
976 pub fn while_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![while]) } 759 pub fn while_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![while]) }
977 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } 760 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
978} 761}
979/// Continue expression.
980///
981/// ```
982/// while bool_cond {
983/// ❰ continue ❱;
984/// }
985///
986/// 'outer: loop {
987/// loop {
988/// ❰ continue 'outer ❱;
989/// }
990/// }
991///
992/// ```
993///
994/// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#continue-expressions)
995#[derive(Debug, Clone, PartialEq, Eq, Hash)] 762#[derive(Debug, Clone, PartialEq, Eq, Hash)]
996pub struct ContinueExpr { 763pub struct ContinueExpr {
997 pub(crate) syntax: SyntaxNode, 764 pub(crate) syntax: SyntaxNode,
@@ -1005,25 +772,6 @@ impl ContinueExpr {
1005 support::token(&self.syntax, T![lifetime]) 772 support::token(&self.syntax, T![lifetime])
1006 } 773 }
1007} 774}
1008/// Break expression.
1009///
1010/// ```
1011/// while bool_cond {
1012/// ❰ break ❱;
1013/// }
1014/// 'outer: loop {
1015/// for foo in bar {
1016/// ❰ break 'outer ❱;
1017/// }
1018/// }
1019/// 'outer: loop {
1020/// loop {
1021/// ❰ break 'outer 42 ❱;
1022/// }
1023/// }
1024/// ```
1025///
1026/// [Refernce](https://doc.rust-lang.org/reference/expressions/loop-expr.html#break-expressions)
1027#[derive(Debug, Clone, PartialEq, Eq, Hash)] 775#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1028pub struct BreakExpr { 776pub struct BreakExpr {
1029 pub(crate) syntax: SyntaxNode, 777 pub(crate) syntax: SyntaxNode,
@@ -1036,104 +784,33 @@ impl BreakExpr {
1036 } 784 }
1037 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 785 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1038} 786}
1039/// Label.
1040///
1041/// ```
1042/// ❰ 'outer: ❱ loop {}
1043///
1044/// let foo = ❰ 'bar: ❱ loop {}
1045///
1046/// ❰ 'baz: ❱ {
1047/// break 'baz;
1048/// }
1049/// ```
1050///
1051/// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html?highlight=label#loop-labels)
1052/// [Labels for blocks RFC](https://github.com/rust-lang/rfcs/blob/master/text/2046-label-break-value.md)
1053#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1054pub struct Label {
1055 pub(crate) syntax: SyntaxNode,
1056}
1057impl Label {
1058 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1059 support::token(&self.syntax, T![lifetime])
1060 }
1061}
1062/// Block expression. Includes unsafe blocks and block labels.
1063///
1064/// ```
1065/// let foo = ❰
1066/// {
1067/// #![inner_attr]
1068/// ❰ { } ❱
1069///
1070/// ❰ 'label: { break 'label } ❱
1071/// }
1072/// ❱;
1073/// ```
1074///
1075/// [Reference](https://doc.rust-lang.org/reference/expressions/block-expr.html)
1076/// [Labels for blocks RFC](https://github.com/rust-lang/rfcs/blob/master/text/2046-label-break-value.md)
1077#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1078pub struct BlockExpr {
1079 pub(crate) syntax: SyntaxNode,
1080}
1081impl ast::AttrsOwner for BlockExpr {}
1082impl ast::ModuleItemOwner for BlockExpr {}
1083impl BlockExpr {
1084 pub fn label(&self) -> Option<Label> { support::child(&self.syntax) }
1085 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1086 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) }
1087 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1088 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1089}
1090/// Return expression.
1091///
1092/// ```
1093/// || ❰ return 42 ❱;
1094///
1095/// fn bar() {
1096/// ❰ return ❱;
1097/// }
1098/// ```
1099///
1100/// [Reference](https://doc.rust-lang.org/reference/expressions/return-expr.html)
1101#[derive(Debug, Clone, PartialEq, Eq, Hash)] 787#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1102pub struct ReturnExpr { 788pub struct ReturnExpr {
1103 pub(crate) syntax: SyntaxNode, 789 pub(crate) syntax: SyntaxNode,
1104} 790}
1105impl ast::AttrsOwner for ReturnExpr {} 791impl ast::AttrsOwner for ReturnExpr {}
1106impl ReturnExpr { 792impl ReturnExpr {
793 pub fn return_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![return]) }
1107 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 794 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1108} 795}
1109/// Call expression (not to be confused with method call expression, it is
1110/// a separate ast node).
1111///
1112/// ```
1113/// ❰ foo() ❱;
1114/// ❰ &str::len("bar") ❱;
1115/// ❰ <&str as PartialEq<&str>>::eq(&"", &"") ❱;
1116/// ```
1117///
1118/// [Reference](https://doc.rust-lang.org/reference/expressions/call-expr.html)
1119#[derive(Debug, Clone, PartialEq, Eq, Hash)] 796#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1120pub struct CallExpr { 797pub struct CallExpr {
1121 pub(crate) syntax: SyntaxNode, 798 pub(crate) syntax: SyntaxNode,
1122} 799}
800impl ast::AttrsOwner for CallExpr {}
1123impl ast::ArgListOwner for CallExpr {} 801impl ast::ArgListOwner for CallExpr {}
1124impl CallExpr { 802impl CallExpr {
1125 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 803 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1126} 804}
1127/// Method call expression. 805#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1128/// 806pub struct ArgList {
1129/// ``` 807 pub(crate) syntax: SyntaxNode,
1130/// ❰ receiver_expr.method() ❱; 808}
1131/// ❰ receiver_expr.method::<T>(42, true) ❱; 809impl ArgList {
1132/// 810 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
1133/// ❰ ❰ ❰ foo.bar() ❱ .baz() ❱ .bruh() ❱; 811 pub fn args(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
1134/// ``` 812 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1135/// 813}
1136/// [Reference](https://doc.rust-lang.org/reference/expressions/method-call-expr.html)
1137#[derive(Debug, Clone, PartialEq, Eq, Hash)] 814#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1138pub struct MethodCallExpr { 815pub struct MethodCallExpr {
1139 pub(crate) syntax: SyntaxNode, 816 pub(crate) syntax: SyntaxNode,
@@ -1146,31 +823,19 @@ impl MethodCallExpr {
1146 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 823 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1147 pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) } 824 pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) }
1148} 825}
1149/// Index expression a.k.a. subscript operator call.
1150///
1151/// ```
1152/// ❰ foo[42] ❱;
1153/// ```
1154///
1155/// [Reference](https://doc.rust-lang.org/reference/expressions/array-expr.html)
1156#[derive(Debug, Clone, PartialEq, Eq, Hash)] 826#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1157pub struct IndexExpr { 827pub struct TypeArgList {
1158 pub(crate) syntax: SyntaxNode, 828 pub(crate) syntax: SyntaxNode,
1159} 829}
1160impl ast::AttrsOwner for IndexExpr {} 830impl TypeArgList {
1161impl IndexExpr { 831 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
1162 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } 832 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
1163 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 833 pub fn type_args(&self) -> AstChildren<TypeArg> { support::children(&self.syntax) }
834 pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> { support::children(&self.syntax) }
835 pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> { support::children(&self.syntax) }
836 pub fn const_args(&self) -> AstChildren<ConstArg> { support::children(&self.syntax) }
837 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
1164} 838}
1165/// Field access expression.
1166///
1167/// ```
1168/// ❰ expr.bar ❱;
1169///
1170/// ❰ ❰ ❰ foo.bar ❱ .baz ❱ .bruh ❱;
1171/// ```
1172///
1173/// [Reference](https://doc.rust-lang.org/reference/expressions/field-expr.html)
1174#[derive(Debug, Clone, PartialEq, Eq, Hash)] 839#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1175pub struct FieldExpr { 840pub struct FieldExpr {
1176 pub(crate) syntax: SyntaxNode, 841 pub(crate) syntax: SyntaxNode,
@@ -1181,13 +846,15 @@ impl FieldExpr {
1181 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) } 846 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) }
1182 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 847 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1183} 848}
1184/// Await operator call expression. 849#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1185/// 850pub struct IndexExpr {
1186/// ``` 851 pub(crate) syntax: SyntaxNode,
1187/// ❰ expr.await ❱; 852}
1188/// ``` 853impl ast::AttrsOwner for IndexExpr {}
1189/// 854impl IndexExpr {
1190/// [Reference](https://doc.rust-lang.org/reference/expressions/await-expr.html) 855 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
856 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
857}
1191#[derive(Debug, Clone, PartialEq, Eq, Hash)] 858#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1192pub struct AwaitExpr { 859pub struct AwaitExpr {
1193 pub(crate) syntax: SyntaxNode, 860 pub(crate) syntax: SyntaxNode,
@@ -1198,13 +865,6 @@ impl AwaitExpr {
1198 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) } 865 pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) }
1199 pub fn await_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![await]) } 866 pub fn await_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![await]) }
1200} 867}
1201/// The question mark operator call.
1202///
1203/// ```
1204/// ❰ expr? ❱;
1205/// ```
1206///
1207/// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#the-question-mark-operator)
1208#[derive(Debug, Clone, PartialEq, Eq, Hash)] 868#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1209pub struct TryExpr { 869pub struct TryExpr {
1210 pub(crate) syntax: SyntaxNode, 870 pub(crate) syntax: SyntaxNode,
@@ -1214,13 +874,6 @@ impl TryExpr {
1214 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 874 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1215 pub fn question_mark_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![?]) } 875 pub fn question_mark_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![?]) }
1216} 876}
1217/// Type cast expression.
1218///
1219/// ```
1220/// ❰ expr as T ❱;
1221/// ```
1222///
1223/// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#type-cast-expressions)
1224#[derive(Debug, Clone, PartialEq, Eq, Hash)] 877#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1225pub struct CastExpr { 878pub struct CastExpr {
1226 pub(crate) syntax: SyntaxNode, 879 pub(crate) syntax: SyntaxNode,
@@ -1229,18 +882,8 @@ impl ast::AttrsOwner for CastExpr {}
1229impl CastExpr { 882impl CastExpr {
1230 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 883 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1231 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) } 884 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
1232 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 885 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
1233} 886}
1234/// Borrow operator call.
1235///
1236/// ```
1237/// ❰ &foo ❱;
1238/// ❰ &mut bar ❱;
1239/// ❰ &raw const bar ❱;
1240/// ❰ &raw mut bar ❱;
1241/// ```
1242///
1243/// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#borrow-operators)
1244#[derive(Debug, Clone, PartialEq, Eq, Hash)] 887#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1245pub struct RefExpr { 888pub struct RefExpr {
1246 pub(crate) syntax: SyntaxNode, 889 pub(crate) syntax: SyntaxNode,
@@ -1253,15 +896,6 @@ impl RefExpr {
1253 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 896 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
1254 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 897 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1255} 898}
1256/// Prefix operator call. This is either `!` or `*` or `-`.
1257///
1258/// ```
1259/// ❰ !foo ❱;
1260/// ❰ *bar ❱;
1261/// ❰ -42 ❱;
1262/// ```
1263///
1264/// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html)
1265#[derive(Debug, Clone, PartialEq, Eq, Hash)] 899#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1266pub struct PrefixExpr { 900pub struct PrefixExpr {
1267 pub(crate) syntax: SyntaxNode, 901 pub(crate) syntax: SyntaxNode,
@@ -1270,13 +904,6 @@ impl ast::AttrsOwner for PrefixExpr {}
1270impl PrefixExpr { 904impl PrefixExpr {
1271 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 905 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1272} 906}
1273/// Box operator call.
1274///
1275/// ```
1276/// ❰ box 42 ❱;
1277/// ```
1278///
1279/// [RFC](https://github.com/rust-lang/rfcs/blob/0806be4f282144cfcd55b1d20284b43f87cbe1c6/text/0809-box-and-in-for-stdlib.md)
1280#[derive(Debug, Clone, PartialEq, Eq, Hash)] 907#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1281pub struct BoxExpr { 908pub struct BoxExpr {
1282 pub(crate) syntax: SyntaxNode, 909 pub(crate) syntax: SyntaxNode,
@@ -1286,69 +913,18 @@ impl BoxExpr {
1286 pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) } 913 pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) }
1287 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 914 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1288} 915}
1289/// Range operator call.
1290///
1291/// ```
1292/// ❰ 0..42 ❱;
1293/// ❰ ..42 ❱;
1294/// ❰ 0.. ❱;
1295/// ❰ .. ❱;
1296/// ❰ 0..=42 ❱;
1297/// ❰ ..=42 ❱;
1298/// ```
1299///
1300/// [Reference](https://doc.rust-lang.org/reference/expressions/range-expr.html)
1301#[derive(Debug, Clone, PartialEq, Eq, Hash)] 916#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1302pub struct RangeExpr { 917pub struct RangeExpr {
1303 pub(crate) syntax: SyntaxNode, 918 pub(crate) syntax: SyntaxNode,
1304} 919}
1305impl ast::AttrsOwner for RangeExpr {} 920impl ast::AttrsOwner for RangeExpr {}
1306impl RangeExpr {} 921impl RangeExpr {}
1307/// Binary operator call.
1308/// Includes all arithmetic, logic, bitwise and assignment operators.
1309///
1310/// ```
1311/// ❰ 2 + ❰ 2 * 2 ❱ ❱;
1312/// ❰ ❰ true && false ❱ || true ❱;
1313/// ```
1314///
1315/// [Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#arithmetic-and-logical-binary-operators)
1316#[derive(Debug, Clone, PartialEq, Eq, Hash)] 922#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1317pub struct BinExpr { 923pub struct BinExpr {
1318 pub(crate) syntax: SyntaxNode, 924 pub(crate) syntax: SyntaxNode,
1319} 925}
1320impl ast::AttrsOwner for BinExpr {} 926impl ast::AttrsOwner for BinExpr {}
1321impl BinExpr {} 927impl BinExpr {}
1322/// [Raw] string, [raw] byte string, char, byte, integer, float or bool literal.
1323///
1324/// ```
1325/// ❰ "str" ❱;
1326/// ❰ br##"raw byte str"## ❱;
1327/// ❰ 'c' ❱;
1328/// ❰ b'c' ❱;
1329/// ❰ 42 ❱;
1330/// ❰ 1e9 ❱;
1331/// ❰ true ❱;
1332/// ```
1333///
1334/// [Reference](https://doc.rust-lang.org/reference/expressions/literal-expr.html)
1335#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1336pub struct Literal {
1337 pub(crate) syntax: SyntaxNode,
1338}
1339impl Literal {}
1340/// Match expression.
1341///
1342/// ```
1343/// ❰
1344/// match expr {
1345/// Pat1 => {}
1346/// Pat2(_) => 42,
1347/// }
1348/// ❱
1349/// ```
1350///
1351/// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html)
1352#[derive(Debug, Clone, PartialEq, Eq, Hash)] 928#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1353pub struct MatchExpr { 929pub struct MatchExpr {
1354 pub(crate) syntax: SyntaxNode, 930 pub(crate) syntax: SyntaxNode,
@@ -1359,40 +935,15 @@ impl MatchExpr {
1359 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 935 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1360 pub fn match_arm_list(&self) -> Option<MatchArmList> { support::child(&self.syntax) } 936 pub fn match_arm_list(&self) -> Option<MatchArmList> { support::child(&self.syntax) }
1361} 937}
1362/// Match arm list part of match expression. Includes its inner attributes.
1363///
1364/// ```
1365/// match expr
1366/// ❰
1367/// {
1368/// #![inner_attr]
1369/// Pat1 => {}
1370/// Pat2(_) => 42,
1371/// }
1372/// ❱
1373/// ```
1374///
1375/// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html)
1376#[derive(Debug, Clone, PartialEq, Eq, Hash)] 938#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1377pub struct MatchArmList { 939pub struct MatchArmList {
1378 pub(crate) syntax: SyntaxNode, 940 pub(crate) syntax: SyntaxNode,
1379} 941}
1380impl ast::AttrsOwner for MatchArmList {}
1381impl MatchArmList { 942impl MatchArmList {
1382 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 943 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1383 pub fn arms(&self) -> AstChildren<MatchArm> { support::children(&self.syntax) } 944 pub fn arms(&self) -> AstChildren<MatchArm> { support::children(&self.syntax) }
1384 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 945 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1385} 946}
1386/// Match arm.
1387/// Note: record struct literals are not valid as target match expression
1388/// due to ambiguity.
1389/// ```
1390/// match expr {
1391/// ❰ #[attr] Pattern(it) if bool_cond => it ❱,
1392/// }
1393/// ```
1394///
1395/// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html)
1396#[derive(Debug, Clone, PartialEq, Eq, Hash)] 947#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1397pub struct MatchArm { 948pub struct MatchArm {
1398 pub(crate) syntax: SyntaxNode, 949 pub(crate) syntax: SyntaxNode,
@@ -1404,15 +955,6 @@ impl MatchArm {
1404 pub fn fat_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=>]) } 955 pub fn fat_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=>]) }
1405 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 956 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1406} 957}
1407/// Match guard.
1408///
1409/// ```
1410/// match expr {
1411/// Pattern(it) ❰ if bool_cond ❱ => it,
1412/// }
1413/// ```
1414///
1415/// [Reference](https://doc.rust-lang.org/reference/expressions/match-expr.html#match-guards)
1416#[derive(Debug, Clone, PartialEq, Eq, Hash)] 958#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1417pub struct MatchGuard { 959pub struct MatchGuard {
1418 pub(crate) syntax: SyntaxNode, 960 pub(crate) syntax: SyntaxNode,
@@ -1421,76 +963,37 @@ impl MatchGuard {
1421 pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) } 963 pub fn if_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![if]) }
1422 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 964 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1423} 965}
1424/// Record literal expression. The same syntax is used for structs, 966#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1425/// unions and record enum variants. 967pub struct RecordExpr {
1426///
1427/// ```
1428/// ❰
1429/// foo::Bar {
1430/// #![inner_attr]
1431/// baz: 42,
1432/// bruh: true,
1433/// ..spread
1434/// }
1435/// ❱
1436/// ```
1437///
1438/// [Reference](https://doc.rust-lang.org/reference/expressions/struct-expr.html)
1439#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1440pub struct RecordLit {
1441 pub(crate) syntax: SyntaxNode, 968 pub(crate) syntax: SyntaxNode,
1442} 969}
1443impl RecordLit { 970impl RecordExpr {
1444 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 971 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1445 pub fn record_field_list(&self) -> Option<RecordFieldList> { support::child(&self.syntax) } 972 pub fn record_expr_field_list(&self) -> Option<RecordExprFieldList> {
973 support::child(&self.syntax)
974 }
1446} 975}
1447/// Record field list including enclosing curly braces.
1448///
1449/// foo::Bar ❰
1450/// {
1451/// baz: 42,
1452/// ..spread
1453/// }
1454/// ❱
1455///
1456/// [Reference](https://doc.rust-lang.org/reference/expressions/struct-expr.html)
1457#[derive(Debug, Clone, PartialEq, Eq, Hash)] 976#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1458pub struct RecordFieldList { 977pub struct RecordExprFieldList {
1459 pub(crate) syntax: SyntaxNode, 978 pub(crate) syntax: SyntaxNode,
1460} 979}
1461impl RecordFieldList { 980impl RecordExprFieldList {
1462 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 981 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1463 pub fn fields(&self) -> AstChildren<RecordField> { support::children(&self.syntax) } 982 pub fn fields(&self) -> AstChildren<RecordExprField> { support::children(&self.syntax) }
1464 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) } 983 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
1465 pub fn spread(&self) -> Option<Expr> { support::child(&self.syntax) } 984 pub fn spread(&self) -> Option<Expr> { support::child(&self.syntax) }
1466 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 985 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1467} 986}
1468/// Record field.
1469///
1470/// ```
1471/// foo::Bar {
1472/// ❰ #[attr] baz: 42 ❱
1473/// }
1474/// ```
1475///
1476/// [Reference](https://doc.rust-lang.org/reference/expressions/struct-expr.html)
1477#[derive(Debug, Clone, PartialEq, Eq, Hash)] 987#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1478pub struct RecordField { 988pub struct RecordExprField {
1479 pub(crate) syntax: SyntaxNode, 989 pub(crate) syntax: SyntaxNode,
1480} 990}
1481impl ast::AttrsOwner for RecordField {} 991impl ast::AttrsOwner for RecordExprField {}
1482impl RecordField { 992impl RecordExprField {
1483 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 993 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
1484 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } 994 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
1485 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 995 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1486} 996}
1487/// Disjunction of patterns.
1488///
1489/// ```
1490/// let ❰ Foo(it) | Bar(it) | Baz(it) ❱ = bruh;
1491/// ```
1492///
1493/// [Reference](https://doc.rust-lang.org/reference/patterns.html)
1494#[derive(Debug, Clone, PartialEq, Eq, Hash)] 997#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1495pub struct OrPat { 998pub struct OrPat {
1496 pub(crate) syntax: SyntaxNode, 999 pub(crate) syntax: SyntaxNode,
@@ -1498,14 +1001,6 @@ pub struct OrPat {
1498impl OrPat { 1001impl OrPat {
1499 pub fn pats(&self) -> AstChildren<Pat> { support::children(&self.syntax) } 1002 pub fn pats(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1500} 1003}
1501/// Parenthesized pattern.
1502/// Note: parens are only used for grouping, this is not a tuple pattern.
1503///
1504/// ```
1505/// if let ❰ &(0..=42) ❱ = foo {}
1506/// ```
1507///
1508/// https://doc.rust-lang.org/reference/patterns.html#grouped-patterns
1509#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1004#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1510pub struct ParenPat { 1005pub struct ParenPat {
1511 pub(crate) syntax: SyntaxNode, 1006 pub(crate) syntax: SyntaxNode,
@@ -1515,16 +1010,6 @@ impl ParenPat {
1515 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1010 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1516 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 1011 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1517} 1012}
1518/// Reference pattern.
1519/// Note: this has nothing to do with `ref` keyword, the latter is used in bind patterns.
1520///
1521/// ```
1522/// let ❰ &mut foo ❱ = bar;
1523///
1524/// let ❰ & ❰ &mut ❰ &_ ❱ ❱ ❱ = baz;
1525/// ```
1526///
1527/// [Reference](https://doc.rust-lang.org/reference/patterns.html#reference-patterns)
1528#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1013#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1529pub struct RefPat { 1014pub struct RefPat {
1530 pub(crate) syntax: SyntaxNode, 1015 pub(crate) syntax: SyntaxNode,
@@ -1534,31 +1019,14 @@ impl RefPat {
1534 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 1019 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
1535 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1020 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1536} 1021}
1537/// Box pattern.
1538///
1539/// ```
1540/// let ❰ box foo ❱ = box 42;
1541/// ```
1542///
1543/// [Unstable book](https://doc.rust-lang.org/unstable-book/language-features/box-patterns.html)
1544#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1022#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1545pub struct BoxPat { 1023pub struct BoxPat {
1546 pub(crate) syntax: SyntaxNode, 1024 pub(crate) syntax: SyntaxNode,
1547} 1025}
1548impl BoxPat { 1026impl BoxPat {
1549 pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) } 1027 pub fn box_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![box]) }
1550 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1028 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1551} 1029}
1552/// Bind pattern.
1553///
1554/// ```
1555/// match foo {
1556/// Some(❰ ref mut bar ❱) => {}
1557/// ❰ baz @ None ❱ => {}
1558/// }
1559/// ```
1560///
1561/// [Reference](https://doc.rust-lang.org/reference/patterns.html#identifier-patterns)
1562#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1030#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1563pub struct BindPat { 1031pub struct BindPat {
1564 pub(crate) syntax: SyntaxNode, 1032 pub(crate) syntax: SyntaxNode,
@@ -1571,13 +1039,6 @@ impl BindPat {
1571 pub fn at_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![@]) } 1039 pub fn at_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![@]) }
1572 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1040 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1573} 1041}
1574/// Placeholder pattern a.k.a. the wildcard pattern or the underscore.
1575///
1576/// ```
1577/// let ❰ _ ❱ = foo;
1578/// ```
1579///
1580/// [Reference](https://doc.rust-lang.org/reference/patterns.html#wildcard-pattern)
1581#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1042#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1582pub struct PlaceholderPat { 1043pub struct PlaceholderPat {
1583 pub(crate) syntax: SyntaxNode, 1044 pub(crate) syntax: SyntaxNode,
@@ -1585,16 +1046,6 @@ pub struct PlaceholderPat {
1585impl PlaceholderPat { 1046impl PlaceholderPat {
1586 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) } 1047 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
1587} 1048}
1588/// Rest-of-the record/tuple pattern.
1589/// Note: this is not the unbonded range pattern (even more: it doesn't exist).
1590///
1591/// ```
1592/// let Foo { bar, ❰ .. ❱ } = baz;
1593/// let (❰ .. ❱, bruh) = (42, 24, 42);
1594/// let Bruuh(❰ .. ❱) = bruuuh;
1595/// ```
1596///
1597/// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns)
1598#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1049#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1599pub struct DotDotPat { 1050pub struct DotDotPat {
1600 pub(crate) syntax: SyntaxNode, 1051 pub(crate) syntax: SyntaxNode,
@@ -1602,15 +1053,6 @@ pub struct DotDotPat {
1602impl DotDotPat { 1053impl DotDotPat {
1603 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) } 1054 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
1604} 1055}
1605/// Path pattern.
1606/// Doesn't include the underscore pattern (it is a special case, namely `PlaceholderPat`).
1607///
1608/// ```
1609/// let ❰ foo::bar::Baz ❱ { .. } = bruh;
1610/// if let ❰ CONST ❱ = 42 {}
1611/// ```
1612///
1613/// [Reference](https://doc.rust-lang.org/reference/patterns.html#path-patterns)
1614#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1056#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1615pub struct PathPat { 1057pub struct PathPat {
1616 pub(crate) syntax: SyntaxNode, 1058 pub(crate) syntax: SyntaxNode,
@@ -1618,13 +1060,6 @@ pub struct PathPat {
1618impl PathPat { 1060impl PathPat {
1619 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 1061 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1620} 1062}
1621/// Slice pattern.
1622///
1623/// ```
1624/// let ❰ [foo, bar, baz] ❱ = [1, 2, 3];
1625/// ```
1626///
1627/// [Reference](https://doc.rust-lang.org/reference/patterns.html#slice-patterns)
1628#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1063#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1629pub struct SlicePat { 1064pub struct SlicePat {
1630 pub(crate) syntax: SyntaxNode, 1065 pub(crate) syntax: SyntaxNode,
@@ -1634,33 +1069,14 @@ impl SlicePat {
1634 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } 1069 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1635 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } 1070 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
1636} 1071}
1637/// Range pattern.
1638///
1639/// ```
1640/// match foo {
1641/// ❰ 0..42 ❱ => {}
1642/// ❰ 0..=42 ❱ => {}
1643/// }
1644/// ```
1645///
1646/// [Reference](https://doc.rust-lang.org/reference/patterns.html#range-patterns)
1647#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1072#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1648pub struct RangePat { 1073pub struct RangePat {
1649 pub(crate) syntax: SyntaxNode, 1074 pub(crate) syntax: SyntaxNode,
1650} 1075}
1651impl RangePat {} 1076impl RangePat {
1652/// Literal pattern. 1077 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
1653/// Includes only bool, number, char, and string literals. 1078 pub fn dotdoteq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..=]) }
1654/// 1079}
1655/// ```
1656/// match foo {
1657/// Number(❰ 42 ❱) => {}
1658/// String(❰ "42" ❱) => {}
1659/// Bool(❰ true ❱) => {}
1660/// }
1661/// ```
1662///
1663/// [Reference](https://doc.rust-lang.org/reference/patterns.html#literal-patterns)
1664#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1080#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1665pub struct LiteralPat { 1081pub struct LiteralPat {
1666 pub(crate) syntax: SyntaxNode, 1082 pub(crate) syntax: SyntaxNode,
@@ -1668,13 +1084,6 @@ pub struct LiteralPat {
1668impl LiteralPat { 1084impl LiteralPat {
1669 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) } 1085 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) }
1670} 1086}
1671/// Macro invocation in pattern position.
1672///
1673/// ```
1674/// let ❰ foo!(my custom syntax) ❱ = baz;
1675///
1676/// ```
1677/// [Reference](https://doc.rust-lang.org/reference/macros.html#macro-invocation)
1678#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1087#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1679pub struct MacroPat { 1088pub struct MacroPat {
1680 pub(crate) syntax: SyntaxNode, 1089 pub(crate) syntax: SyntaxNode,
@@ -1682,37 +1091,22 @@ pub struct MacroPat {
1682impl MacroPat { 1091impl MacroPat {
1683 pub fn macro_call(&self) -> Option<MacroCall> { support::child(&self.syntax) } 1092 pub fn macro_call(&self) -> Option<MacroCall> { support::child(&self.syntax) }
1684} 1093}
1685/// Record literal pattern.
1686///
1687/// ```
1688/// let ❰ foo::Bar { baz, .. } ❱ = bruh;
1689/// ```
1690///
1691/// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns)
1692#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1094#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1693pub struct RecordPat { 1095pub struct RecordPat {
1694 pub(crate) syntax: SyntaxNode, 1096 pub(crate) syntax: SyntaxNode,
1695} 1097}
1696impl RecordPat { 1098impl RecordPat {
1099 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1697 pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> { 1100 pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> {
1698 support::child(&self.syntax) 1101 support::child(&self.syntax)
1699 } 1102 }
1700 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1701} 1103}
1702/// Record literal's field patterns list including enclosing curly braces.
1703///
1704/// ```
1705/// let foo::Bar ❰ { baz, bind @ bruh, .. } ❱ = bruuh;
1706/// ``
1707///
1708/// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns)
1709#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1104#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1710pub struct RecordFieldPatList { 1105pub struct RecordFieldPatList {
1711 pub(crate) syntax: SyntaxNode, 1106 pub(crate) syntax: SyntaxNode,
1712} 1107}
1713impl RecordFieldPatList { 1108impl RecordFieldPatList {
1714 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } 1109 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
1715 pub fn pats(&self) -> AstChildren<RecordInnerPat> { support::children(&self.syntax) }
1716 pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> { 1110 pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> {
1717 support::children(&self.syntax) 1111 support::children(&self.syntax)
1718 } 1112 }
@@ -1720,15 +1114,6 @@ impl RecordFieldPatList {
1720 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) } 1114 pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) }
1721 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } 1115 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
1722} 1116}
1723/// Record literal's field pattern.
1724/// Note: record literal can also match tuple structs.
1725///
1726/// ```
1727/// let Foo { ❰ bar: _ ❱ } = baz;
1728/// let TupleStruct { ❰ 0: _ ❱ } = bruh;
1729/// ```
1730///
1731/// [Reference](https://doc.rust-lang.org/reference/patterns.html#struct-patterns)
1732#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1117#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1733pub struct RecordFieldPat { 1118pub struct RecordFieldPat {
1734 pub(crate) syntax: SyntaxNode, 1119 pub(crate) syntax: SyntaxNode,
@@ -1739,13 +1124,6 @@ impl RecordFieldPat {
1739 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } 1124 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
1740 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1125 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1741} 1126}
1742/// Tuple struct literal pattern.
1743///
1744/// ```
1745/// let ❰ foo::Bar(baz, bruh) ❱ = bruuh;
1746/// ```
1747///
1748/// [Reference](https://doc.rust-lang.org/reference/patterns.html#tuple-struct-patterns)
1749#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1127#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1750pub struct TupleStructPat { 1128pub struct TupleStructPat {
1751 pub(crate) syntax: SyntaxNode, 1129 pub(crate) syntax: SyntaxNode,
@@ -1756,14 +1134,6 @@ impl TupleStructPat {
1756 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } 1134 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1757 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 1135 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1758} 1136}
1759/// Tuple pattern.
1760/// Note: this doesn't include tuple structs (see `TupleStructPat`)
1761///
1762/// ```
1763/// let ❰ (foo, bar, .., baz) ❱ = bruh;
1764/// ```
1765///
1766/// [Reference](https://doc.rust-lang.org/reference/patterns.html#tuple-patterns)
1767#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1137#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1768pub struct TuplePat { 1138pub struct TuplePat {
1769 pub(crate) syntax: SyntaxNode, 1139 pub(crate) syntax: SyntaxNode,
@@ -1773,234 +1143,28 @@ impl TuplePat {
1773 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } 1143 pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) }
1774 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 1144 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
1775} 1145}
1776/// Visibility.
1777///
1778/// ```
1779/// ❰ pub mod ❱ foo;
1780/// ❰ pub(crate) ❱ struct Bar;
1781/// ❰ pub(self) ❱ enum Baz {}
1782/// ❰ pub(super) ❱ fn bruh() {}
1783/// ❰ pub(in bruuh::bruuuh) ❱ type T = u64;
1784/// ```
1785///
1786/// [Reference](https://doc.rust-lang.org/reference/visibility-and-privacy.html)
1787#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1788pub struct Visibility {
1789 pub(crate) syntax: SyntaxNode,
1790}
1791impl Visibility {
1792 pub fn pub_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![pub]) }
1793 pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) }
1794 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
1795 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
1796}
1797/// Single identifier.
1798/// Note(@matklad): `Name` is for things that install a new name into the scope,
1799/// `NameRef` is a usage of a name. Most of the time, this definition/reference
1800/// distinction can be determined purely syntactically, ie in
1801/// ```
1802/// fn foo() { foo() }
1803/// ```
1804/// the first foo is `Name`, the second one is `NameRef`.
1805/// The notable exception are patterns, where in
1806/// ``
1807/// let x = 92
1808/// ```
1809/// `x` can be semantically either a name or a name ref, depeding on
1810/// wether there's an `x` constant in scope.
1811/// We use `Name` for patterns, and disambiguate semantically (see `NameClass` in ide_db).
1812///
1813/// ```
1814/// let ❰ foo ❱ = bar;
1815/// struct ❰ Baz ❱;
1816/// fn ❰ bruh ❱() {}
1817/// ```
1818///
1819/// [Reference](https://doc.rust-lang.org/reference/identifiers.html)
1820#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1821pub struct Name {
1822 pub(crate) syntax: SyntaxNode,
1823}
1824impl Name {
1825 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) }
1826}
1827/// Reference to a name.
1828/// See the explanation on the difference between `Name` and `NameRef`
1829/// in `Name` ast node docs.
1830///
1831/// ```
1832/// let foo = ❰ bar ❱(❰ Baz(❰ bruh ❱) ❱;
1833/// ```
1834///
1835/// [Reference](https://doc.rust-lang.org/reference/identifiers.html)
1836#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1837pub struct NameRef {
1838 pub(crate) syntax: SyntaxNode,
1839}
1840impl NameRef {}
1841/// Macro call.
1842/// Includes all of its attributes and doc comments.
1843///
1844/// ```
1845/// ❰
1846/// /// Docs
1847/// #[attr]
1848/// macro_rules! foo { // macro rules is also a macro call
1849/// ($bar: tt) => {}
1850/// }
1851/// ❱
1852///
1853/// // semicolon is a part of `MacroCall` when it is used in item positions
1854/// ❰ foo!(); ❱
1855///
1856/// fn main() {
1857/// ❰ foo!() ❱; // macro call in expression positions doesn't include the semi
1858/// }
1859/// ```
1860///
1861/// [Reference](https://doc.rust-lang.org/reference/macros.html)
1862#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1146#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1863pub struct MacroCall { 1147pub struct MacroDef {
1864 pub(crate) syntax: SyntaxNode, 1148 pub(crate) syntax: SyntaxNode,
1865} 1149}
1866impl ast::NameOwner for MacroCall {} 1150impl ast::NameOwner for MacroDef {}
1867impl ast::AttrsOwner for MacroCall {} 1151impl MacroDef {
1868impl ast::DocCommentsOwner for MacroCall {}
1869impl MacroCall {
1870 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1871 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
1872 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) } 1152 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
1873 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
1874}
1875/// Attribute.
1876///
1877/// ```
1878/// ❰ #![inner_attr] ❱
1879///
1880/// ❰ #[attr] ❱
1881/// ❰ #[foo = "bar"] ❱
1882/// ❰ #[baz(bruh::bruuh = "42")] ❱
1883/// struct Foo;
1884/// ```
1885///
1886/// [Reference](https://doc.rust-lang.org/reference/attributes.html)
1887#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1888pub struct Attr {
1889 pub(crate) syntax: SyntaxNode,
1890} 1153}
1891impl Attr {
1892 pub fn pound_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![#]) }
1893 pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) }
1894 pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) }
1895 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
1896 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1897 pub fn input(&self) -> Option<AttrInput> { support::child(&self.syntax) }
1898 pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) }
1899}
1900/// Stores a list of lexer tokens and other `TokenTree`s.
1901/// It appears in attributes, macro_rules and macro call (foo!)
1902///
1903/// ```
1904/// macro_call! ❰ { my syntax here } ❱;
1905/// ```
1906///
1907/// [Reference](https://doc.rust-lang.org/reference/macros.html)
1908#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1154#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1909pub struct TokenTree { 1155pub struct MacroItems {
1910 pub(crate) syntax: SyntaxNode,
1911}
1912impl TokenTree {}
1913/// Generic lifetime, type and constants parameters list **declaration**.
1914///
1915/// ```
1916/// fn foo❰ <'a, 'b, T, U, const BAR: u64> ❱() {}
1917///
1918/// struct Baz❰ <T> ❱(T);
1919///
1920/// impl❰ <T> ❱ Bruh<T> {}
1921///
1922/// type Bruuh = for❰ <'a> ❱ fn(&'a str) -> &'a str;
1923/// ```
1924///
1925/// [Reference](https://doc.rust-lang.org/reference/items/generics.html)
1926#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1927pub struct TypeParamList {
1928 pub(crate) syntax: SyntaxNode,
1929}
1930impl TypeParamList {
1931 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
1932 pub fn generic_params(&self) -> AstChildren<GenericParam> { support::children(&self.syntax) }
1933 pub fn type_params(&self) -> AstChildren<TypeParam> { support::children(&self.syntax) }
1934 pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> { support::children(&self.syntax) }
1935 pub fn const_params(&self) -> AstChildren<ConstParam> { support::children(&self.syntax) }
1936 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
1937}
1938/// Single type parameter **declaration**.
1939///
1940/// ```
1941/// fn foo<❰ K ❱, ❰ I ❱, ❰ E: Debug ❱, ❰ V = DefaultType ❱>() {}
1942/// ```
1943///
1944/// [Reference](https://doc.rust-lang.org/reference/items/generics.html)
1945#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1946pub struct TypeParam {
1947 pub(crate) syntax: SyntaxNode,
1948}
1949impl ast::NameOwner for TypeParam {}
1950impl ast::AttrsOwner for TypeParam {}
1951impl ast::TypeBoundsOwner for TypeParam {}
1952impl TypeParam {
1953 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1954 pub fn default_type(&self) -> Option<TypeRef> { support::child(&self.syntax) }
1955}
1956/// Const generic parameter **declaration**.
1957/// ```
1958/// fn foo<T, U, ❰ const BAR: usize ❱, ❰ const BAZ: bool ❱>() {}
1959/// ```
1960///
1961/// [RFC](https://github.com/rust-lang/rfcs/blob/master/text/2000-const-generics.md#declaring-a-const-parameter)
1962#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1963pub struct ConstParam {
1964 pub(crate) syntax: SyntaxNode, 1156 pub(crate) syntax: SyntaxNode,
1965} 1157}
1966impl ast::NameOwner for ConstParam {} 1158impl ast::ModuleItemOwner for MacroItems {}
1967impl ast::AttrsOwner for ConstParam {} 1159impl MacroItems {}
1968impl ast::TypeAscriptionOwner for ConstParam {}
1969impl ConstParam {
1970 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
1971 pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) }
1972}
1973/// Lifetime parameter **declaration**.
1974///
1975/// ```
1976/// fn foo<❰ 'a ❱, ❰ 'b ❱, V, G, D>(bar: &'a str, baz: &'b mut str) {}
1977/// ```
1978///
1979/// [Reference](https://doc.rust-lang.org/reference/items/generics.html)
1980#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1160#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1981pub struct LifetimeParam { 1161pub struct MacroStmts {
1982 pub(crate) syntax: SyntaxNode, 1162 pub(crate) syntax: SyntaxNode,
1983} 1163}
1984impl ast::AttrsOwner for LifetimeParam {} 1164impl MacroStmts {
1985impl LifetimeParam { 1165 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) }
1986 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 1166 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
1987 support::token(&self.syntax, T![lifetime])
1988 }
1989} 1167}
1990/// Type bound declaration clause.
1991///
1992/// ```
1993/// fn foo<T: ❰ ?Sized ❱ + ❰ Debug ❱>() {}
1994///
1995/// trait Bar<T>
1996/// where
1997/// T: ❰ Send ❱ + ❰ Sync ❱
1998/// {
1999/// type Baz: ❰ !Sync ❱ + ❰ Debug ❱ + ❰ ?const Add ❱;
2000/// }
2001/// ```
2002///
2003/// [Reference](https://doc.rust-lang.org/reference/trait-bounds.html)
2004#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1168#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2005pub struct TypeBound { 1169pub struct TypeBound {
2006 pub(crate) syntax: SyntaxNode, 1170 pub(crate) syntax: SyntaxNode,
@@ -2012,40 +1176,6 @@ impl TypeBound {
2012 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } 1176 pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) }
2013 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 1177 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2014} 1178}
2015/// Type bounds list.
2016///
2017/// ```
2018///
2019/// fn foo<T: ❰ ?Sized + Debug ❱>() {}
2020///
2021/// trait Bar<T>
2022/// where
2023/// T: ❰ Send + Sync ❱
2024/// {
2025/// type Baz: ❰ !Sync + Debug ❱;
2026/// }
2027/// ```
2028///
2029/// [Reference](https://doc.rust-lang.org/reference/trait-bounds.html)
2030#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2031pub struct TypeBoundList {
2032 pub(crate) syntax: SyntaxNode,
2033}
2034impl TypeBoundList {
2035 pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) }
2036}
2037/// Single where predicate.
2038///
2039/// ```
2040/// trait Foo<'a, 'b, T>
2041/// where
2042/// ❰ 'a: 'b ❱,
2043/// ❰ T: IntoIterator ❱,
2044/// ❰ for<'c> <T as IntoIterator>::Item: Bar<'c> ❱
2045/// {}
2046/// ```
2047///
2048/// [Reference](https://doc.rust-lang.org/reference/items/generics.html#where-clauses)
2049#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1179#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2050pub struct WherePred { 1180pub struct WherePred {
2051 pub(crate) syntax: SyntaxNode, 1181 pub(crate) syntax: SyntaxNode,
@@ -2053,64 +1183,12 @@ pub struct WherePred {
2053impl ast::TypeBoundsOwner for WherePred {} 1183impl ast::TypeBoundsOwner for WherePred {}
2054impl WherePred { 1184impl WherePred {
2055 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } 1185 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
2056 pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) } 1186 pub fn generic_param_list(&self) -> Option<GenericParamList> { support::child(&self.syntax) }
2057 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 1187 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2058 support::token(&self.syntax, T![lifetime]) 1188 support::token(&self.syntax, T![lifetime])
2059 } 1189 }
2060 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 1190 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2061} 1191}
2062/// Where clause.
2063///
2064/// ```
2065/// trait Foo<'a, T> ❰ where 'a: 'static, T: Debug ❱ {}
2066///
2067/// ```
2068///
2069/// [Reference](https://doc.rust-lang.org/reference/items/generics.html#where-clauses)
2070#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2071pub struct WhereClause {
2072 pub(crate) syntax: SyntaxNode,
2073}
2074impl WhereClause {
2075 pub fn where_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![where]) }
2076 pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) }
2077}
2078/// Abi declaration.
2079/// Note: the abi string is optional.
2080///
2081/// ```
2082/// ❰ extern "C" ❱ {
2083/// fn foo() {}
2084/// }
2085///
2086/// type Bar = ❰ extern ❱ fn() -> u32;
2087///
2088/// type Baz = ❰ extern r#"stdcall"# ❱ fn() -> bool;
2089/// ```
2090///
2091/// - [Extern blocks reference](https://doc.rust-lang.org/reference/items/external-blocks.html)
2092/// - [FFI function pointers reference](https://doc.rust-lang.org/reference/items/functions.html#functions)
2093#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2094pub struct Abi {
2095 pub(crate) syntax: SyntaxNode,
2096}
2097impl Abi {}
2098/// Expression statement.
2099///
2100/// ```
2101/// ❰ 42; ❱
2102/// ❰ foo(); ❱
2103/// ❰ (); ❱
2104/// ❰ {}; ❱
2105///
2106/// // constructions with trailing curly brace can omit the semicolon
2107/// // but only when there are satements immediately after them (this is important!)
2108/// ❰ if bool_cond { } ❱
2109/// ❰ loop {} ❱
2110/// ❰ somestatment; ❱
2111/// ```
2112///
2113/// [Reference](https://doc.rust-lang.org/reference/statements.html)
2114#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1192#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2115pub struct ExprStmt { 1193pub struct ExprStmt {
2116 pub(crate) syntax: SyntaxNode, 1194 pub(crate) syntax: SyntaxNode,
@@ -2120,267 +1198,20 @@ impl ExprStmt {
2120 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 1198 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
2121 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 1199 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
2122} 1200}
2123/// Let statement.
2124///
2125/// ```
2126/// ❰ #[attr] let foo; ❱
2127/// ❰ let bar: u64; ❱
2128/// ❰ let baz = 42; ❱
2129/// ❰ let bruh: bool = true; ❱
2130/// ```
2131///
2132/// [Reference](https://doc.rust-lang.org/reference/statements.html#let-statements)
2133#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1201#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2134pub struct LetStmt { 1202pub struct LetStmt {
2135 pub(crate) syntax: SyntaxNode, 1203 pub(crate) syntax: SyntaxNode,
2136} 1204}
2137impl ast::AttrsOwner for LetStmt {} 1205impl ast::AttrsOwner for LetStmt {}
2138impl ast::TypeAscriptionOwner for LetStmt {}
2139impl LetStmt { 1206impl LetStmt {
2140 pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) } 1207 pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) }
2141 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } 1208 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
1209 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
1210 pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2142 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 1211 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2143 pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) } 1212 pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) }
2144 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 1213 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
2145} 1214}
2146/// Condition of `if` or `while` expression.
2147///
2148/// ```
2149/// if ❰ true ❱ {}
2150/// if ❰ let Pat(foo) = bar ❱ {}
2151///
2152/// while ❰ true ❱ {}
2153/// while ❰ let Pat(baz) = bruh ❱ {}
2154/// ```
2155///
2156/// [If expression reference](https://doc.rust-lang.org/reference/expressions/if-expr.html)
2157/// [While expression reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#predicate-loops)
2158#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2159pub struct Condition {
2160 pub(crate) syntax: SyntaxNode,
2161}
2162impl Condition {
2163 pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) }
2164 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2165 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2166 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
2167}
2168/// Parameter list **declaration**.
2169///
2170/// ```
2171/// fn foo❰ (a: u32, b: bool) ❱ -> u32 {}
2172/// let bar = ❰ |a, b| ❱ {};
2173///
2174/// impl Baz {
2175/// fn bruh❰ (&self, a: u32) ❱ {}
2176/// }
2177/// ```
2178///
2179/// [Reference](https://doc.rust-lang.org/reference/items/functions.html)ocs to codegen script
2180#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2181pub struct ParamList {
2182 pub(crate) syntax: SyntaxNode,
2183}
2184impl ParamList {
2185 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
2186 pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) }
2187 pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) }
2188 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
2189}
2190/// Self parameter **declaration**.
2191///
2192/// ```
2193/// impl Bruh {
2194/// fn foo(❰ self ❱) {}
2195/// fn bar(❰ &self ❱) {}
2196/// fn baz(❰ &mut self ❱) {}
2197/// fn blah<'a>(❰ &'a self ❱) {}
2198/// fn blin(❰ self: Box<Self> ❱) {}
2199/// }
2200/// ```
2201///
2202/// [Reference](https://doc.rust-lang.org/reference/items/functions.html)
2203#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2204pub struct SelfParam {
2205 pub(crate) syntax: SyntaxNode,
2206}
2207impl ast::TypeAscriptionOwner for SelfParam {}
2208impl ast::AttrsOwner for SelfParam {}
2209impl SelfParam {
2210 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
2211 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
2212 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2213 support::token(&self.syntax, T![lifetime])
2214 }
2215 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
2216}
2217/// Parameter **declaration**.
2218///
2219/// ```
2220/// fn foo(❰ #[attr] Pat(bar): Pat(u32) ❱, ❰ #[attr] _: bool ❱) {}
2221///
2222/// extern "C" {
2223/// fn bar(❰ baz: u32 ❱, ❰ ... ❱) -> u32;
2224/// }
2225/// ```
2226///
2227/// [Reference](https://doc.rust-lang.org/reference/items/functions.html)
2228#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2229pub struct Param {
2230 pub(crate) syntax: SyntaxNode,
2231}
2232impl ast::TypeAscriptionOwner for Param {}
2233impl ast::AttrsOwner for Param {}
2234impl Param {
2235 pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
2236 pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) }
2237}
2238/// Use declaration.
2239///
2240/// ```
2241/// ❰ #[attr] pub use foo; ❱
2242/// ❰ use bar as baz; ❱
2243/// ❰ use bruh::{self, bruuh}; ❱
2244/// ❰ use { blin::blen, blah::* };
2245/// ```
2246///
2247/// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
2248#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2249pub struct UseItem {
2250 pub(crate) syntax: SyntaxNode,
2251}
2252impl ast::AttrsOwner for UseItem {}
2253impl ast::VisibilityOwner for UseItem {}
2254impl UseItem {
2255 pub fn use_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![use]) }
2256 pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) }
2257}
2258/// Use tree.
2259///
2260/// ```
2261/// pub use ❰ foo::❰ * ❱ ❱;
2262/// use ❰ bar as baz ❱;
2263/// use ❰ bruh::bruuh::{ ❰ self ❱, ❰ blin ❱ } ❱;
2264/// use ❰ { ❰ blin::blen ❱ } ❱
2265/// ```
2266///
2267/// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
2268#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2269pub struct UseTree {
2270 pub(crate) syntax: SyntaxNode,
2271}
2272impl UseTree {
2273 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
2274 pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) }
2275 pub fn use_tree_list(&self) -> Option<UseTreeList> { support::child(&self.syntax) }
2276 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) }
2277}
2278/// Item alias.
2279/// Note: this is not the type alias.
2280///
2281/// ```
2282/// use foo ❰ as bar ❱;
2283/// use baz::{bruh ❰ as _ ❱};
2284/// extern crate bruuh ❰ as blin ❱;
2285/// ```
2286///
2287/// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
2288#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2289pub struct Alias {
2290 pub(crate) syntax: SyntaxNode,
2291}
2292impl ast::NameOwner for Alias {}
2293impl Alias {
2294 pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
2295}
2296/// Sublist of use trees.
2297///
2298/// ```
2299/// use bruh::bruuh::❰ { ❰ self ❱, ❰ blin ❱ } ❱;
2300/// use ❰ { blin::blen::❰ {} ❱ } ❱
2301/// ```
2302///
2303/// [Reference](https://doc.rust-lang.org/reference/items/use-declarations.html)
2304#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2305pub struct UseTreeList {
2306 pub(crate) syntax: SyntaxNode,
2307}
2308impl UseTreeList {
2309 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
2310 pub fn use_trees(&self) -> AstChildren<UseTree> { support::children(&self.syntax) }
2311 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
2312}
2313/// Extern crate item.
2314///
2315/// ```
2316/// ❰ #[attr] pub extern crate foo; ❱
2317/// ❰ extern crate self as bar; ❱
2318/// ```
2319///
2320/// [Reference](https://doc.rust-lang.org/reference/items/extern-crates.html)
2321#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2322pub struct ExternCrateItem {
2323 pub(crate) syntax: SyntaxNode,
2324}
2325impl ast::AttrsOwner for ExternCrateItem {}
2326impl ast::VisibilityOwner for ExternCrateItem {}
2327impl ExternCrateItem {
2328 pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) }
2329 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
2330 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
2331 pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) }
2332}
2333/// Call site arguments list.
2334///
2335/// ```
2336/// foo::<T, U>❰ (42, true) ❱;
2337/// ```
2338///
2339/// [Reference](https://doc.rust-lang.org/reference/expressions/call-expr.html)
2340#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2341pub struct ArgList {
2342 pub(crate) syntax: SyntaxNode,
2343}
2344impl ArgList {
2345 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
2346 pub fn args(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
2347 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
2348}
2349/// Path to a symbol. Includes single identifier names and elaborate paths with
2350/// generic parameters.
2351///
2352/// ```
2353/// (0..10).❰ ❰ collect ❱ ::<Vec<_>> ❱();
2354/// ❰ ❰ ❰ Vec ❱ ::<u8> ❱ ::with_capacity ❱(1024);
2355/// ❰ ❰ <❰ Foo ❱ as ❰ ❰ bar ❱ ::Bar ❱> ❱ ::baz ❱();
2356/// ❰ ❰ <❰ bruh ❱> ❱ ::bruuh ❱();
2357/// ```
2358///
2359/// [Reference](https://doc.rust-lang.org/reference/paths.html)
2360#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2361pub struct Path {
2362 pub(crate) syntax: SyntaxNode,
2363}
2364impl Path {
2365 pub fn segment(&self) -> Option<PathSegment> { support::child(&self.syntax) }
2366 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
2367 pub fn qualifier(&self) -> Option<Path> { support::child(&self.syntax) }
2368}
2369/// Segment of the path to a symbol.
2370/// Only path segment of an absolute path holds the `::` token,
2371/// all other `::` tokens that connect path segments reside under `Path` itself.`
2372///
2373/// ```
2374/// (0..10).❰ collect ❱ :: ❰ <Vec<_>> ❱();
2375/// ❰ Vec ❱ :: ❰ <u8> ❱ :: ❰ with_capacity ❱(1024);
2376/// ❰ <❰ Foo ❱ as ❰ bar ❱ :: ❰ Bar ❱> ❱ :: ❰ baz ❱();
2377/// ❰ <❰ bruh ❱> ❱ :: ❰ bruuh ❱();
2378///
2379/// // Note that only in this case `::` token is inlcuded:
2380/// ❰ ::foo ❱;
2381/// ```
2382///
2383/// [Reference](https://doc.rust-lang.org/reference/paths.html)
2384#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1215#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2385pub struct PathSegment { 1216pub struct PathSegment {
2386 pub(crate) syntax: SyntaxNode, 1217 pub(crate) syntax: SyntaxNode,
@@ -2398,50 +1229,22 @@ impl PathSegment {
2398 pub fn path_type(&self) -> Option<PathType> { support::child(&self.syntax) } 1229 pub fn path_type(&self) -> Option<PathType> { support::child(&self.syntax) }
2399 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) } 1230 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
2400} 1231}
2401/// List of type arguments that are passed at generic instantiation site.
2402///
2403/// ```
2404/// type _ = Foo ❰ ::<'a, u64, Item = Bar, 42, {true}> ❱::Bar;
2405///
2406/// Vec❰ ::<bool> ❱::();
2407/// ```
2408///
2409/// [Reference](https://doc.rust-lang.org/reference/paths.html#paths-in-expressions)
2410#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1232#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2411pub struct TypeArgList { 1233pub struct TypeArg {
2412 pub(crate) syntax: SyntaxNode, 1234 pub(crate) syntax: SyntaxNode,
2413} 1235}
2414impl TypeArgList { 1236impl TypeArg {
2415 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) } 1237 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2416 pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
2417 pub fn generic_args(&self) -> AstChildren<GenericArg> { support::children(&self.syntax) }
2418 pub fn type_args(&self) -> AstChildren<TypeArg> { support::children(&self.syntax) }
2419 pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> { support::children(&self.syntax) }
2420 pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> { support::children(&self.syntax) }
2421 pub fn const_args(&self) -> AstChildren<ConstArg> { support::children(&self.syntax) }
2422 pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
2423} 1238}
2424/// Type argument that is passed at generic instantiation site.
2425///
2426/// ```
2427/// type _ = Foo::<'a, ❰ u64 ❱, ❰ bool ❱, Item = Bar, 42>::Baz;
2428/// ```
2429///
2430/// [Reference](https://doc.rust-lang.org/reference/paths.html#paths-in-expressions)
2431#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1239#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2432pub struct TypeArg { 1240pub struct LifetimeArg {
2433 pub(crate) syntax: SyntaxNode, 1241 pub(crate) syntax: SyntaxNode,
2434} 1242}
2435impl TypeArg { 1243impl LifetimeArg {
2436 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 1244 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
1245 support::token(&self.syntax, T![lifetime])
1246 }
2437} 1247}
2438/// Associated type argument that is passed at generic instantiation site.
2439/// ```
2440/// type Foo = Bar::<'a, u64, bool, ❰ Item = Baz ❱, 42>::Bruh;
2441///
2442/// trait Bruh<T>: Iterator<❰ Item: Debug ❱> {}
2443/// ```
2444///
2445#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1248#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2446pub struct AssocTypeArg { 1249pub struct AssocTypeArg {
2447 pub(crate) syntax: SyntaxNode, 1250 pub(crate) syntax: SyntaxNode,
@@ -2452,33 +1255,6 @@ impl AssocTypeArg {
2452 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } 1255 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2453 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } 1256 pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
2454} 1257}
2455/// Lifetime argument that is passed at generic instantiation site.
2456///
2457/// ```
2458/// fn foo<'a>(s: &'a str) {
2459/// bar::<❰ 'a ❱>(s);
2460/// }
2461/// ```
2462///
2463/// [Reference](https://doc.rust-lang.org/reference/paths.html#paths-in-expressions)
2464#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2465pub struct LifetimeArg {
2466 pub(crate) syntax: SyntaxNode,
2467}
2468impl LifetimeArg {
2469 pub fn lifetime_token(&self) -> Option<SyntaxToken> {
2470 support::token(&self.syntax, T![lifetime])
2471 }
2472}
2473/// Constant value argument that is passed at generic instantiation site.
2474///
2475/// ```
2476/// foo::<u32, ❰ { true } ❱>();
2477///
2478/// bar::<❰ { 2 + 2} ❱>();
2479/// ```
2480///
2481/// [RFC](https://github.com/rust-lang/rfcs/blob/master/text/2000-const-generics.md#declaring-a-const-parameter)
2482#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1258#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2483pub struct ConstArg { 1259pub struct ConstArg {
2484 pub(crate) syntax: SyntaxNode, 1260 pub(crate) syntax: SyntaxNode,
@@ -2487,136 +1263,24 @@ impl ConstArg {
2487 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) } 1263 pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) }
2488 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) } 1264 pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
2489} 1265}
2490/// FIXME: (@edwin0cheng) Remove it to use ItemList instead
2491/// https://github.com/rust-analyzer/rust-analyzer/pull/4083#discussion_r422666243
2492///
2493/// [Reference](https://doc.rust-lang.org/reference/macros.html)
2494#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2495pub struct MacroItems {
2496 pub(crate) syntax: SyntaxNode,
2497}
2498impl ast::ModuleItemOwner for MacroItems {}
2499impl MacroItems {}
2500/// FIXME: (@edwin0cheng) add some documentation here. As per the writing
2501/// of this comment this ast node is not used.
2502///
2503/// ```
2504/// // FIXME: example here
2505/// ```
2506///
2507/// [Reference](https://doc.rust-lang.org/reference/macros.html)
2508#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2509pub struct MacroStmts {
2510 pub(crate) syntax: SyntaxNode,
2511}
2512impl MacroStmts {
2513 pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) }
2514 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
2515}
2516/// List of items in an extern block.
2517///
2518/// ```
2519/// extern "C" ❰
2520/// {
2521/// fn foo();
2522/// static var: u32;
2523/// }
2524/// ❱
2525/// ```
2526///
2527/// [Reference](https://doc.rust-lang.org/reference/items/external-blocks.html)
2528#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2529pub struct ExternItemList {
2530 pub(crate) syntax: SyntaxNode,
2531}
2532impl ast::ModuleItemOwner for ExternItemList {}
2533impl ExternItemList {
2534 pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
2535 pub fn extern_items(&self) -> AstChildren<ExternItem> { support::children(&self.syntax) }
2536 pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
2537}
2538/// Extern block.
2539///
2540/// ```
2541/// ❰
2542/// extern "C" {
2543/// fn foo();
2544/// }
2545/// ❱
2546///
2547/// ```
2548///
2549/// [Reference](https://doc.rust-lang.org/reference/items/external-blocks.html)
2550#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2551pub struct ExternBlock {
2552 pub(crate) syntax: SyntaxNode,
2553}
2554impl ExternBlock {
2555 pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
2556 pub fn extern_item_list(&self) -> Option<ExternItemList> { support::child(&self.syntax) }
2557}
2558/// Meta item in an attribute.
2559///
2560/// ```
2561/// #[❰ bar::baz = "42" ❱]
2562/// #[❰ bruh(bruuh("true")) ❱]
2563/// struct Foo;
2564/// ```
2565///
2566/// [Reference](https://doc.rust-lang.org/reference/attributes.html?highlight=meta,item#meta-item-attribute-syntax)
2567#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2568pub struct MetaItem {
2569 pub(crate) syntax: SyntaxNode,
2570}
2571impl MetaItem {
2572 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
2573 pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
2574 pub fn attr_input(&self) -> Option<AttrInput> { support::child(&self.syntax) }
2575 pub fn nested_meta_items(&self) -> AstChildren<MetaItem> { support::children(&self.syntax) }
2576}
2577/// Macro 2.0 definition.
2578/// Their syntax is still WIP by rustc team...
2579/// ```
2580/// ❰
2581/// macro foo { }
2582/// ❱
2583/// ```
2584///
2585/// [RFC](https://github.com/rust-lang/rfcs/blob/master/text/1584-macros.md)
2586#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2587pub struct MacroDef {
2588 pub(crate) syntax: SyntaxNode,
2589}
2590impl MacroDef {
2591 pub fn name(&self) -> Option<Name> { support::child(&self.syntax) }
2592 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
2593}
2594/// Any kind of nominal type definition.
2595#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1266#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2596pub enum NominalDef { 1267pub enum Item {
2597 StructDef(StructDef), 1268 Const(Const),
2598 EnumDef(EnumDef), 1269 Enum(Enum),
2599 UnionDef(UnionDef), 1270 ExternBlock(ExternBlock),
2600} 1271 ExternCrate(ExternCrate),
2601impl ast::NameOwner for NominalDef {} 1272 Fn(Fn),
2602impl ast::TypeParamsOwner for NominalDef {} 1273 Impl(Impl),
2603impl ast::AttrsOwner for NominalDef {} 1274 MacroCall(MacroCall),
2604/// Any kind of **declared** generic parameter 1275 Module(Module),
2605#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1276 Static(Static),
2606pub enum GenericParam { 1277 Struct(Struct),
2607 LifetimeParam(LifetimeParam), 1278 Trait(Trait),
2608 TypeParam(TypeParam), 1279 TypeAlias(TypeAlias),
2609 ConstParam(ConstParam), 1280 Union(Union),
2610} 1281 Use(Use),
2611/// Any kind of generic argument passed at instantiation site
2612#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2613pub enum GenericArg {
2614 LifetimeArg(LifetimeArg),
2615 TypeArg(TypeArg),
2616 ConstArg(ConstArg),
2617 AssocTypeArg(AssocTypeArg),
2618} 1282}
2619/// Any kind of construct valid in type context 1283impl ast::AttrsOwner for Item {}
2620#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1284#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2621pub enum TypeRef { 1285pub enum TypeRef {
2622 ParenType(ParenType), 1286 ParenType(ParenType),
@@ -2633,50 +1297,29 @@ pub enum TypeRef {
2633 ImplTraitType(ImplTraitType), 1297 ImplTraitType(ImplTraitType),
2634 DynTraitType(DynTraitType), 1298 DynTraitType(DynTraitType),
2635} 1299}
2636/// Any kind of top-level item that may appear in a module
2637#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2638pub enum ModuleItem {
2639 StructDef(StructDef),
2640 UnionDef(UnionDef),
2641 EnumDef(EnumDef),
2642 FnDef(FnDef),
2643 TraitDef(TraitDef),
2644 TypeAliasDef(TypeAliasDef),
2645 ImplDef(ImplDef),
2646 UseItem(UseItem),
2647 ExternCrateItem(ExternCrateItem),
2648 ConstDef(ConstDef),
2649 StaticDef(StaticDef),
2650 Module(Module),
2651 MacroCall(MacroCall),
2652 ExternBlock(ExternBlock),
2653}
2654impl ast::NameOwner for ModuleItem {}
2655impl ast::AttrsOwner for ModuleItem {}
2656impl ast::VisibilityOwner for ModuleItem {}
2657/// Any kind of item that may appear in an impl block
2658///
2659/// // FIXME: impl blocks can also contain MacroCall
2660#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1300#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2661pub enum AssocItem { 1301pub enum Pat {
2662 FnDef(FnDef), 1302 OrPat(OrPat),
2663 TypeAliasDef(TypeAliasDef), 1303 ParenPat(ParenPat),
2664 ConstDef(ConstDef), 1304 RefPat(RefPat),
1305 BoxPat(BoxPat),
1306 BindPat(BindPat),
1307 PlaceholderPat(PlaceholderPat),
1308 DotDotPat(DotDotPat),
1309 PathPat(PathPat),
1310 RecordPat(RecordPat),
1311 TupleStructPat(TupleStructPat),
1312 TuplePat(TuplePat),
1313 SlicePat(SlicePat),
1314 RangePat(RangePat),
1315 LiteralPat(LiteralPat),
1316 MacroPat(MacroPat),
2665} 1317}
2666impl ast::NameOwner for AssocItem {}
2667impl ast::AttrsOwner for AssocItem {}
2668/// Any kind of item that may appear in an extern block
2669///
2670/// // FIXME: extern blocks can also contain MacroCall
2671#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1318#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2672pub enum ExternItem { 1319pub enum FieldList {
2673 FnDef(FnDef), 1320 RecordFieldList(RecordFieldList),
2674 StaticDef(StaticDef), 1321 TupleFieldList(TupleFieldList),
2675} 1322}
2676impl ast::NameOwner for ExternItem {}
2677impl ast::AttrsOwner for ExternItem {}
2678impl ast::VisibilityOwner for ExternItem {}
2679/// Any kind of expression
2680#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1323#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2681pub enum Expr { 1324pub enum Expr {
2682 TupleExpr(TupleExpr), 1325 TupleExpr(TupleExpr),
@@ -2694,7 +1337,7 @@ pub enum Expr {
2694 BlockExpr(BlockExpr), 1337 BlockExpr(BlockExpr),
2695 ReturnExpr(ReturnExpr), 1338 ReturnExpr(ReturnExpr),
2696 MatchExpr(MatchExpr), 1339 MatchExpr(MatchExpr),
2697 RecordLit(RecordLit), 1340 RecordExpr(RecordExpr),
2698 CallExpr(CallExpr), 1341 CallExpr(CallExpr),
2699 IndexExpr(IndexExpr), 1342 IndexExpr(IndexExpr),
2700 MethodCallExpr(MethodCallExpr), 1343 MethodCallExpr(MethodCallExpr),
@@ -2711,53 +1354,46 @@ pub enum Expr {
2711 MacroCall(MacroCall), 1354 MacroCall(MacroCall),
2712 BoxExpr(BoxExpr), 1355 BoxExpr(BoxExpr),
2713} 1356}
2714impl ast::AttrsOwner for Expr {}
2715/// Any kind of pattern
2716#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1357#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2717pub enum Pat { 1358pub enum AssocItem {
2718 OrPat(OrPat), 1359 Fn(Fn),
2719 ParenPat(ParenPat), 1360 TypeAlias(TypeAlias),
2720 RefPat(RefPat), 1361 Const(Const),
2721 BoxPat(BoxPat), 1362 MacroCall(MacroCall),
2722 BindPat(BindPat),
2723 PlaceholderPat(PlaceholderPat),
2724 DotDotPat(DotDotPat),
2725 PathPat(PathPat),
2726 RecordPat(RecordPat),
2727 TupleStructPat(TupleStructPat),
2728 TuplePat(TuplePat),
2729 SlicePat(SlicePat),
2730 RangePat(RangePat),
2731 LiteralPat(LiteralPat),
2732 MacroPat(MacroPat),
2733} 1363}
2734/// Any kind of pattern that appears directly inside of the curly 1364impl ast::AttrsOwner for AssocItem {}
2735/// braces of a record pattern 1365impl ast::NameOwner for AssocItem {}
2736#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1366#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2737pub enum RecordInnerPat { 1367pub enum ExternItem {
2738 RecordFieldPat(RecordFieldPat), 1368 Fn(Fn),
2739 BindPat(BindPat), 1369 Static(Static),
1370 MacroCall(MacroCall),
2740} 1371}
2741/// Any kind of input to an attribute 1372impl ast::AttrsOwner for ExternItem {}
1373impl ast::NameOwner for ExternItem {}
2742#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1374#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2743pub enum AttrInput { 1375pub enum GenericParam {
2744 Literal(Literal), 1376 LifetimeParam(LifetimeParam),
2745 TokenTree(TokenTree), 1377 TypeParam(TypeParam),
1378 ConstParam(ConstParam),
2746} 1379}
2747/// Any kind of statement 1380impl ast::AttrsOwner for GenericParam {}
2748/// Note: there are no empty statements, these are just represented as
2749/// bare semicolons without a dedicated statement ast node.
2750#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1381#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2751pub enum Stmt { 1382pub enum Stmt {
2752 LetStmt(LetStmt), 1383 LetStmt(LetStmt),
2753 ExprStmt(ExprStmt), 1384 ExprStmt(ExprStmt),
2754} 1385}
2755/// Any kind of fields list (record or tuple field lists) 1386impl ast::AttrsOwner for Stmt {}
2756#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1387#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2757pub enum FieldDefList { 1388pub enum AdtDef {
2758 RecordFieldDefList(RecordFieldDefList), 1389 Struct(Struct),
2759 TupleFieldDefList(TupleFieldDefList), 1390 Enum(Enum),
1391 Union(Union),
2760} 1392}
1393impl ast::AttrsOwner for AdtDef {}
1394impl ast::GenericParamsOwner for AdtDef {}
1395impl ast::NameOwner for AdtDef {}
1396impl ast::VisibilityOwner for AdtDef {}
2761impl AstNode for SourceFile { 1397impl AstNode for SourceFile {
2762 fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE } 1398 fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE }
2763 fn cast(syntax: SyntaxNode) -> Option<Self> { 1399 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2769,8 +1405,8 @@ impl AstNode for SourceFile {
2769 } 1405 }
2770 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1406 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2771} 1407}
2772impl AstNode for FnDef { 1408impl AstNode for Attr {
2773 fn can_cast(kind: SyntaxKind) -> bool { kind == FN_DEF } 1409 fn can_cast(kind: SyntaxKind) -> bool { kind == ATTR }
2774 fn cast(syntax: SyntaxNode) -> Option<Self> { 1410 fn cast(syntax: SyntaxNode) -> Option<Self> {
2775 if Self::can_cast(syntax.kind()) { 1411 if Self::can_cast(syntax.kind()) {
2776 Some(Self { syntax }) 1412 Some(Self { syntax })
@@ -2780,8 +1416,8 @@ impl AstNode for FnDef {
2780 } 1416 }
2781 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1417 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2782} 1418}
2783impl AstNode for RetType { 1419impl AstNode for Const {
2784 fn can_cast(kind: SyntaxKind) -> bool { kind == RET_TYPE } 1420 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST }
2785 fn cast(syntax: SyntaxNode) -> Option<Self> { 1421 fn cast(syntax: SyntaxNode) -> Option<Self> {
2786 if Self::can_cast(syntax.kind()) { 1422 if Self::can_cast(syntax.kind()) {
2787 Some(Self { syntax }) 1423 Some(Self { syntax })
@@ -2791,8 +1427,8 @@ impl AstNode for RetType {
2791 } 1427 }
2792 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1428 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2793} 1429}
2794impl AstNode for StructDef { 1430impl AstNode for Enum {
2795 fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT_DEF } 1431 fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM }
2796 fn cast(syntax: SyntaxNode) -> Option<Self> { 1432 fn cast(syntax: SyntaxNode) -> Option<Self> {
2797 if Self::can_cast(syntax.kind()) { 1433 if Self::can_cast(syntax.kind()) {
2798 Some(Self { syntax }) 1434 Some(Self { syntax })
@@ -2802,8 +1438,8 @@ impl AstNode for StructDef {
2802 } 1438 }
2803 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1439 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2804} 1440}
2805impl AstNode for UnionDef { 1441impl AstNode for ExternBlock {
2806 fn can_cast(kind: SyntaxKind) -> bool { kind == UNION_DEF } 1442 fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_BLOCK }
2807 fn cast(syntax: SyntaxNode) -> Option<Self> { 1443 fn cast(syntax: SyntaxNode) -> Option<Self> {
2808 if Self::can_cast(syntax.kind()) { 1444 if Self::can_cast(syntax.kind()) {
2809 Some(Self { syntax }) 1445 Some(Self { syntax })
@@ -2813,8 +1449,8 @@ impl AstNode for UnionDef {
2813 } 1449 }
2814 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1450 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2815} 1451}
2816impl AstNode for RecordFieldDefList { 1452impl AstNode for ExternCrate {
2817 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF_LIST } 1453 fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_CRATE }
2818 fn cast(syntax: SyntaxNode) -> Option<Self> { 1454 fn cast(syntax: SyntaxNode) -> Option<Self> {
2819 if Self::can_cast(syntax.kind()) { 1455 if Self::can_cast(syntax.kind()) {
2820 Some(Self { syntax }) 1456 Some(Self { syntax })
@@ -2824,8 +1460,8 @@ impl AstNode for RecordFieldDefList {
2824 } 1460 }
2825 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1461 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2826} 1462}
2827impl AstNode for RecordFieldDef { 1463impl AstNode for Fn {
2828 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF } 1464 fn can_cast(kind: SyntaxKind) -> bool { kind == FN }
2829 fn cast(syntax: SyntaxNode) -> Option<Self> { 1465 fn cast(syntax: SyntaxNode) -> Option<Self> {
2830 if Self::can_cast(syntax.kind()) { 1466 if Self::can_cast(syntax.kind()) {
2831 Some(Self { syntax }) 1467 Some(Self { syntax })
@@ -2835,8 +1471,8 @@ impl AstNode for RecordFieldDef {
2835 } 1471 }
2836 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1472 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2837} 1473}
2838impl AstNode for TupleFieldDefList { 1474impl AstNode for Impl {
2839 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF_LIST } 1475 fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL }
2840 fn cast(syntax: SyntaxNode) -> Option<Self> { 1476 fn cast(syntax: SyntaxNode) -> Option<Self> {
2841 if Self::can_cast(syntax.kind()) { 1477 if Self::can_cast(syntax.kind()) {
2842 Some(Self { syntax }) 1478 Some(Self { syntax })
@@ -2846,8 +1482,8 @@ impl AstNode for TupleFieldDefList {
2846 } 1482 }
2847 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1483 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2848} 1484}
2849impl AstNode for TupleFieldDef { 1485impl AstNode for MacroCall {
2850 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF } 1486 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_CALL }
2851 fn cast(syntax: SyntaxNode) -> Option<Self> { 1487 fn cast(syntax: SyntaxNode) -> Option<Self> {
2852 if Self::can_cast(syntax.kind()) { 1488 if Self::can_cast(syntax.kind()) {
2853 Some(Self { syntax }) 1489 Some(Self { syntax })
@@ -2857,8 +1493,8 @@ impl AstNode for TupleFieldDef {
2857 } 1493 }
2858 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1494 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2859} 1495}
2860impl AstNode for EnumDef { 1496impl AstNode for Module {
2861 fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_DEF } 1497 fn can_cast(kind: SyntaxKind) -> bool { kind == MODULE }
2862 fn cast(syntax: SyntaxNode) -> Option<Self> { 1498 fn cast(syntax: SyntaxNode) -> Option<Self> {
2863 if Self::can_cast(syntax.kind()) { 1499 if Self::can_cast(syntax.kind()) {
2864 Some(Self { syntax }) 1500 Some(Self { syntax })
@@ -2868,8 +1504,8 @@ impl AstNode for EnumDef {
2868 } 1504 }
2869 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1505 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2870} 1506}
2871impl AstNode for EnumVariantList { 1507impl AstNode for Static {
2872 fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT_LIST } 1508 fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC }
2873 fn cast(syntax: SyntaxNode) -> Option<Self> { 1509 fn cast(syntax: SyntaxNode) -> Option<Self> {
2874 if Self::can_cast(syntax.kind()) { 1510 if Self::can_cast(syntax.kind()) {
2875 Some(Self { syntax }) 1511 Some(Self { syntax })
@@ -2879,8 +1515,8 @@ impl AstNode for EnumVariantList {
2879 } 1515 }
2880 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1516 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2881} 1517}
2882impl AstNode for EnumVariant { 1518impl AstNode for Struct {
2883 fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT } 1519 fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT }
2884 fn cast(syntax: SyntaxNode) -> Option<Self> { 1520 fn cast(syntax: SyntaxNode) -> Option<Self> {
2885 if Self::can_cast(syntax.kind()) { 1521 if Self::can_cast(syntax.kind()) {
2886 Some(Self { syntax }) 1522 Some(Self { syntax })
@@ -2890,8 +1526,8 @@ impl AstNode for EnumVariant {
2890 } 1526 }
2891 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1527 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2892} 1528}
2893impl AstNode for TraitDef { 1529impl AstNode for Trait {
2894 fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT_DEF } 1530 fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT }
2895 fn cast(syntax: SyntaxNode) -> Option<Self> { 1531 fn cast(syntax: SyntaxNode) -> Option<Self> {
2896 if Self::can_cast(syntax.kind()) { 1532 if Self::can_cast(syntax.kind()) {
2897 Some(Self { syntax }) 1533 Some(Self { syntax })
@@ -2901,8 +1537,8 @@ impl AstNode for TraitDef {
2901 } 1537 }
2902 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1538 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2903} 1539}
2904impl AstNode for Module { 1540impl AstNode for TypeAlias {
2905 fn can_cast(kind: SyntaxKind) -> bool { kind == MODULE } 1541 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS }
2906 fn cast(syntax: SyntaxNode) -> Option<Self> { 1542 fn cast(syntax: SyntaxNode) -> Option<Self> {
2907 if Self::can_cast(syntax.kind()) { 1543 if Self::can_cast(syntax.kind()) {
2908 Some(Self { syntax }) 1544 Some(Self { syntax })
@@ -2912,8 +1548,8 @@ impl AstNode for Module {
2912 } 1548 }
2913 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1549 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2914} 1550}
2915impl AstNode for ItemList { 1551impl AstNode for Union {
2916 fn can_cast(kind: SyntaxKind) -> bool { kind == ITEM_LIST } 1552 fn can_cast(kind: SyntaxKind) -> bool { kind == UNION }
2917 fn cast(syntax: SyntaxNode) -> Option<Self> { 1553 fn cast(syntax: SyntaxNode) -> Option<Self> {
2918 if Self::can_cast(syntax.kind()) { 1554 if Self::can_cast(syntax.kind()) {
2919 Some(Self { syntax }) 1555 Some(Self { syntax })
@@ -2923,8 +1559,8 @@ impl AstNode for ItemList {
2923 } 1559 }
2924 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1560 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2925} 1561}
2926impl AstNode for ConstDef { 1562impl AstNode for Use {
2927 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_DEF } 1563 fn can_cast(kind: SyntaxKind) -> bool { kind == USE }
2928 fn cast(syntax: SyntaxNode) -> Option<Self> { 1564 fn cast(syntax: SyntaxNode) -> Option<Self> {
2929 if Self::can_cast(syntax.kind()) { 1565 if Self::can_cast(syntax.kind()) {
2930 Some(Self { syntax }) 1566 Some(Self { syntax })
@@ -2934,8 +1570,8 @@ impl AstNode for ConstDef {
2934 } 1570 }
2935 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1571 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2936} 1572}
2937impl AstNode for StaticDef { 1573impl AstNode for Visibility {
2938 fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC_DEF } 1574 fn can_cast(kind: SyntaxKind) -> bool { kind == VISIBILITY }
2939 fn cast(syntax: SyntaxNode) -> Option<Self> { 1575 fn cast(syntax: SyntaxNode) -> Option<Self> {
2940 if Self::can_cast(syntax.kind()) { 1576 if Self::can_cast(syntax.kind()) {
2941 Some(Self { syntax }) 1577 Some(Self { syntax })
@@ -2945,8 +1581,8 @@ impl AstNode for StaticDef {
2945 } 1581 }
2946 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1582 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2947} 1583}
2948impl AstNode for TypeAliasDef { 1584impl AstNode for Name {
2949 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS_DEF } 1585 fn can_cast(kind: SyntaxKind) -> bool { kind == NAME }
2950 fn cast(syntax: SyntaxNode) -> Option<Self> { 1586 fn cast(syntax: SyntaxNode) -> Option<Self> {
2951 if Self::can_cast(syntax.kind()) { 1587 if Self::can_cast(syntax.kind()) {
2952 Some(Self { syntax }) 1588 Some(Self { syntax })
@@ -2956,8 +1592,8 @@ impl AstNode for TypeAliasDef {
2956 } 1592 }
2957 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1593 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2958} 1594}
2959impl AstNode for ImplDef { 1595impl AstNode for ItemList {
2960 fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_DEF } 1596 fn can_cast(kind: SyntaxKind) -> bool { kind == ITEM_LIST }
2961 fn cast(syntax: SyntaxNode) -> Option<Self> { 1597 fn cast(syntax: SyntaxNode) -> Option<Self> {
2962 if Self::can_cast(syntax.kind()) { 1598 if Self::can_cast(syntax.kind()) {
2963 Some(Self { syntax }) 1599 Some(Self { syntax })
@@ -2967,8 +1603,8 @@ impl AstNode for ImplDef {
2967 } 1603 }
2968 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1604 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2969} 1605}
2970impl AstNode for ParenType { 1606impl AstNode for NameRef {
2971 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_TYPE } 1607 fn can_cast(kind: SyntaxKind) -> bool { kind == NAME_REF }
2972 fn cast(syntax: SyntaxNode) -> Option<Self> { 1608 fn cast(syntax: SyntaxNode) -> Option<Self> {
2973 if Self::can_cast(syntax.kind()) { 1609 if Self::can_cast(syntax.kind()) {
2974 Some(Self { syntax }) 1610 Some(Self { syntax })
@@ -2978,8 +1614,8 @@ impl AstNode for ParenType {
2978 } 1614 }
2979 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1615 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2980} 1616}
2981impl AstNode for TupleType { 1617impl AstNode for Rename {
2982 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_TYPE } 1618 fn can_cast(kind: SyntaxKind) -> bool { kind == RENAME }
2983 fn cast(syntax: SyntaxNode) -> Option<Self> { 1619 fn cast(syntax: SyntaxNode) -> Option<Self> {
2984 if Self::can_cast(syntax.kind()) { 1620 if Self::can_cast(syntax.kind()) {
2985 Some(Self { syntax }) 1621 Some(Self { syntax })
@@ -2989,8 +1625,8 @@ impl AstNode for TupleType {
2989 } 1625 }
2990 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1626 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2991} 1627}
2992impl AstNode for NeverType { 1628impl AstNode for UseTree {
2993 fn can_cast(kind: SyntaxKind) -> bool { kind == NEVER_TYPE } 1629 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE }
2994 fn cast(syntax: SyntaxNode) -> Option<Self> { 1630 fn cast(syntax: SyntaxNode) -> Option<Self> {
2995 if Self::can_cast(syntax.kind()) { 1631 if Self::can_cast(syntax.kind()) {
2996 Some(Self { syntax }) 1632 Some(Self { syntax })
@@ -3000,8 +1636,8 @@ impl AstNode for NeverType {
3000 } 1636 }
3001 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1637 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3002} 1638}
3003impl AstNode for PathType { 1639impl AstNode for Path {
3004 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_TYPE } 1640 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH }
3005 fn cast(syntax: SyntaxNode) -> Option<Self> { 1641 fn cast(syntax: SyntaxNode) -> Option<Self> {
3006 if Self::can_cast(syntax.kind()) { 1642 if Self::can_cast(syntax.kind()) {
3007 Some(Self { syntax }) 1643 Some(Self { syntax })
@@ -3011,8 +1647,8 @@ impl AstNode for PathType {
3011 } 1647 }
3012 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1648 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3013} 1649}
3014impl AstNode for PointerType { 1650impl AstNode for UseTreeList {
3015 fn can_cast(kind: SyntaxKind) -> bool { kind == POINTER_TYPE } 1651 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE_LIST }
3016 fn cast(syntax: SyntaxNode) -> Option<Self> { 1652 fn cast(syntax: SyntaxNode) -> Option<Self> {
3017 if Self::can_cast(syntax.kind()) { 1653 if Self::can_cast(syntax.kind()) {
3018 Some(Self { syntax }) 1654 Some(Self { syntax })
@@ -3022,8 +1658,8 @@ impl AstNode for PointerType {
3022 } 1658 }
3023 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1659 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3024} 1660}
3025impl AstNode for ArrayType { 1661impl AstNode for Abi {
3026 fn can_cast(kind: SyntaxKind) -> bool { kind == ARRAY_TYPE } 1662 fn can_cast(kind: SyntaxKind) -> bool { kind == ABI }
3027 fn cast(syntax: SyntaxNode) -> Option<Self> { 1663 fn cast(syntax: SyntaxNode) -> Option<Self> {
3028 if Self::can_cast(syntax.kind()) { 1664 if Self::can_cast(syntax.kind()) {
3029 Some(Self { syntax }) 1665 Some(Self { syntax })
@@ -3033,8 +1669,8 @@ impl AstNode for ArrayType {
3033 } 1669 }
3034 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1670 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3035} 1671}
3036impl AstNode for SliceType { 1672impl AstNode for GenericParamList {
3037 fn can_cast(kind: SyntaxKind) -> bool { kind == SLICE_TYPE } 1673 fn can_cast(kind: SyntaxKind) -> bool { kind == GENERIC_PARAM_LIST }
3038 fn cast(syntax: SyntaxNode) -> Option<Self> { 1674 fn cast(syntax: SyntaxNode) -> Option<Self> {
3039 if Self::can_cast(syntax.kind()) { 1675 if Self::can_cast(syntax.kind()) {
3040 Some(Self { syntax }) 1676 Some(Self { syntax })
@@ -3044,8 +1680,8 @@ impl AstNode for SliceType {
3044 } 1680 }
3045 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1681 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3046} 1682}
3047impl AstNode for ReferenceType { 1683impl AstNode for ParamList {
3048 fn can_cast(kind: SyntaxKind) -> bool { kind == REFERENCE_TYPE } 1684 fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM_LIST }
3049 fn cast(syntax: SyntaxNode) -> Option<Self> { 1685 fn cast(syntax: SyntaxNode) -> Option<Self> {
3050 if Self::can_cast(syntax.kind()) { 1686 if Self::can_cast(syntax.kind()) {
3051 Some(Self { syntax }) 1687 Some(Self { syntax })
@@ -3055,8 +1691,8 @@ impl AstNode for ReferenceType {
3055 } 1691 }
3056 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1692 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3057} 1693}
3058impl AstNode for PlaceholderType { 1694impl AstNode for RetType {
3059 fn can_cast(kind: SyntaxKind) -> bool { kind == PLACEHOLDER_TYPE } 1695 fn can_cast(kind: SyntaxKind) -> bool { kind == RET_TYPE }
3060 fn cast(syntax: SyntaxNode) -> Option<Self> { 1696 fn cast(syntax: SyntaxNode) -> Option<Self> {
3061 if Self::can_cast(syntax.kind()) { 1697 if Self::can_cast(syntax.kind()) {
3062 Some(Self { syntax }) 1698 Some(Self { syntax })
@@ -3066,8 +1702,8 @@ impl AstNode for PlaceholderType {
3066 } 1702 }
3067 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1703 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3068} 1704}
3069impl AstNode for FnPointerType { 1705impl AstNode for WhereClause {
3070 fn can_cast(kind: SyntaxKind) -> bool { kind == FN_POINTER_TYPE } 1706 fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_CLAUSE }
3071 fn cast(syntax: SyntaxNode) -> Option<Self> { 1707 fn cast(syntax: SyntaxNode) -> Option<Self> {
3072 if Self::can_cast(syntax.kind()) { 1708 if Self::can_cast(syntax.kind()) {
3073 Some(Self { syntax }) 1709 Some(Self { syntax })
@@ -3077,8 +1713,8 @@ impl AstNode for FnPointerType {
3077 } 1713 }
3078 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1714 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3079} 1715}
3080impl AstNode for ForType { 1716impl AstNode for BlockExpr {
3081 fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_TYPE } 1717 fn can_cast(kind: SyntaxKind) -> bool { kind == BLOCK_EXPR }
3082 fn cast(syntax: SyntaxNode) -> Option<Self> { 1718 fn cast(syntax: SyntaxNode) -> Option<Self> {
3083 if Self::can_cast(syntax.kind()) { 1719 if Self::can_cast(syntax.kind()) {
3084 Some(Self { syntax }) 1720 Some(Self { syntax })
@@ -3088,8 +1724,8 @@ impl AstNode for ForType {
3088 } 1724 }
3089 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1725 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3090} 1726}
3091impl AstNode for ImplTraitType { 1727impl AstNode for SelfParam {
3092 fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_TRAIT_TYPE } 1728 fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM }
3093 fn cast(syntax: SyntaxNode) -> Option<Self> { 1729 fn cast(syntax: SyntaxNode) -> Option<Self> {
3094 if Self::can_cast(syntax.kind()) { 1730 if Self::can_cast(syntax.kind()) {
3095 Some(Self { syntax }) 1731 Some(Self { syntax })
@@ -3099,8 +1735,8 @@ impl AstNode for ImplTraitType {
3099 } 1735 }
3100 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1736 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3101} 1737}
3102impl AstNode for DynTraitType { 1738impl AstNode for Param {
3103 fn can_cast(kind: SyntaxKind) -> bool { kind == DYN_TRAIT_TYPE } 1739 fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM }
3104 fn cast(syntax: SyntaxNode) -> Option<Self> { 1740 fn cast(syntax: SyntaxNode) -> Option<Self> {
3105 if Self::can_cast(syntax.kind()) { 1741 if Self::can_cast(syntax.kind()) {
3106 Some(Self { syntax }) 1742 Some(Self { syntax })
@@ -3110,8 +1746,8 @@ impl AstNode for DynTraitType {
3110 } 1746 }
3111 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1747 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3112} 1748}
3113impl AstNode for TupleExpr { 1749impl AstNode for TypeBoundList {
3114 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_EXPR } 1750 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST }
3115 fn cast(syntax: SyntaxNode) -> Option<Self> { 1751 fn cast(syntax: SyntaxNode) -> Option<Self> {
3116 if Self::can_cast(syntax.kind()) { 1752 if Self::can_cast(syntax.kind()) {
3117 Some(Self { syntax }) 1753 Some(Self { syntax })
@@ -3121,8 +1757,8 @@ impl AstNode for TupleExpr {
3121 } 1757 }
3122 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1758 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3123} 1759}
3124impl AstNode for ArrayExpr { 1760impl AstNode for RecordFieldList {
3125 fn can_cast(kind: SyntaxKind) -> bool { kind == ARRAY_EXPR } 1761 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_LIST }
3126 fn cast(syntax: SyntaxNode) -> Option<Self> { 1762 fn cast(syntax: SyntaxNode) -> Option<Self> {
3127 if Self::can_cast(syntax.kind()) { 1763 if Self::can_cast(syntax.kind()) {
3128 Some(Self { syntax }) 1764 Some(Self { syntax })
@@ -3132,8 +1768,8 @@ impl AstNode for ArrayExpr {
3132 } 1768 }
3133 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1769 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3134} 1770}
3135impl AstNode for ParenExpr { 1771impl AstNode for TupleFieldList {
3136 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_EXPR } 1772 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_LIST }
3137 fn cast(syntax: SyntaxNode) -> Option<Self> { 1773 fn cast(syntax: SyntaxNode) -> Option<Self> {
3138 if Self::can_cast(syntax.kind()) { 1774 if Self::can_cast(syntax.kind()) {
3139 Some(Self { syntax }) 1775 Some(Self { syntax })
@@ -3143,8 +1779,8 @@ impl AstNode for ParenExpr {
3143 } 1779 }
3144 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1780 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3145} 1781}
3146impl AstNode for PathExpr { 1782impl AstNode for RecordField {
3147 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_EXPR } 1783 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD }
3148 fn cast(syntax: SyntaxNode) -> Option<Self> { 1784 fn cast(syntax: SyntaxNode) -> Option<Self> {
3149 if Self::can_cast(syntax.kind()) { 1785 if Self::can_cast(syntax.kind()) {
3150 Some(Self { syntax }) 1786 Some(Self { syntax })
@@ -3154,8 +1790,8 @@ impl AstNode for PathExpr {
3154 } 1790 }
3155 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1791 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3156} 1792}
3157impl AstNode for LambdaExpr { 1793impl AstNode for TupleField {
3158 fn can_cast(kind: SyntaxKind) -> bool { kind == LAMBDA_EXPR } 1794 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD }
3159 fn cast(syntax: SyntaxNode) -> Option<Self> { 1795 fn cast(syntax: SyntaxNode) -> Option<Self> {
3160 if Self::can_cast(syntax.kind()) { 1796 if Self::can_cast(syntax.kind()) {
3161 Some(Self { syntax }) 1797 Some(Self { syntax })
@@ -3165,8 +1801,8 @@ impl AstNode for LambdaExpr {
3165 } 1801 }
3166 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1802 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3167} 1803}
3168impl AstNode for IfExpr { 1804impl AstNode for VariantList {
3169 fn can_cast(kind: SyntaxKind) -> bool { kind == IF_EXPR } 1805 fn can_cast(kind: SyntaxKind) -> bool { kind == VARIANT_LIST }
3170 fn cast(syntax: SyntaxNode) -> Option<Self> { 1806 fn cast(syntax: SyntaxNode) -> Option<Self> {
3171 if Self::can_cast(syntax.kind()) { 1807 if Self::can_cast(syntax.kind()) {
3172 Some(Self { syntax }) 1808 Some(Self { syntax })
@@ -3176,8 +1812,8 @@ impl AstNode for IfExpr {
3176 } 1812 }
3177 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1813 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3178} 1814}
3179impl AstNode for LoopExpr { 1815impl AstNode for Variant {
3180 fn can_cast(kind: SyntaxKind) -> bool { kind == LOOP_EXPR } 1816 fn can_cast(kind: SyntaxKind) -> bool { kind == VARIANT }
3181 fn cast(syntax: SyntaxNode) -> Option<Self> { 1817 fn cast(syntax: SyntaxNode) -> Option<Self> {
3182 if Self::can_cast(syntax.kind()) { 1818 if Self::can_cast(syntax.kind()) {
3183 Some(Self { syntax }) 1819 Some(Self { syntax })
@@ -3187,8 +1823,8 @@ impl AstNode for LoopExpr {
3187 } 1823 }
3188 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1824 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3189} 1825}
3190impl AstNode for EffectExpr { 1826impl AstNode for AssocItemList {
3191 fn can_cast(kind: SyntaxKind) -> bool { kind == EFFECT_EXPR } 1827 fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_ITEM_LIST }
3192 fn cast(syntax: SyntaxNode) -> Option<Self> { 1828 fn cast(syntax: SyntaxNode) -> Option<Self> {
3193 if Self::can_cast(syntax.kind()) { 1829 if Self::can_cast(syntax.kind()) {
3194 Some(Self { syntax }) 1830 Some(Self { syntax })
@@ -3198,8 +1834,8 @@ impl AstNode for EffectExpr {
3198 } 1834 }
3199 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1835 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3200} 1836}
3201impl AstNode for ForExpr { 1837impl AstNode for ExternItemList {
3202 fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_EXPR } 1838 fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_ITEM_LIST }
3203 fn cast(syntax: SyntaxNode) -> Option<Self> { 1839 fn cast(syntax: SyntaxNode) -> Option<Self> {
3204 if Self::can_cast(syntax.kind()) { 1840 if Self::can_cast(syntax.kind()) {
3205 Some(Self { syntax }) 1841 Some(Self { syntax })
@@ -3209,8 +1845,8 @@ impl AstNode for ForExpr {
3209 } 1845 }
3210 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1846 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3211} 1847}
3212impl AstNode for WhileExpr { 1848impl AstNode for LifetimeParam {
3213 fn can_cast(kind: SyntaxKind) -> bool { kind == WHILE_EXPR } 1849 fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_PARAM }
3214 fn cast(syntax: SyntaxNode) -> Option<Self> { 1850 fn cast(syntax: SyntaxNode) -> Option<Self> {
3215 if Self::can_cast(syntax.kind()) { 1851 if Self::can_cast(syntax.kind()) {
3216 Some(Self { syntax }) 1852 Some(Self { syntax })
@@ -3220,8 +1856,8 @@ impl AstNode for WhileExpr {
3220 } 1856 }
3221 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1857 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3222} 1858}
3223impl AstNode for ContinueExpr { 1859impl AstNode for TypeParam {
3224 fn can_cast(kind: SyntaxKind) -> bool { kind == CONTINUE_EXPR } 1860 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM }
3225 fn cast(syntax: SyntaxNode) -> Option<Self> { 1861 fn cast(syntax: SyntaxNode) -> Option<Self> {
3226 if Self::can_cast(syntax.kind()) { 1862 if Self::can_cast(syntax.kind()) {
3227 Some(Self { syntax }) 1863 Some(Self { syntax })
@@ -3231,8 +1867,8 @@ impl AstNode for ContinueExpr {
3231 } 1867 }
3232 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1868 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3233} 1869}
3234impl AstNode for BreakExpr { 1870impl AstNode for ConstParam {
3235 fn can_cast(kind: SyntaxKind) -> bool { kind == BREAK_EXPR } 1871 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_PARAM }
3236 fn cast(syntax: SyntaxNode) -> Option<Self> { 1872 fn cast(syntax: SyntaxNode) -> Option<Self> {
3237 if Self::can_cast(syntax.kind()) { 1873 if Self::can_cast(syntax.kind()) {
3238 Some(Self { syntax }) 1874 Some(Self { syntax })
@@ -3242,8 +1878,8 @@ impl AstNode for BreakExpr {
3242 } 1878 }
3243 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1879 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3244} 1880}
3245impl AstNode for Label { 1881impl AstNode for Literal {
3246 fn can_cast(kind: SyntaxKind) -> bool { kind == LABEL } 1882 fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL }
3247 fn cast(syntax: SyntaxNode) -> Option<Self> { 1883 fn cast(syntax: SyntaxNode) -> Option<Self> {
3248 if Self::can_cast(syntax.kind()) { 1884 if Self::can_cast(syntax.kind()) {
3249 Some(Self { syntax }) 1885 Some(Self { syntax })
@@ -3253,8 +1889,8 @@ impl AstNode for Label {
3253 } 1889 }
3254 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1890 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3255} 1891}
3256impl AstNode for BlockExpr { 1892impl AstNode for TokenTree {
3257 fn can_cast(kind: SyntaxKind) -> bool { kind == BLOCK_EXPR } 1893 fn can_cast(kind: SyntaxKind) -> bool { kind == TOKEN_TREE }
3258 fn cast(syntax: SyntaxNode) -> Option<Self> { 1894 fn cast(syntax: SyntaxNode) -> Option<Self> {
3259 if Self::can_cast(syntax.kind()) { 1895 if Self::can_cast(syntax.kind()) {
3260 Some(Self { syntax }) 1896 Some(Self { syntax })
@@ -3264,8 +1900,8 @@ impl AstNode for BlockExpr {
3264 } 1900 }
3265 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1901 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3266} 1902}
3267impl AstNode for ReturnExpr { 1903impl AstNode for ParenType {
3268 fn can_cast(kind: SyntaxKind) -> bool { kind == RETURN_EXPR } 1904 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_TYPE }
3269 fn cast(syntax: SyntaxNode) -> Option<Self> { 1905 fn cast(syntax: SyntaxNode) -> Option<Self> {
3270 if Self::can_cast(syntax.kind()) { 1906 if Self::can_cast(syntax.kind()) {
3271 Some(Self { syntax }) 1907 Some(Self { syntax })
@@ -3275,8 +1911,8 @@ impl AstNode for ReturnExpr {
3275 } 1911 }
3276 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1912 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3277} 1913}
3278impl AstNode for CallExpr { 1914impl AstNode for TupleType {
3279 fn can_cast(kind: SyntaxKind) -> bool { kind == CALL_EXPR } 1915 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_TYPE }
3280 fn cast(syntax: SyntaxNode) -> Option<Self> { 1916 fn cast(syntax: SyntaxNode) -> Option<Self> {
3281 if Self::can_cast(syntax.kind()) { 1917 if Self::can_cast(syntax.kind()) {
3282 Some(Self { syntax }) 1918 Some(Self { syntax })
@@ -3286,8 +1922,8 @@ impl AstNode for CallExpr {
3286 } 1922 }
3287 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1923 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3288} 1924}
3289impl AstNode for MethodCallExpr { 1925impl AstNode for NeverType {
3290 fn can_cast(kind: SyntaxKind) -> bool { kind == METHOD_CALL_EXPR } 1926 fn can_cast(kind: SyntaxKind) -> bool { kind == NEVER_TYPE }
3291 fn cast(syntax: SyntaxNode) -> Option<Self> { 1927 fn cast(syntax: SyntaxNode) -> Option<Self> {
3292 if Self::can_cast(syntax.kind()) { 1928 if Self::can_cast(syntax.kind()) {
3293 Some(Self { syntax }) 1929 Some(Self { syntax })
@@ -3297,8 +1933,8 @@ impl AstNode for MethodCallExpr {
3297 } 1933 }
3298 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1934 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3299} 1935}
3300impl AstNode for IndexExpr { 1936impl AstNode for PathType {
3301 fn can_cast(kind: SyntaxKind) -> bool { kind == INDEX_EXPR } 1937 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_TYPE }
3302 fn cast(syntax: SyntaxNode) -> Option<Self> { 1938 fn cast(syntax: SyntaxNode) -> Option<Self> {
3303 if Self::can_cast(syntax.kind()) { 1939 if Self::can_cast(syntax.kind()) {
3304 Some(Self { syntax }) 1940 Some(Self { syntax })
@@ -3308,8 +1944,8 @@ impl AstNode for IndexExpr {
3308 } 1944 }
3309 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1945 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3310} 1946}
3311impl AstNode for FieldExpr { 1947impl AstNode for PointerType {
3312 fn can_cast(kind: SyntaxKind) -> bool { kind == FIELD_EXPR } 1948 fn can_cast(kind: SyntaxKind) -> bool { kind == POINTER_TYPE }
3313 fn cast(syntax: SyntaxNode) -> Option<Self> { 1949 fn cast(syntax: SyntaxNode) -> Option<Self> {
3314 if Self::can_cast(syntax.kind()) { 1950 if Self::can_cast(syntax.kind()) {
3315 Some(Self { syntax }) 1951 Some(Self { syntax })
@@ -3319,8 +1955,8 @@ impl AstNode for FieldExpr {
3319 } 1955 }
3320 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1956 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3321} 1957}
3322impl AstNode for AwaitExpr { 1958impl AstNode for ArrayType {
3323 fn can_cast(kind: SyntaxKind) -> bool { kind == AWAIT_EXPR } 1959 fn can_cast(kind: SyntaxKind) -> bool { kind == ARRAY_TYPE }
3324 fn cast(syntax: SyntaxNode) -> Option<Self> { 1960 fn cast(syntax: SyntaxNode) -> Option<Self> {
3325 if Self::can_cast(syntax.kind()) { 1961 if Self::can_cast(syntax.kind()) {
3326 Some(Self { syntax }) 1962 Some(Self { syntax })
@@ -3330,8 +1966,8 @@ impl AstNode for AwaitExpr {
3330 } 1966 }
3331 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1967 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3332} 1968}
3333impl AstNode for TryExpr { 1969impl AstNode for SliceType {
3334 fn can_cast(kind: SyntaxKind) -> bool { kind == TRY_EXPR } 1970 fn can_cast(kind: SyntaxKind) -> bool { kind == SLICE_TYPE }
3335 fn cast(syntax: SyntaxNode) -> Option<Self> { 1971 fn cast(syntax: SyntaxNode) -> Option<Self> {
3336 if Self::can_cast(syntax.kind()) { 1972 if Self::can_cast(syntax.kind()) {
3337 Some(Self { syntax }) 1973 Some(Self { syntax })
@@ -3341,8 +1977,8 @@ impl AstNode for TryExpr {
3341 } 1977 }
3342 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1978 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3343} 1979}
3344impl AstNode for CastExpr { 1980impl AstNode for ReferenceType {
3345 fn can_cast(kind: SyntaxKind) -> bool { kind == CAST_EXPR } 1981 fn can_cast(kind: SyntaxKind) -> bool { kind == REFERENCE_TYPE }
3346 fn cast(syntax: SyntaxNode) -> Option<Self> { 1982 fn cast(syntax: SyntaxNode) -> Option<Self> {
3347 if Self::can_cast(syntax.kind()) { 1983 if Self::can_cast(syntax.kind()) {
3348 Some(Self { syntax }) 1984 Some(Self { syntax })
@@ -3352,8 +1988,8 @@ impl AstNode for CastExpr {
3352 } 1988 }
3353 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1989 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3354} 1990}
3355impl AstNode for RefExpr { 1991impl AstNode for PlaceholderType {
3356 fn can_cast(kind: SyntaxKind) -> bool { kind == REF_EXPR } 1992 fn can_cast(kind: SyntaxKind) -> bool { kind == PLACEHOLDER_TYPE }
3357 fn cast(syntax: SyntaxNode) -> Option<Self> { 1993 fn cast(syntax: SyntaxNode) -> Option<Self> {
3358 if Self::can_cast(syntax.kind()) { 1994 if Self::can_cast(syntax.kind()) {
3359 Some(Self { syntax }) 1995 Some(Self { syntax })
@@ -3363,8 +1999,8 @@ impl AstNode for RefExpr {
3363 } 1999 }
3364 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2000 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3365} 2001}
3366impl AstNode for PrefixExpr { 2002impl AstNode for FnPointerType {
3367 fn can_cast(kind: SyntaxKind) -> bool { kind == PREFIX_EXPR } 2003 fn can_cast(kind: SyntaxKind) -> bool { kind == FN_POINTER_TYPE }
3368 fn cast(syntax: SyntaxNode) -> Option<Self> { 2004 fn cast(syntax: SyntaxNode) -> Option<Self> {
3369 if Self::can_cast(syntax.kind()) { 2005 if Self::can_cast(syntax.kind()) {
3370 Some(Self { syntax }) 2006 Some(Self { syntax })
@@ -3374,8 +2010,8 @@ impl AstNode for PrefixExpr {
3374 } 2010 }
3375 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2011 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3376} 2012}
3377impl AstNode for BoxExpr { 2013impl AstNode for ForType {
3378 fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_EXPR } 2014 fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_TYPE }
3379 fn cast(syntax: SyntaxNode) -> Option<Self> { 2015 fn cast(syntax: SyntaxNode) -> Option<Self> {
3380 if Self::can_cast(syntax.kind()) { 2016 if Self::can_cast(syntax.kind()) {
3381 Some(Self { syntax }) 2017 Some(Self { syntax })
@@ -3385,8 +2021,8 @@ impl AstNode for BoxExpr {
3385 } 2021 }
3386 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2022 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3387} 2023}
3388impl AstNode for RangeExpr { 2024impl AstNode for ImplTraitType {
3389 fn can_cast(kind: SyntaxKind) -> bool { kind == RANGE_EXPR } 2025 fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_TRAIT_TYPE }
3390 fn cast(syntax: SyntaxNode) -> Option<Self> { 2026 fn cast(syntax: SyntaxNode) -> Option<Self> {
3391 if Self::can_cast(syntax.kind()) { 2027 if Self::can_cast(syntax.kind()) {
3392 Some(Self { syntax }) 2028 Some(Self { syntax })
@@ -3396,8 +2032,8 @@ impl AstNode for RangeExpr {
3396 } 2032 }
3397 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2033 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3398} 2034}
3399impl AstNode for BinExpr { 2035impl AstNode for DynTraitType {
3400 fn can_cast(kind: SyntaxKind) -> bool { kind == BIN_EXPR } 2036 fn can_cast(kind: SyntaxKind) -> bool { kind == DYN_TRAIT_TYPE }
3401 fn cast(syntax: SyntaxNode) -> Option<Self> { 2037 fn cast(syntax: SyntaxNode) -> Option<Self> {
3402 if Self::can_cast(syntax.kind()) { 2038 if Self::can_cast(syntax.kind()) {
3403 Some(Self { syntax }) 2039 Some(Self { syntax })
@@ -3407,8 +2043,8 @@ impl AstNode for BinExpr {
3407 } 2043 }
3408 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2044 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3409} 2045}
3410impl AstNode for Literal { 2046impl AstNode for TupleExpr {
3411 fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL } 2047 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_EXPR }
3412 fn cast(syntax: SyntaxNode) -> Option<Self> { 2048 fn cast(syntax: SyntaxNode) -> Option<Self> {
3413 if Self::can_cast(syntax.kind()) { 2049 if Self::can_cast(syntax.kind()) {
3414 Some(Self { syntax }) 2050 Some(Self { syntax })
@@ -3418,8 +2054,8 @@ impl AstNode for Literal {
3418 } 2054 }
3419 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2055 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3420} 2056}
3421impl AstNode for MatchExpr { 2057impl AstNode for ArrayExpr {
3422 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_EXPR } 2058 fn can_cast(kind: SyntaxKind) -> bool { kind == ARRAY_EXPR }
3423 fn cast(syntax: SyntaxNode) -> Option<Self> { 2059 fn cast(syntax: SyntaxNode) -> Option<Self> {
3424 if Self::can_cast(syntax.kind()) { 2060 if Self::can_cast(syntax.kind()) {
3425 Some(Self { syntax }) 2061 Some(Self { syntax })
@@ -3429,8 +2065,8 @@ impl AstNode for MatchExpr {
3429 } 2065 }
3430 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2066 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3431} 2067}
3432impl AstNode for MatchArmList { 2068impl AstNode for ParenExpr {
3433 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_ARM_LIST } 2069 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_EXPR }
3434 fn cast(syntax: SyntaxNode) -> Option<Self> { 2070 fn cast(syntax: SyntaxNode) -> Option<Self> {
3435 if Self::can_cast(syntax.kind()) { 2071 if Self::can_cast(syntax.kind()) {
3436 Some(Self { syntax }) 2072 Some(Self { syntax })
@@ -3440,8 +2076,8 @@ impl AstNode for MatchArmList {
3440 } 2076 }
3441 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2077 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3442} 2078}
3443impl AstNode for MatchArm { 2079impl AstNode for PathExpr {
3444 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_ARM } 2080 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_EXPR }
3445 fn cast(syntax: SyntaxNode) -> Option<Self> { 2081 fn cast(syntax: SyntaxNode) -> Option<Self> {
3446 if Self::can_cast(syntax.kind()) { 2082 if Self::can_cast(syntax.kind()) {
3447 Some(Self { syntax }) 2083 Some(Self { syntax })
@@ -3451,8 +2087,8 @@ impl AstNode for MatchArm {
3451 } 2087 }
3452 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2088 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3453} 2089}
3454impl AstNode for MatchGuard { 2090impl AstNode for LambdaExpr {
3455 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_GUARD } 2091 fn can_cast(kind: SyntaxKind) -> bool { kind == LAMBDA_EXPR }
3456 fn cast(syntax: SyntaxNode) -> Option<Self> { 2092 fn cast(syntax: SyntaxNode) -> Option<Self> {
3457 if Self::can_cast(syntax.kind()) { 2093 if Self::can_cast(syntax.kind()) {
3458 Some(Self { syntax }) 2094 Some(Self { syntax })
@@ -3462,8 +2098,8 @@ impl AstNode for MatchGuard {
3462 } 2098 }
3463 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2099 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3464} 2100}
3465impl AstNode for RecordLit { 2101impl AstNode for IfExpr {
3466 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_LIT } 2102 fn can_cast(kind: SyntaxKind) -> bool { kind == IF_EXPR }
3467 fn cast(syntax: SyntaxNode) -> Option<Self> { 2103 fn cast(syntax: SyntaxNode) -> Option<Self> {
3468 if Self::can_cast(syntax.kind()) { 2104 if Self::can_cast(syntax.kind()) {
3469 Some(Self { syntax }) 2105 Some(Self { syntax })
@@ -3473,8 +2109,8 @@ impl AstNode for RecordLit {
3473 } 2109 }
3474 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2110 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3475} 2111}
3476impl AstNode for RecordFieldList { 2112impl AstNode for Condition {
3477 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_LIST } 2113 fn can_cast(kind: SyntaxKind) -> bool { kind == CONDITION }
3478 fn cast(syntax: SyntaxNode) -> Option<Self> { 2114 fn cast(syntax: SyntaxNode) -> Option<Self> {
3479 if Self::can_cast(syntax.kind()) { 2115 if Self::can_cast(syntax.kind()) {
3480 Some(Self { syntax }) 2116 Some(Self { syntax })
@@ -3484,8 +2120,8 @@ impl AstNode for RecordFieldList {
3484 } 2120 }
3485 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2121 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3486} 2122}
3487impl AstNode for RecordField { 2123impl AstNode for EffectExpr {
3488 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD } 2124 fn can_cast(kind: SyntaxKind) -> bool { kind == EFFECT_EXPR }
3489 fn cast(syntax: SyntaxNode) -> Option<Self> { 2125 fn cast(syntax: SyntaxNode) -> Option<Self> {
3490 if Self::can_cast(syntax.kind()) { 2126 if Self::can_cast(syntax.kind()) {
3491 Some(Self { syntax }) 2127 Some(Self { syntax })
@@ -3495,8 +2131,8 @@ impl AstNode for RecordField {
3495 } 2131 }
3496 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2132 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3497} 2133}
3498impl AstNode for OrPat { 2134impl AstNode for Label {
3499 fn can_cast(kind: SyntaxKind) -> bool { kind == OR_PAT } 2135 fn can_cast(kind: SyntaxKind) -> bool { kind == LABEL }
3500 fn cast(syntax: SyntaxNode) -> Option<Self> { 2136 fn cast(syntax: SyntaxNode) -> Option<Self> {
3501 if Self::can_cast(syntax.kind()) { 2137 if Self::can_cast(syntax.kind()) {
3502 Some(Self { syntax }) 2138 Some(Self { syntax })
@@ -3506,8 +2142,8 @@ impl AstNode for OrPat {
3506 } 2142 }
3507 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2143 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3508} 2144}
3509impl AstNode for ParenPat { 2145impl AstNode for LoopExpr {
3510 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_PAT } 2146 fn can_cast(kind: SyntaxKind) -> bool { kind == LOOP_EXPR }
3511 fn cast(syntax: SyntaxNode) -> Option<Self> { 2147 fn cast(syntax: SyntaxNode) -> Option<Self> {
3512 if Self::can_cast(syntax.kind()) { 2148 if Self::can_cast(syntax.kind()) {
3513 Some(Self { syntax }) 2149 Some(Self { syntax })
@@ -3517,8 +2153,8 @@ impl AstNode for ParenPat {
3517 } 2153 }
3518 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2154 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3519} 2155}
3520impl AstNode for RefPat { 2156impl AstNode for ForExpr {
3521 fn can_cast(kind: SyntaxKind) -> bool { kind == REF_PAT } 2157 fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_EXPR }
3522 fn cast(syntax: SyntaxNode) -> Option<Self> { 2158 fn cast(syntax: SyntaxNode) -> Option<Self> {
3523 if Self::can_cast(syntax.kind()) { 2159 if Self::can_cast(syntax.kind()) {
3524 Some(Self { syntax }) 2160 Some(Self { syntax })
@@ -3528,8 +2164,8 @@ impl AstNode for RefPat {
3528 } 2164 }
3529 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2165 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3530} 2166}
3531impl AstNode for BoxPat { 2167impl AstNode for WhileExpr {
3532 fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_PAT } 2168 fn can_cast(kind: SyntaxKind) -> bool { kind == WHILE_EXPR }
3533 fn cast(syntax: SyntaxNode) -> Option<Self> { 2169 fn cast(syntax: SyntaxNode) -> Option<Self> {
3534 if Self::can_cast(syntax.kind()) { 2170 if Self::can_cast(syntax.kind()) {
3535 Some(Self { syntax }) 2171 Some(Self { syntax })
@@ -3539,8 +2175,8 @@ impl AstNode for BoxPat {
3539 } 2175 }
3540 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2176 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3541} 2177}
3542impl AstNode for BindPat { 2178impl AstNode for ContinueExpr {
3543 fn can_cast(kind: SyntaxKind) -> bool { kind == BIND_PAT } 2179 fn can_cast(kind: SyntaxKind) -> bool { kind == CONTINUE_EXPR }
3544 fn cast(syntax: SyntaxNode) -> Option<Self> { 2180 fn cast(syntax: SyntaxNode) -> Option<Self> {
3545 if Self::can_cast(syntax.kind()) { 2181 if Self::can_cast(syntax.kind()) {
3546 Some(Self { syntax }) 2182 Some(Self { syntax })
@@ -3550,8 +2186,8 @@ impl AstNode for BindPat {
3550 } 2186 }
3551 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2187 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3552} 2188}
3553impl AstNode for PlaceholderPat { 2189impl AstNode for BreakExpr {
3554 fn can_cast(kind: SyntaxKind) -> bool { kind == PLACEHOLDER_PAT } 2190 fn can_cast(kind: SyntaxKind) -> bool { kind == BREAK_EXPR }
3555 fn cast(syntax: SyntaxNode) -> Option<Self> { 2191 fn cast(syntax: SyntaxNode) -> Option<Self> {
3556 if Self::can_cast(syntax.kind()) { 2192 if Self::can_cast(syntax.kind()) {
3557 Some(Self { syntax }) 2193 Some(Self { syntax })
@@ -3561,8 +2197,8 @@ impl AstNode for PlaceholderPat {
3561 } 2197 }
3562 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2198 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3563} 2199}
3564impl AstNode for DotDotPat { 2200impl AstNode for ReturnExpr {
3565 fn can_cast(kind: SyntaxKind) -> bool { kind == DOT_DOT_PAT } 2201 fn can_cast(kind: SyntaxKind) -> bool { kind == RETURN_EXPR }
3566 fn cast(syntax: SyntaxNode) -> Option<Self> { 2202 fn cast(syntax: SyntaxNode) -> Option<Self> {
3567 if Self::can_cast(syntax.kind()) { 2203 if Self::can_cast(syntax.kind()) {
3568 Some(Self { syntax }) 2204 Some(Self { syntax })
@@ -3572,8 +2208,8 @@ impl AstNode for DotDotPat {
3572 } 2208 }
3573 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2209 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3574} 2210}
3575impl AstNode for PathPat { 2211impl AstNode for CallExpr {
3576 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_PAT } 2212 fn can_cast(kind: SyntaxKind) -> bool { kind == CALL_EXPR }
3577 fn cast(syntax: SyntaxNode) -> Option<Self> { 2213 fn cast(syntax: SyntaxNode) -> Option<Self> {
3578 if Self::can_cast(syntax.kind()) { 2214 if Self::can_cast(syntax.kind()) {
3579 Some(Self { syntax }) 2215 Some(Self { syntax })
@@ -3583,8 +2219,8 @@ impl AstNode for PathPat {
3583 } 2219 }
3584 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2220 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3585} 2221}
3586impl AstNode for SlicePat { 2222impl AstNode for ArgList {
3587 fn can_cast(kind: SyntaxKind) -> bool { kind == SLICE_PAT } 2223 fn can_cast(kind: SyntaxKind) -> bool { kind == ARG_LIST }
3588 fn cast(syntax: SyntaxNode) -> Option<Self> { 2224 fn cast(syntax: SyntaxNode) -> Option<Self> {
3589 if Self::can_cast(syntax.kind()) { 2225 if Self::can_cast(syntax.kind()) {
3590 Some(Self { syntax }) 2226 Some(Self { syntax })
@@ -3594,8 +2230,8 @@ impl AstNode for SlicePat {
3594 } 2230 }
3595 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2231 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3596} 2232}
3597impl AstNode for RangePat { 2233impl AstNode for MethodCallExpr {
3598 fn can_cast(kind: SyntaxKind) -> bool { kind == RANGE_PAT } 2234 fn can_cast(kind: SyntaxKind) -> bool { kind == METHOD_CALL_EXPR }
3599 fn cast(syntax: SyntaxNode) -> Option<Self> { 2235 fn cast(syntax: SyntaxNode) -> Option<Self> {
3600 if Self::can_cast(syntax.kind()) { 2236 if Self::can_cast(syntax.kind()) {
3601 Some(Self { syntax }) 2237 Some(Self { syntax })
@@ -3605,8 +2241,8 @@ impl AstNode for RangePat {
3605 } 2241 }
3606 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2242 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3607} 2243}
3608impl AstNode for LiteralPat { 2244impl AstNode for TypeArgList {
3609 fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL_PAT } 2245 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG_LIST }
3610 fn cast(syntax: SyntaxNode) -> Option<Self> { 2246 fn cast(syntax: SyntaxNode) -> Option<Self> {
3611 if Self::can_cast(syntax.kind()) { 2247 if Self::can_cast(syntax.kind()) {
3612 Some(Self { syntax }) 2248 Some(Self { syntax })
@@ -3616,8 +2252,8 @@ impl AstNode for LiteralPat {
3616 } 2252 }
3617 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2253 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3618} 2254}
3619impl AstNode for MacroPat { 2255impl AstNode for FieldExpr {
3620 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_PAT } 2256 fn can_cast(kind: SyntaxKind) -> bool { kind == FIELD_EXPR }
3621 fn cast(syntax: SyntaxNode) -> Option<Self> { 2257 fn cast(syntax: SyntaxNode) -> Option<Self> {
3622 if Self::can_cast(syntax.kind()) { 2258 if Self::can_cast(syntax.kind()) {
3623 Some(Self { syntax }) 2259 Some(Self { syntax })
@@ -3627,8 +2263,8 @@ impl AstNode for MacroPat {
3627 } 2263 }
3628 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2264 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3629} 2265}
3630impl AstNode for RecordPat { 2266impl AstNode for IndexExpr {
3631 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_PAT } 2267 fn can_cast(kind: SyntaxKind) -> bool { kind == INDEX_EXPR }
3632 fn cast(syntax: SyntaxNode) -> Option<Self> { 2268 fn cast(syntax: SyntaxNode) -> Option<Self> {
3633 if Self::can_cast(syntax.kind()) { 2269 if Self::can_cast(syntax.kind()) {
3634 Some(Self { syntax }) 2270 Some(Self { syntax })
@@ -3638,8 +2274,8 @@ impl AstNode for RecordPat {
3638 } 2274 }
3639 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2275 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3640} 2276}
3641impl AstNode for RecordFieldPatList { 2277impl AstNode for AwaitExpr {
3642 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_PAT_LIST } 2278 fn can_cast(kind: SyntaxKind) -> bool { kind == AWAIT_EXPR }
3643 fn cast(syntax: SyntaxNode) -> Option<Self> { 2279 fn cast(syntax: SyntaxNode) -> Option<Self> {
3644 if Self::can_cast(syntax.kind()) { 2280 if Self::can_cast(syntax.kind()) {
3645 Some(Self { syntax }) 2281 Some(Self { syntax })
@@ -3649,8 +2285,8 @@ impl AstNode for RecordFieldPatList {
3649 } 2285 }
3650 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2286 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3651} 2287}
3652impl AstNode for RecordFieldPat { 2288impl AstNode for TryExpr {
3653 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_PAT } 2289 fn can_cast(kind: SyntaxKind) -> bool { kind == TRY_EXPR }
3654 fn cast(syntax: SyntaxNode) -> Option<Self> { 2290 fn cast(syntax: SyntaxNode) -> Option<Self> {
3655 if Self::can_cast(syntax.kind()) { 2291 if Self::can_cast(syntax.kind()) {
3656 Some(Self { syntax }) 2292 Some(Self { syntax })
@@ -3660,8 +2296,8 @@ impl AstNode for RecordFieldPat {
3660 } 2296 }
3661 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2297 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3662} 2298}
3663impl AstNode for TupleStructPat { 2299impl AstNode for CastExpr {
3664 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_STRUCT_PAT } 2300 fn can_cast(kind: SyntaxKind) -> bool { kind == CAST_EXPR }
3665 fn cast(syntax: SyntaxNode) -> Option<Self> { 2301 fn cast(syntax: SyntaxNode) -> Option<Self> {
3666 if Self::can_cast(syntax.kind()) { 2302 if Self::can_cast(syntax.kind()) {
3667 Some(Self { syntax }) 2303 Some(Self { syntax })
@@ -3671,8 +2307,8 @@ impl AstNode for TupleStructPat {
3671 } 2307 }
3672 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2308 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3673} 2309}
3674impl AstNode for TuplePat { 2310impl AstNode for RefExpr {
3675 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_PAT } 2311 fn can_cast(kind: SyntaxKind) -> bool { kind == REF_EXPR }
3676 fn cast(syntax: SyntaxNode) -> Option<Self> { 2312 fn cast(syntax: SyntaxNode) -> Option<Self> {
3677 if Self::can_cast(syntax.kind()) { 2313 if Self::can_cast(syntax.kind()) {
3678 Some(Self { syntax }) 2314 Some(Self { syntax })
@@ -3682,8 +2318,8 @@ impl AstNode for TuplePat {
3682 } 2318 }
3683 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2319 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3684} 2320}
3685impl AstNode for Visibility { 2321impl AstNode for PrefixExpr {
3686 fn can_cast(kind: SyntaxKind) -> bool { kind == VISIBILITY } 2322 fn can_cast(kind: SyntaxKind) -> bool { kind == PREFIX_EXPR }
3687 fn cast(syntax: SyntaxNode) -> Option<Self> { 2323 fn cast(syntax: SyntaxNode) -> Option<Self> {
3688 if Self::can_cast(syntax.kind()) { 2324 if Self::can_cast(syntax.kind()) {
3689 Some(Self { syntax }) 2325 Some(Self { syntax })
@@ -3693,8 +2329,8 @@ impl AstNode for Visibility {
3693 } 2329 }
3694 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2330 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3695} 2331}
3696impl AstNode for Name { 2332impl AstNode for BoxExpr {
3697 fn can_cast(kind: SyntaxKind) -> bool { kind == NAME } 2333 fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_EXPR }
3698 fn cast(syntax: SyntaxNode) -> Option<Self> { 2334 fn cast(syntax: SyntaxNode) -> Option<Self> {
3699 if Self::can_cast(syntax.kind()) { 2335 if Self::can_cast(syntax.kind()) {
3700 Some(Self { syntax }) 2336 Some(Self { syntax })
@@ -3704,8 +2340,8 @@ impl AstNode for Name {
3704 } 2340 }
3705 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2341 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3706} 2342}
3707impl AstNode for NameRef { 2343impl AstNode for RangeExpr {
3708 fn can_cast(kind: SyntaxKind) -> bool { kind == NAME_REF } 2344 fn can_cast(kind: SyntaxKind) -> bool { kind == RANGE_EXPR }
3709 fn cast(syntax: SyntaxNode) -> Option<Self> { 2345 fn cast(syntax: SyntaxNode) -> Option<Self> {
3710 if Self::can_cast(syntax.kind()) { 2346 if Self::can_cast(syntax.kind()) {
3711 Some(Self { syntax }) 2347 Some(Self { syntax })
@@ -3715,8 +2351,8 @@ impl AstNode for NameRef {
3715 } 2351 }
3716 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2352 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3717} 2353}
3718impl AstNode for MacroCall { 2354impl AstNode for BinExpr {
3719 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_CALL } 2355 fn can_cast(kind: SyntaxKind) -> bool { kind == BIN_EXPR }
3720 fn cast(syntax: SyntaxNode) -> Option<Self> { 2356 fn cast(syntax: SyntaxNode) -> Option<Self> {
3721 if Self::can_cast(syntax.kind()) { 2357 if Self::can_cast(syntax.kind()) {
3722 Some(Self { syntax }) 2358 Some(Self { syntax })
@@ -3726,8 +2362,8 @@ impl AstNode for MacroCall {
3726 } 2362 }
3727 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2363 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3728} 2364}
3729impl AstNode for Attr { 2365impl AstNode for MatchExpr {
3730 fn can_cast(kind: SyntaxKind) -> bool { kind == ATTR } 2366 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_EXPR }
3731 fn cast(syntax: SyntaxNode) -> Option<Self> { 2367 fn cast(syntax: SyntaxNode) -> Option<Self> {
3732 if Self::can_cast(syntax.kind()) { 2368 if Self::can_cast(syntax.kind()) {
3733 Some(Self { syntax }) 2369 Some(Self { syntax })
@@ -3737,8 +2373,8 @@ impl AstNode for Attr {
3737 } 2373 }
3738 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2374 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3739} 2375}
3740impl AstNode for TokenTree { 2376impl AstNode for MatchArmList {
3741 fn can_cast(kind: SyntaxKind) -> bool { kind == TOKEN_TREE } 2377 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_ARM_LIST }
3742 fn cast(syntax: SyntaxNode) -> Option<Self> { 2378 fn cast(syntax: SyntaxNode) -> Option<Self> {
3743 if Self::can_cast(syntax.kind()) { 2379 if Self::can_cast(syntax.kind()) {
3744 Some(Self { syntax }) 2380 Some(Self { syntax })
@@ -3748,8 +2384,8 @@ impl AstNode for TokenTree {
3748 } 2384 }
3749 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2385 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3750} 2386}
3751impl AstNode for TypeParamList { 2387impl AstNode for MatchArm {
3752 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM_LIST } 2388 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_ARM }
3753 fn cast(syntax: SyntaxNode) -> Option<Self> { 2389 fn cast(syntax: SyntaxNode) -> Option<Self> {
3754 if Self::can_cast(syntax.kind()) { 2390 if Self::can_cast(syntax.kind()) {
3755 Some(Self { syntax }) 2391 Some(Self { syntax })
@@ -3759,8 +2395,8 @@ impl AstNode for TypeParamList {
3759 } 2395 }
3760 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2396 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3761} 2397}
3762impl AstNode for TypeParam { 2398impl AstNode for MatchGuard {
3763 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM } 2399 fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_GUARD }
3764 fn cast(syntax: SyntaxNode) -> Option<Self> { 2400 fn cast(syntax: SyntaxNode) -> Option<Self> {
3765 if Self::can_cast(syntax.kind()) { 2401 if Self::can_cast(syntax.kind()) {
3766 Some(Self { syntax }) 2402 Some(Self { syntax })
@@ -3770,8 +2406,8 @@ impl AstNode for TypeParam {
3770 } 2406 }
3771 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2407 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3772} 2408}
3773impl AstNode for ConstParam { 2409impl AstNode for RecordExpr {
3774 fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_PARAM } 2410 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR }
3775 fn cast(syntax: SyntaxNode) -> Option<Self> { 2411 fn cast(syntax: SyntaxNode) -> Option<Self> {
3776 if Self::can_cast(syntax.kind()) { 2412 if Self::can_cast(syntax.kind()) {
3777 Some(Self { syntax }) 2413 Some(Self { syntax })
@@ -3781,8 +2417,8 @@ impl AstNode for ConstParam {
3781 } 2417 }
3782 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2418 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3783} 2419}
3784impl AstNode for LifetimeParam { 2420impl AstNode for RecordExprFieldList {
3785 fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_PARAM } 2421 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR_FIELD_LIST }
3786 fn cast(syntax: SyntaxNode) -> Option<Self> { 2422 fn cast(syntax: SyntaxNode) -> Option<Self> {
3787 if Self::can_cast(syntax.kind()) { 2423 if Self::can_cast(syntax.kind()) {
3788 Some(Self { syntax }) 2424 Some(Self { syntax })
@@ -3792,8 +2428,8 @@ impl AstNode for LifetimeParam {
3792 } 2428 }
3793 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2429 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3794} 2430}
3795impl AstNode for TypeBound { 2431impl AstNode for RecordExprField {
3796 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND } 2432 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR_FIELD }
3797 fn cast(syntax: SyntaxNode) -> Option<Self> { 2433 fn cast(syntax: SyntaxNode) -> Option<Self> {
3798 if Self::can_cast(syntax.kind()) { 2434 if Self::can_cast(syntax.kind()) {
3799 Some(Self { syntax }) 2435 Some(Self { syntax })
@@ -3803,8 +2439,8 @@ impl AstNode for TypeBound {
3803 } 2439 }
3804 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2440 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3805} 2441}
3806impl AstNode for TypeBoundList { 2442impl AstNode for OrPat {
3807 fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST } 2443 fn can_cast(kind: SyntaxKind) -> bool { kind == OR_PAT }
3808 fn cast(syntax: SyntaxNode) -> Option<Self> { 2444 fn cast(syntax: SyntaxNode) -> Option<Self> {
3809 if Self::can_cast(syntax.kind()) { 2445 if Self::can_cast(syntax.kind()) {
3810 Some(Self { syntax }) 2446 Some(Self { syntax })
@@ -3814,8 +2450,8 @@ impl AstNode for TypeBoundList {
3814 } 2450 }
3815 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2451 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3816} 2452}
3817impl AstNode for WherePred { 2453impl AstNode for ParenPat {
3818 fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_PRED } 2454 fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_PAT }
3819 fn cast(syntax: SyntaxNode) -> Option<Self> { 2455 fn cast(syntax: SyntaxNode) -> Option<Self> {
3820 if Self::can_cast(syntax.kind()) { 2456 if Self::can_cast(syntax.kind()) {
3821 Some(Self { syntax }) 2457 Some(Self { syntax })
@@ -3825,8 +2461,8 @@ impl AstNode for WherePred {
3825 } 2461 }
3826 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2462 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3827} 2463}
3828impl AstNode for WhereClause { 2464impl AstNode for RefPat {
3829 fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_CLAUSE } 2465 fn can_cast(kind: SyntaxKind) -> bool { kind == REF_PAT }
3830 fn cast(syntax: SyntaxNode) -> Option<Self> { 2466 fn cast(syntax: SyntaxNode) -> Option<Self> {
3831 if Self::can_cast(syntax.kind()) { 2467 if Self::can_cast(syntax.kind()) {
3832 Some(Self { syntax }) 2468 Some(Self { syntax })
@@ -3836,8 +2472,8 @@ impl AstNode for WhereClause {
3836 } 2472 }
3837 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2473 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3838} 2474}
3839impl AstNode for Abi { 2475impl AstNode for BoxPat {
3840 fn can_cast(kind: SyntaxKind) -> bool { kind == ABI } 2476 fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_PAT }
3841 fn cast(syntax: SyntaxNode) -> Option<Self> { 2477 fn cast(syntax: SyntaxNode) -> Option<Self> {
3842 if Self::can_cast(syntax.kind()) { 2478 if Self::can_cast(syntax.kind()) {
3843 Some(Self { syntax }) 2479 Some(Self { syntax })
@@ -3847,8 +2483,8 @@ impl AstNode for Abi {
3847 } 2483 }
3848 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2484 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3849} 2485}
3850impl AstNode for ExprStmt { 2486impl AstNode for BindPat {
3851 fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_STMT } 2487 fn can_cast(kind: SyntaxKind) -> bool { kind == BIND_PAT }
3852 fn cast(syntax: SyntaxNode) -> Option<Self> { 2488 fn cast(syntax: SyntaxNode) -> Option<Self> {
3853 if Self::can_cast(syntax.kind()) { 2489 if Self::can_cast(syntax.kind()) {
3854 Some(Self { syntax }) 2490 Some(Self { syntax })
@@ -3858,8 +2494,8 @@ impl AstNode for ExprStmt {
3858 } 2494 }
3859 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2495 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3860} 2496}
3861impl AstNode for LetStmt { 2497impl AstNode for PlaceholderPat {
3862 fn can_cast(kind: SyntaxKind) -> bool { kind == LET_STMT } 2498 fn can_cast(kind: SyntaxKind) -> bool { kind == PLACEHOLDER_PAT }
3863 fn cast(syntax: SyntaxNode) -> Option<Self> { 2499 fn cast(syntax: SyntaxNode) -> Option<Self> {
3864 if Self::can_cast(syntax.kind()) { 2500 if Self::can_cast(syntax.kind()) {
3865 Some(Self { syntax }) 2501 Some(Self { syntax })
@@ -3869,8 +2505,8 @@ impl AstNode for LetStmt {
3869 } 2505 }
3870 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2506 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3871} 2507}
3872impl AstNode for Condition { 2508impl AstNode for DotDotPat {
3873 fn can_cast(kind: SyntaxKind) -> bool { kind == CONDITION } 2509 fn can_cast(kind: SyntaxKind) -> bool { kind == DOT_DOT_PAT }
3874 fn cast(syntax: SyntaxNode) -> Option<Self> { 2510 fn cast(syntax: SyntaxNode) -> Option<Self> {
3875 if Self::can_cast(syntax.kind()) { 2511 if Self::can_cast(syntax.kind()) {
3876 Some(Self { syntax }) 2512 Some(Self { syntax })
@@ -3880,8 +2516,8 @@ impl AstNode for Condition {
3880 } 2516 }
3881 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2517 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3882} 2518}
3883impl AstNode for ParamList { 2519impl AstNode for PathPat {
3884 fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM_LIST } 2520 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_PAT }
3885 fn cast(syntax: SyntaxNode) -> Option<Self> { 2521 fn cast(syntax: SyntaxNode) -> Option<Self> {
3886 if Self::can_cast(syntax.kind()) { 2522 if Self::can_cast(syntax.kind()) {
3887 Some(Self { syntax }) 2523 Some(Self { syntax })
@@ -3891,8 +2527,8 @@ impl AstNode for ParamList {
3891 } 2527 }
3892 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2528 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3893} 2529}
3894impl AstNode for SelfParam { 2530impl AstNode for SlicePat {
3895 fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM } 2531 fn can_cast(kind: SyntaxKind) -> bool { kind == SLICE_PAT }
3896 fn cast(syntax: SyntaxNode) -> Option<Self> { 2532 fn cast(syntax: SyntaxNode) -> Option<Self> {
3897 if Self::can_cast(syntax.kind()) { 2533 if Self::can_cast(syntax.kind()) {
3898 Some(Self { syntax }) 2534 Some(Self { syntax })
@@ -3902,8 +2538,8 @@ impl AstNode for SelfParam {
3902 } 2538 }
3903 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2539 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3904} 2540}
3905impl AstNode for Param { 2541impl AstNode for RangePat {
3906 fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM } 2542 fn can_cast(kind: SyntaxKind) -> bool { kind == RANGE_PAT }
3907 fn cast(syntax: SyntaxNode) -> Option<Self> { 2543 fn cast(syntax: SyntaxNode) -> Option<Self> {
3908 if Self::can_cast(syntax.kind()) { 2544 if Self::can_cast(syntax.kind()) {
3909 Some(Self { syntax }) 2545 Some(Self { syntax })
@@ -3913,8 +2549,8 @@ impl AstNode for Param {
3913 } 2549 }
3914 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2550 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3915} 2551}
3916impl AstNode for UseItem { 2552impl AstNode for LiteralPat {
3917 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_ITEM } 2553 fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL_PAT }
3918 fn cast(syntax: SyntaxNode) -> Option<Self> { 2554 fn cast(syntax: SyntaxNode) -> Option<Self> {
3919 if Self::can_cast(syntax.kind()) { 2555 if Self::can_cast(syntax.kind()) {
3920 Some(Self { syntax }) 2556 Some(Self { syntax })
@@ -3924,8 +2560,8 @@ impl AstNode for UseItem {
3924 } 2560 }
3925 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2561 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3926} 2562}
3927impl AstNode for UseTree { 2563impl AstNode for MacroPat {
3928 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE } 2564 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_PAT }
3929 fn cast(syntax: SyntaxNode) -> Option<Self> { 2565 fn cast(syntax: SyntaxNode) -> Option<Self> {
3930 if Self::can_cast(syntax.kind()) { 2566 if Self::can_cast(syntax.kind()) {
3931 Some(Self { syntax }) 2567 Some(Self { syntax })
@@ -3935,8 +2571,8 @@ impl AstNode for UseTree {
3935 } 2571 }
3936 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2572 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3937} 2573}
3938impl AstNode for Alias { 2574impl AstNode for RecordPat {
3939 fn can_cast(kind: SyntaxKind) -> bool { kind == ALIAS } 2575 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_PAT }
3940 fn cast(syntax: SyntaxNode) -> Option<Self> { 2576 fn cast(syntax: SyntaxNode) -> Option<Self> {
3941 if Self::can_cast(syntax.kind()) { 2577 if Self::can_cast(syntax.kind()) {
3942 Some(Self { syntax }) 2578 Some(Self { syntax })
@@ -3946,8 +2582,8 @@ impl AstNode for Alias {
3946 } 2582 }
3947 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2583 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3948} 2584}
3949impl AstNode for UseTreeList { 2585impl AstNode for RecordFieldPatList {
3950 fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE_LIST } 2586 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_PAT_LIST }
3951 fn cast(syntax: SyntaxNode) -> Option<Self> { 2587 fn cast(syntax: SyntaxNode) -> Option<Self> {
3952 if Self::can_cast(syntax.kind()) { 2588 if Self::can_cast(syntax.kind()) {
3953 Some(Self { syntax }) 2589 Some(Self { syntax })
@@ -3957,8 +2593,8 @@ impl AstNode for UseTreeList {
3957 } 2593 }
3958 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2594 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3959} 2595}
3960impl AstNode for ExternCrateItem { 2596impl AstNode for RecordFieldPat {
3961 fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_CRATE_ITEM } 2597 fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_PAT }
3962 fn cast(syntax: SyntaxNode) -> Option<Self> { 2598 fn cast(syntax: SyntaxNode) -> Option<Self> {
3963 if Self::can_cast(syntax.kind()) { 2599 if Self::can_cast(syntax.kind()) {
3964 Some(Self { syntax }) 2600 Some(Self { syntax })
@@ -3968,8 +2604,8 @@ impl AstNode for ExternCrateItem {
3968 } 2604 }
3969 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2605 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3970} 2606}
3971impl AstNode for ArgList { 2607impl AstNode for TupleStructPat {
3972 fn can_cast(kind: SyntaxKind) -> bool { kind == ARG_LIST } 2608 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_STRUCT_PAT }
3973 fn cast(syntax: SyntaxNode) -> Option<Self> { 2609 fn cast(syntax: SyntaxNode) -> Option<Self> {
3974 if Self::can_cast(syntax.kind()) { 2610 if Self::can_cast(syntax.kind()) {
3975 Some(Self { syntax }) 2611 Some(Self { syntax })
@@ -3979,8 +2615,8 @@ impl AstNode for ArgList {
3979 } 2615 }
3980 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2616 fn syntax(&self) -> &SyntaxNode { &self.syntax }
3981} 2617}
3982impl AstNode for Path { 2618impl AstNode for TuplePat {
3983 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH } 2619 fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_PAT }
3984 fn cast(syntax: SyntaxNode) -> Option<Self> { 2620 fn cast(syntax: SyntaxNode) -> Option<Self> {