diff options
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r-- | crates/ra_syntax/src/ast/edit.rs | 46 | ||||
-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.rs | 3812 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/make.rs | 14 | ||||
-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.rs | 12 |
7 files changed, 1296 insertions, 2712 deletions
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 | ||
32 | impl ast::FnDef { | 32 | impl 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 | ||
83 | impl ast::ItemList { | 83 | impl 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 | ||
116 | impl ast::RecordFieldList { | 119 | impl 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 | ||
195 | impl 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 | |||
192 | impl ast::TypeParam { | 210 | impl 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 | ||
247 | impl ast::UseItem { | 265 | impl 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 | ||
10 | impl ast::AttrsOwner for ast::Expr {} | ||
11 | |||
10 | impl ast::Expr { | 12 | impl 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 | ||
413 | impl ast::RecordField { | 414 | impl 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)] |
12 | pub struct SourceFile { | 9 | pub struct SourceFile { |
13 | pub(crate) syntax: SyntaxNode, | 10 | pub(crate) syntax: SyntaxNode, |
14 | } | 11 | } |
15 | impl ast::ModuleItemOwner for SourceFile {} | ||
16 | impl ast::AttrsOwner for SourceFile {} | 12 | impl ast::AttrsOwner for SourceFile {} |
17 | impl ast::DocCommentsOwner for SourceFile {} | 13 | impl ast::ModuleItemOwner for SourceFile {} |
18 | impl SourceFile { | 14 | impl 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. | 18 | pub 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)] | ||
44 | pub struct FnDef { | ||
45 | pub(crate) syntax: SyntaxNode, | 19 | pub(crate) syntax: SyntaxNode, |
46 | } | 20 | } |
47 | impl ast::VisibilityOwner for FnDef {} | 21 | impl Attr { |
48 | impl ast::NameOwner for FnDef {} | 22 | pub fn pound_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![#]) } |
49 | impl ast::TypeParamsOwner for FnDef {} | 23 | pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) } |
50 | impl ast::DocCommentsOwner for FnDef {} | 24 | pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } |
51 | impl ast::AttrsOwner for FnDef {} | 25 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } |
52 | impl 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)] | ||
32 | pub struct Const { | ||
33 | pub(crate) syntax: SyntaxNode, | ||
34 | } | ||
35 | impl ast::AttrsOwner for Const {} | ||
36 | impl ast::NameOwner for Const {} | ||
37 | impl ast::VisibilityOwner for Const {} | ||
38 | impl 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)] | ||
49 | pub struct Enum { | ||
50 | pub(crate) syntax: SyntaxNode, | ||
51 | } | ||
52 | impl ast::AttrsOwner for Enum {} | ||
53 | impl ast::NameOwner for Enum {} | ||
54 | impl ast::VisibilityOwner for Enum {} | ||
55 | impl ast::GenericParamsOwner for Enum {} | ||
56 | impl 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)] | ||
61 | pub struct ExternBlock { | ||
62 | pub(crate) syntax: SyntaxNode, | ||
63 | } | ||
64 | impl ast::AttrsOwner for ExternBlock {} | ||
65 | impl 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)] | ||
70 | pub struct ExternCrate { | ||
71 | pub(crate) syntax: SyntaxNode, | ||
72 | } | ||
73 | impl ast::AttrsOwner for ExternCrate {} | ||
74 | impl ast::VisibilityOwner for ExternCrate {} | ||
75 | impl 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)] | ||
84 | pub struct Fn { | ||
85 | pub(crate) syntax: SyntaxNode, | ||
86 | } | ||
87 | impl ast::AttrsOwner for Fn {} | ||
88 | impl ast::NameOwner for Fn {} | ||
89 | impl ast::VisibilityOwner for Fn {} | ||
90 | impl ast::GenericParamsOwner for Fn {} | ||
91 | impl 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)] |
72 | pub struct RetType { | 104 | pub struct Impl { |
73 | pub(crate) syntax: SyntaxNode, | 105 | pub(crate) syntax: SyntaxNode, |
74 | } | 106 | } |
75 | impl RetType { | 107 | impl ast::AttrsOwner for Impl {} |
76 | pub fn thin_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![->]) } | 108 | impl ast::VisibilityOwner for Impl {} |
109 | impl ast::GenericParamsOwner for Impl {} | ||
110 | impl 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)] | ||
121 | pub struct MacroCall { | ||
122 | pub(crate) syntax: SyntaxNode, | ||
123 | } | ||
124 | impl ast::AttrsOwner for MacroCall {} | ||
125 | impl ast::NameOwner for MacroCall {} | ||
126 | impl 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)] | ||
133 | pub struct Module { | ||
134 | pub(crate) syntax: SyntaxNode, | ||
135 | } | ||
136 | impl ast::AttrsOwner for Module {} | ||
137 | impl ast::NameOwner for Module {} | ||
138 | impl ast::VisibilityOwner for Module {} | ||
139 | impl 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)] | ||
145 | pub struct Static { | ||
146 | pub(crate) syntax: SyntaxNode, | ||
147 | } | ||
148 | impl ast::AttrsOwner for Static {} | ||
149 | impl ast::NameOwner for Static {} | ||
150 | impl ast::VisibilityOwner for Static {} | ||
151 | impl 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. | 161 | pub 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)] | ||
100 | pub struct StructDef { | ||
101 | pub(crate) syntax: SyntaxNode, | 162 | pub(crate) syntax: SyntaxNode, |
102 | } | 163 | } |
103 | impl ast::VisibilityOwner for StructDef {} | 164 | impl ast::AttrsOwner for Struct {} |
104 | impl ast::NameOwner for StructDef {} | 165 | impl ast::NameOwner for Struct {} |
105 | impl ast::TypeParamsOwner for StructDef {} | 166 | impl ast::VisibilityOwner for Struct {} |
106 | impl ast::AttrsOwner for StructDef {} | 167 | impl ast::GenericParamsOwner for Struct {} |
107 | impl ast::DocCommentsOwner for StructDef {} | 168 | impl Struct { |
108 | impl 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. | 174 | pub struct Trait { |
115 | /// | 175 | pub(crate) syntax: SyntaxNode, |
116 | /// ``` | 176 | } |
117 | /// ❰ | 177 | impl ast::AttrsOwner for Trait {} |
118 | /// /// Docs | 178 | impl ast::NameOwner for Trait {} |
119 | /// #[attr] | 179 | impl ast::VisibilityOwner for Trait {} |
120 | /// pub union Foo<T> where T: Debug { | 180 | impl ast::GenericParamsOwner for Trait {} |
121 | /// /// Docs | 181 | impl ast::TypeBoundsOwner for Trait {} |
122 | /// #[attr] | 182 | impl 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) | 189 | pub struct TypeAlias { |
130 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
131 | pub struct UnionDef { | ||
132 | pub(crate) syntax: SyntaxNode, | 190 | pub(crate) syntax: SyntaxNode, |
133 | } | 191 | } |
134 | impl ast::VisibilityOwner for UnionDef {} | 192 | impl ast::AttrsOwner for TypeAlias {} |
135 | impl ast::NameOwner for UnionDef {} | 193 | impl ast::NameOwner for TypeAlias {} |
136 | impl ast::TypeParamsOwner for UnionDef {} | 194 | impl ast::VisibilityOwner for TypeAlias {} |
137 | impl ast::AttrsOwner for UnionDef {} | 195 | impl ast::GenericParamsOwner for TypeAlias {} |
138 | impl ast::DocCommentsOwner for UnionDef {} | 196 | impl ast::TypeBoundsOwner for TypeAlias {} |
139 | impl UnionDef { | 197 | impl 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)] | ||
205 | pub struct Union { | ||
206 | pub(crate) syntax: SyntaxNode, | ||
207 | } | ||
208 | impl ast::AttrsOwner for Union {} | ||
209 | impl ast::NameOwner for Union {} | ||
210 | impl ast::VisibilityOwner for Union {} | ||
211 | impl ast::GenericParamsOwner for Union {} | ||
212 | impl 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)] |
217 | pub struct Use { | ||
218 | pub(crate) syntax: SyntaxNode, | ||
219 | } | ||
220 | impl ast::AttrsOwner for Use {} | ||
221 | impl ast::VisibilityOwner for Use {} | ||
222 | impl 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)] | ||
228 | pub struct Visibility { | ||
229 | pub(crate) syntax: SyntaxNode, | ||
230 | } | ||
231 | impl 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)] | ||
242 | pub struct Name { | ||
243 | pub(crate) syntax: SyntaxNode, | ||
244 | } | ||
245 | impl Name { | ||
246 | pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) } | ||
247 | } | ||
248 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
249 | pub struct ItemList { | ||
250 | pub(crate) syntax: SyntaxNode, | ||
251 | } | ||
252 | impl ast::AttrsOwner for ItemList {} | ||
253 | impl ast::ModuleItemOwner for ItemList {} | ||
254 | impl 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)] | ||
259 | pub struct NameRef { | ||
260 | pub(crate) syntax: SyntaxNode, | ||
144 | } | 261 | } |
145 | /// Record field definition list including enclosing curly braces. | 262 | impl 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 | /// ❰ | 266 | pub struct Rename { |
150 | /// { | 267 | pub(crate) syntax: SyntaxNode, |
151 | /// a: u32, | 268 | } |
152 | /// b: bool, | 269 | impl ast::NameOwner for Rename {} |
153 | /// } | 270 | impl 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)] | 275 | pub struct UseTree { |
159 | pub struct RecordFieldDefList { | 276 | pub(crate) syntax: SyntaxNode, |
277 | } | ||
278 | impl 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)] | ||
286 | pub struct Path { | ||
287 | pub(crate) syntax: SyntaxNode, | ||
288 | } | ||
289 | impl 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)] | ||
295 | pub struct UseTreeList { | ||
160 | pub(crate) syntax: SyntaxNode, | 296 | pub(crate) syntax: SyntaxNode, |
161 | } | 297 | } |
162 | impl RecordFieldDefList { | 298 | impl 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 | /// | 304 | pub 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)] | ||
184 | pub struct RecordFieldDef { | ||
185 | pub(crate) syntax: SyntaxNode, | 305 | pub(crate) syntax: SyntaxNode, |
186 | } | 306 | } |
187 | impl ast::VisibilityOwner for RecordFieldDef {} | 307 | impl Abi { |
188 | impl ast::NameOwner for RecordFieldDef {} | 308 | pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) } |
189 | impl ast::AttrsOwner for RecordFieldDef {} | 309 | } |
190 | impl ast::DocCommentsOwner for RecordFieldDef {} | 310 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
191 | impl ast::TypeAscriptionOwner for RecordFieldDef {} | 311 | pub struct GenericParamList { |
192 | impl RecordFieldDef {} | 312 | pub(crate) syntax: SyntaxNode, |
193 | /// Tuple field definition list including enclosing parens. | 313 | } |
194 | /// | 314 | impl 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)] | 320 | pub struct ParamList { |
201 | pub struct TupleFieldDefList { | ||
202 | pub(crate) syntax: SyntaxNode, | 321 | pub(crate) syntax: SyntaxNode, |
203 | } | 322 | } |
204 | impl TupleFieldDefList { | 323 | impl 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)] |
217 | pub struct TupleFieldDef { | 331 | pub struct RetType { |
218 | pub(crate) syntax: SyntaxNode, | 332 | pub(crate) syntax: SyntaxNode, |
219 | } | 333 | } |
220 | impl ast::VisibilityOwner for TupleFieldDef {} | 334 | impl RetType { |
221 | impl ast::AttrsOwner for TupleFieldDef {} | 335 | pub fn thin_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![->]) } |
222 | impl 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. | 339 | pub 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)] | ||
249 | pub struct EnumDef { | ||
250 | pub(crate) syntax: SyntaxNode, | 340 | pub(crate) syntax: SyntaxNode, |
251 | } | 341 | } |
252 | impl ast::VisibilityOwner for EnumDef {} | 342 | impl WhereClause { |
253 | impl ast::NameOwner for EnumDef {} | 343 | pub fn where_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![where]) } |
254 | impl ast::TypeParamsOwner for EnumDef {} | 344 | pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) } |
255 | impl ast::AttrsOwner for EnumDef {} | 345 | } |
256 | impl ast::DocCommentsOwner for EnumDef {} | 346 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
257 | impl EnumDef { | 347 | pub 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)] | ||
278 | pub struct EnumVariantList { | ||
279 | pub(crate) syntax: SyntaxNode, | 348 | pub(crate) syntax: SyntaxNode, |
280 | } | 349 | } |
281 | impl EnumVariantList { | 350 | impl ast::AttrsOwner for BlockExpr {} |
351 | impl ast::ModuleItemOwner for BlockExpr {} | ||
352 | impl 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 | /// | 360 | pub 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)] | ||
302 | pub struct EnumVariant { | ||
303 | pub(crate) syntax: SyntaxNode, | 361 | pub(crate) syntax: SyntaxNode, |
304 | } | 362 | } |
305 | impl ast::VisibilityOwner for EnumVariant {} | 363 | impl ast::AttrsOwner for SelfParam {} |
306 | impl ast::NameOwner for EnumVariant {} | 364 | impl SelfParam { |
307 | impl ast::DocCommentsOwner for EnumVariant {} | 365 | pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) } |
308 | impl ast::AttrsOwner for EnumVariant {} | 366 | pub fn lifetime_token(&self) -> Option<SyntaxToken> { |
309 | impl 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. | 375 | pub 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)] | ||
329 | pub struct TraitDef { | ||
330 | pub(crate) syntax: SyntaxNode, | 376 | pub(crate) syntax: SyntaxNode, |
331 | } | 377 | } |
332 | impl ast::VisibilityOwner for TraitDef {} | 378 | impl ast::AttrsOwner for Param {} |
333 | impl ast::NameOwner for TraitDef {} | 379 | impl Param { |
334 | impl ast::AttrsOwner for TraitDef {} | 380 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } |
335 | impl ast::DocCommentsOwner for TraitDef {} | 381 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } |
336 | impl ast::TypeParamsOwner for TraitDef {} | 382 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
337 | impl ast::TypeBoundsOwner for TraitDef {} | 383 | pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) } |
338 | impl 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)] |
366 | pub struct Module { | 386 | pub struct TypeBoundList { |
367 | pub(crate) syntax: SyntaxNode, | 387 | pub(crate) syntax: SyntaxNode, |
368 | } | 388 | } |
369 | impl ast::VisibilityOwner for Module {} | 389 | impl TypeBoundList { |
370 | impl ast::NameOwner for Module {} | 390 | pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) } |
371 | impl ast::AttrsOwner for Module {} | ||
372 | impl ast::DocCommentsOwner for Module {} | ||
373 | impl 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)] |
401 | pub struct ItemList { | 393 | pub struct RecordFieldList { |
402 | pub(crate) syntax: SyntaxNode, | 394 | pub(crate) syntax: SyntaxNode, |
403 | } | 395 | } |
404 | impl ast::ModuleItemOwner for ItemList {} | 396 | impl RecordFieldList { |
405 | impl 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. | 402 | pub 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)] | ||
423 | pub struct ConstDef { | ||
424 | pub(crate) syntax: SyntaxNode, | 403 | pub(crate) syntax: SyntaxNode, |
425 | } | 404 | } |
426 | impl ast::VisibilityOwner for ConstDef {} | 405 | impl TupleFieldList { |
427 | impl ast::NameOwner for ConstDef {} | 406 | pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } |
428 | impl ast::TypeParamsOwner for ConstDef {} | 407 | pub fn fields(&self) -> AstChildren<TupleField> { support::children(&self.syntax) } |
429 | impl ast::AttrsOwner for ConstDef {} | 408 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } |
430 | impl ast::DocCommentsOwner for ConstDef {} | 409 | } |
431 | impl ast::TypeAscriptionOwner for ConstDef {} | 410 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
432 | impl ConstDef { | 411 | pub 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![=]) } | 414 | impl ast::AttrsOwner for RecordField {} |
436 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } | 415 | impl ast::NameOwner for RecordField {} |
437 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 416 | impl ast::VisibilityOwner for RecordField {} |
417 | impl 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. | 422 | pub 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)] | ||
452 | pub struct StaticDef { | ||
453 | pub(crate) syntax: SyntaxNode, | 423 | pub(crate) syntax: SyntaxNode, |
454 | } | 424 | } |
455 | impl ast::VisibilityOwner for StaticDef {} | 425 | impl ast::AttrsOwner for TupleField {} |
456 | impl ast::NameOwner for StaticDef {} | 426 | impl ast::VisibilityOwner for TupleField {} |
457 | impl ast::TypeParamsOwner for StaticDef {} | 427 | impl TupleField { |
458 | impl ast::AttrsOwner for StaticDef {} | 428 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
459 | impl ast::DocCommentsOwner for StaticDef {} | 429 | } |
460 | impl ast::TypeAscriptionOwner for StaticDef {} | 430 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
461 | impl StaticDef { | 431 | pub 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 | } |
434 | impl 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)] | ||
440 | pub struct Variant { | ||
441 | pub(crate) syntax: SyntaxNode, | ||
442 | } | ||
443 | impl ast::AttrsOwner for Variant {} | ||
444 | impl ast::NameOwner for Variant {} | ||
445 | impl ast::VisibilityOwner for Variant {} | ||
446 | impl 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. | 452 | pub 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)] | ||
487 | pub struct TypeAliasDef { | ||
488 | pub(crate) syntax: SyntaxNode, | 453 | pub(crate) syntax: SyntaxNode, |
489 | } | 454 | } |
490 | impl ast::VisibilityOwner for TypeAliasDef {} | 455 | impl ast::AttrsOwner for AssocItemList {} |
491 | impl ast::NameOwner for TypeAliasDef {} | 456 | impl AssocItemList { |
492 | impl ast::TypeParamsOwner for TypeAliasDef {} | 457 | pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } |
493 | impl ast::AttrsOwner for TypeAliasDef {} | 458 | pub fn assoc_items(&self) -> AstChildren<AssocItem> { support::children(&self.syntax) } |
494 | impl ast::DocCommentsOwner for TypeAliasDef {} | 459 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } |
495 | impl ast::TypeBoundsOwner for TypeAliasDef {} | 460 | } |
496 | impl TypeAliasDef { | 461 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
497 | pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } | 462 | pub struct ExternItemList { |
498 | pub fn type_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![type]) } | 463 | pub(crate) syntax: SyntaxNode, |
464 | } | ||
465 | impl ast::AttrsOwner for ExternItemList {} | ||
466 | impl 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)] | ||
472 | pub struct LifetimeParam { | ||
473 | pub(crate) syntax: SyntaxNode, | ||
474 | } | ||
475 | impl ast::AttrsOwner for LifetimeParam {} | ||
476 | impl 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)] | ||
482 | pub struct TypeParam { | ||
483 | pub(crate) syntax: SyntaxNode, | ||
484 | } | ||
485 | impl ast::AttrsOwner for TypeParam {} | ||
486 | impl ast::NameOwner for TypeParam {} | ||
487 | impl ast::TypeBoundsOwner for TypeParam {} | ||
488 | impl 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. | 493 | pub 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)] | ||
518 | pub struct ImplDef { | ||
519 | pub(crate) syntax: SyntaxNode, | 494 | pub(crate) syntax: SyntaxNode, |
520 | } | 495 | } |
521 | impl ast::TypeParamsOwner for ImplDef {} | 496 | impl ast::AttrsOwner for ConstParam {} |
522 | impl ast::AttrsOwner for ImplDef {} | 497 | impl ast::NameOwner for ConstParam {} |
523 | impl ast::DocCommentsOwner for ImplDef {} | 498 | impl ConstParam { |
524 | impl 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)] | ||
506 | pub struct Literal { | ||
507 | pub(crate) syntax: SyntaxNode, | ||
508 | } | ||
509 | impl Literal {} | ||
510 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
511 | pub struct TokenTree { | ||
512 | pub(crate) syntax: SyntaxNode, | ||
513 | } | ||
514 | impl 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)] |
544 | pub struct ParenType { | 523 | pub struct ParenType { |
545 | pub(crate) syntax: SyntaxNode, | 524 | pub(crate) syntax: SyntaxNode, |
546 | } | 525 | } |
547 | impl ParenType { | 526 | impl 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)] |
560 | pub struct TupleType { | 532 | pub 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)] |
580 | pub struct NeverType { | 541 | pub struct NeverType { |
581 | pub(crate) syntax: SyntaxNode, | 542 | pub(crate) syntax: SyntaxNode, |
@@ -583,17 +544,6 @@ pub struct NeverType { | |||
583 | impl NeverType { | 544 | impl 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)] |
598 | pub struct PathType { | 548 | pub struct PathType { |
599 | pub(crate) syntax: SyntaxNode, | 549 | pub(crate) syntax: SyntaxNode, |
@@ -601,14 +551,6 @@ pub struct PathType { | |||
601 | impl PathType { | 551 | impl 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)] |
613 | pub struct PointerType { | 555 | pub 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)] |
630 | pub struct ArrayType { | 565 | pub struct ArrayType { |
631 | pub(crate) syntax: SyntaxNode, | 566 | pub(crate) syntax: SyntaxNode, |
632 | } | 567 | } |
633 | impl ArrayType { | 568 | impl 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)] |
648 | pub struct SliceType { | 576 | pub struct SliceType { |
649 | pub(crate) syntax: SyntaxNode, | 577 | pub(crate) syntax: SyntaxNode, |
650 | } | 578 | } |
651 | impl SliceType { | 579 | impl 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)] |
664 | pub struct ReferenceType { | 585 | pub 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)] |
683 | pub struct PlaceholderType { | 597 | pub struct PlaceholderType { |
684 | pub(crate) syntax: SyntaxNode, | 598 | pub(crate) syntax: SyntaxNode, |
@@ -686,15 +600,6 @@ pub struct PlaceholderType { | |||
686 | impl PlaceholderType { | 600 | impl 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)] |
699 | pub struct FnPointerType { | 604 | pub 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)] |
717 | pub struct ForType { | 615 | pub struct ForType { |
718 | pub(crate) syntax: SyntaxNode, | 616 | pub(crate) syntax: SyntaxNode, |
719 | } | 617 | } |
720 | impl ForType { | 618 | impl 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)] |
733 | pub struct ImplTraitType { | 624 | pub struct ImplTraitType { |
734 | pub(crate) syntax: SyntaxNode, | 625 | pub(crate) syntax: SyntaxNode, |
735 | } | 626 | } |
736 | impl ast::TypeBoundsOwner for ImplTraitType {} | ||
737 | impl ImplTraitType { | 627 | impl 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)] |
748 | pub struct DynTraitType { | 632 | pub struct DynTraitType { |
749 | pub(crate) syntax: SyntaxNode, | 633 | pub(crate) syntax: SyntaxNode, |
750 | } | 634 | } |
751 | impl ast::TypeBoundsOwner for DynTraitType {} | ||
752 | impl DynTraitType { | 635 | impl 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)] |
763 | pub struct TupleExpr { | 640 | pub 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)] |
782 | pub struct ArrayExpr { | 650 | pub struct ArrayExpr { |
783 | pub(crate) syntax: SyntaxNode, | 651 | pub(crate) syntax: SyntaxNode, |
@@ -786,17 +654,10 @@ impl ast::AttrsOwner for ArrayExpr {} | |||
786 | impl ArrayExpr { | 654 | impl 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)] |
801 | pub struct ParenExpr { | 662 | pub 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)] |
824 | pub struct PathExpr { | 672 | pub struct PathExpr { |
825 | pub(crate) syntax: SyntaxNode, | 673 | pub(crate) syntax: SyntaxNode, |
@@ -827,17 +675,6 @@ pub struct PathExpr { | |||
827 | impl PathExpr { | 675 | impl 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)] |
842 | pub struct LambdaExpr { | 679 | pub 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)] |
874 | pub struct IfExpr { | 692 | pub 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)] |
894 | pub struct LoopExpr { | 701 | pub struct Condition { |
895 | pub(crate) syntax: SyntaxNode, | 702 | pub(crate) syntax: SyntaxNode, |
896 | } | 703 | } |
897 | impl ast::AttrsOwner for LoopExpr {} | 704 | impl Condition { |
898 | impl ast::LoopBodyOwner for LoopExpr {} | 705 | pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) } |
899 | impl 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)] |
917 | pub struct EffectExpr { | 711 | pub 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 | 723 | pub struct Label { |
930 | /// due to ambiguity. | 724 | pub(crate) syntax: SyntaxNode, |
931 | /// | 725 | } |
932 | /// ``` | 726 | impl 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 | /// ``` | 732 | pub struct LoopExpr { |
939 | /// | 733 | pub(crate) syntax: SyntaxNode, |
940 | /// [Reference](https://doc.rust-lang.org/reference/expressions/loop-expr.html#iterator-loops) | 734 | } |
735 | impl ast::AttrsOwner for LoopExpr {} | ||
736 | impl ast::LoopBodyOwner for LoopExpr {} | ||
737 | impl 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)] |
942 | pub struct ForExpr { | 741 | pub 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)] |
970 | pub struct WhileExpr { | 753 | pub 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)] |
996 | pub struct ContinueExpr { | 763 | pub 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)] |
1028 | pub struct BreakExpr { | 776 | pub 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)] | ||
1054 | pub struct Label { | ||
1055 | pub(crate) syntax: SyntaxNode, | ||
1056 | } | ||
1057 | impl 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)] | ||
1078 | pub struct BlockExpr { | ||
1079 | pub(crate) syntax: SyntaxNode, | ||
1080 | } | ||
1081 | impl ast::AttrsOwner for BlockExpr {} | ||
1082 | impl ast::ModuleItemOwner for BlockExpr {} | ||
1083 | impl 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)] |
1102 | pub struct ReturnExpr { | 788 | pub struct ReturnExpr { |
1103 | pub(crate) syntax: SyntaxNode, | 789 | pub(crate) syntax: SyntaxNode, |
1104 | } | 790 | } |
1105 | impl ast::AttrsOwner for ReturnExpr {} | 791 | impl ast::AttrsOwner for ReturnExpr {} |
1106 | impl ReturnExpr { | 792 | impl 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)] |
1120 | pub struct CallExpr { | 797 | pub struct CallExpr { |
1121 | pub(crate) syntax: SyntaxNode, | 798 | pub(crate) syntax: SyntaxNode, |
1122 | } | 799 | } |
800 | impl ast::AttrsOwner for CallExpr {} | ||
1123 | impl ast::ArgListOwner for CallExpr {} | 801 | impl ast::ArgListOwner for CallExpr {} |
1124 | impl CallExpr { | 802 | impl 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 | /// | 806 | pub struct ArgList { |
1129 | /// ``` | 807 | pub(crate) syntax: SyntaxNode, |
1130 | /// ❰ receiver_expr.method() ❱; | 808 | } |
1131 | /// ❰ receiver_expr.method::<T>(42, true) ❱; | 809 | impl 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)] |
1138 | pub struct MethodCallExpr { | 815 | pub 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)] |
1157 | pub struct IndexExpr { | 827 | pub struct TypeArgList { |
1158 | pub(crate) syntax: SyntaxNode, | 828 | pub(crate) syntax: SyntaxNode, |
1159 | } | 829 | } |
1160 | impl ast::AttrsOwner for IndexExpr {} | 830 | impl TypeArgList { |
1161 | impl 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)] |
1175 | pub struct FieldExpr { | 840 | pub 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 | /// | 850 | pub struct IndexExpr { |
1186 | /// ``` | 851 | pub(crate) syntax: SyntaxNode, |
1187 | /// ❰ expr.await ❱; | 852 | } |
1188 | /// ``` | 853 | impl ast::AttrsOwner for IndexExpr {} |
1189 | /// | 854 | impl 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)] |
1192 | pub struct AwaitExpr { | 859 | pub 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)] |
1209 | pub struct TryExpr { | 869 | pub 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)] |
1225 | pub struct CastExpr { | 878 | pub struct CastExpr { |
1226 | pub(crate) syntax: SyntaxNode, | 879 | pub(crate) syntax: SyntaxNode, |
@@ -1229,18 +882,8 @@ impl ast::AttrsOwner for CastExpr {} | |||
1229 | impl CastExpr { | 882 | impl 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)] |
1245 | pub struct RefExpr { | 888 | pub 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)] |
1266 | pub struct PrefixExpr { | 900 | pub struct PrefixExpr { |
1267 | pub(crate) syntax: SyntaxNode, | 901 | pub(crate) syntax: SyntaxNode, |
@@ -1270,13 +904,6 @@ impl ast::AttrsOwner for PrefixExpr {} | |||
1270 | impl PrefixExpr { | 904 | impl 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)] |
1281 | pub struct BoxExpr { | 908 | pub 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)] |
1302 | pub struct RangeExpr { | 917 | pub struct RangeExpr { |
1303 | pub(crate) syntax: SyntaxNode, | 918 | pub(crate) syntax: SyntaxNode, |
1304 | } | 919 | } |
1305 | impl ast::AttrsOwner for RangeExpr {} | 920 | impl ast::AttrsOwner for RangeExpr {} |
1306 | impl RangeExpr {} | 921 | impl 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)] |
1317 | pub struct BinExpr { | 923 | pub struct BinExpr { |
1318 | pub(crate) syntax: SyntaxNode, | 924 | pub(crate) syntax: SyntaxNode, |
1319 | } | 925 | } |
1320 | impl ast::AttrsOwner for BinExpr {} | 926 | impl ast::AttrsOwner for BinExpr {} |
1321 | impl BinExpr {} | 927 | impl 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)] | ||
1336 | pub struct Literal { | ||
1337 | pub(crate) syntax: SyntaxNode, | ||
1338 | } | ||
1339 | impl 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)] |
1353 | pub struct MatchExpr { | 929 | pub 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)] |
1377 | pub struct MatchArmList { | 939 | pub struct MatchArmList { |
1378 | pub(crate) syntax: SyntaxNode, | 940 | pub(crate) syntax: SyntaxNode, |
1379 | } | 941 | } |
1380 | impl ast::AttrsOwner for MatchArmList {} | ||
1381 | impl MatchArmList { | 942 | impl 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)] |
1397 | pub struct MatchArm { | 948 | pub 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)] |
1417 | pub struct MatchGuard { | 959 | pub 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. | 967 | pub 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)] | ||
1440 | pub struct RecordLit { | ||
1441 | pub(crate) syntax: SyntaxNode, | 968 | pub(crate) syntax: SyntaxNode, |
1442 | } | 969 | } |
1443 | impl RecordLit { | 970 | impl 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)] |
1458 | pub struct RecordFieldList { | 977 | pub struct RecordExprFieldList { |
1459 | pub(crate) syntax: SyntaxNode, | 978 | pub(crate) syntax: SyntaxNode, |
1460 | } | 979 | } |
1461 | impl RecordFieldList { | 980 | impl 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)] |
1478 | pub struct RecordField { | 988 | pub struct RecordExprField { |
1479 | pub(crate) syntax: SyntaxNode, | 989 | pub(crate) syntax: SyntaxNode, |
1480 | } | 990 | } |
1481 | impl ast::AttrsOwner for RecordField {} | 991 | impl ast::AttrsOwner for RecordExprField {} |
1482 | impl RecordField { | 992 | impl 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)] |
1495 | pub struct OrPat { | 998 | pub struct OrPat { |
1496 | pub(crate) syntax: SyntaxNode, | 999 | pub(crate) syntax: SyntaxNode, |
@@ -1498,14 +1001,6 @@ pub struct OrPat { | |||
1498 | impl OrPat { | 1001 | impl 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)] |
1510 | pub struct ParenPat { | 1005 | pub 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)] |
1529 | pub struct RefPat { | 1014 | pub 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)] |
1545 | pub struct BoxPat { | 1023 | pub struct BoxPat { |
1546 | pub(crate) syntax: SyntaxNode, | 1024 | pub(crate) syntax: SyntaxNode, |
1547 | } | 1025 | } |
1548 | impl BoxPat { | 1026 | impl 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)] |
1563 | pub struct BindPat { | 1031 | pub 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)] |
1582 | pub struct PlaceholderPat { | 1043 | pub struct PlaceholderPat { |
1583 | pub(crate) syntax: SyntaxNode, | 1044 | pub(crate) syntax: SyntaxNode, |
@@ -1585,16 +1046,6 @@ pub struct PlaceholderPat { | |||
1585 | impl PlaceholderPat { | 1046 | impl 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)] |
1599 | pub struct DotDotPat { | 1050 | pub struct DotDotPat { |
1600 | pub(crate) syntax: SyntaxNode, | 1051 | pub(crate) syntax: SyntaxNode, |
@@ -1602,15 +1053,6 @@ pub struct DotDotPat { | |||
1602 | impl DotDotPat { | 1053 | impl 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)] |
1615 | pub struct PathPat { | 1057 | pub struct PathPat { |
1616 | pub(crate) syntax: SyntaxNode, | 1058 | pub(crate) syntax: SyntaxNode, |
@@ -1618,13 +1060,6 @@ pub struct PathPat { | |||
1618 | impl PathPat { | 1060 | impl 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)] |
1629 | pub struct SlicePat { | 1064 | pub 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)] |
1648 | pub struct RangePat { | 1073 | pub struct RangePat { |
1649 | pub(crate) syntax: SyntaxNode, | 1074 | pub(crate) syntax: SyntaxNode, |
1650 | } | 1075 | } |
1651 | impl RangePat {} | 1076 | impl 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)] |
1665 | pub struct LiteralPat { | 1081 | pub struct LiteralPat { |
1666 | pub(crate) syntax: SyntaxNode, | 1082 | pub(crate) syntax: SyntaxNode, |
@@ -1668,13 +1084,6 @@ pub struct LiteralPat { | |||
1668 | impl LiteralPat { | 1084 | impl 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)] |
1679 | pub struct MacroPat { | 1088 | pub struct MacroPat { |
1680 | pub(crate) syntax: SyntaxNode, | 1089 | pub(crate) syntax: SyntaxNode, |
@@ -1682,37 +1091,22 @@ pub struct MacroPat { | |||
1682 | impl MacroPat { | 1091 | impl 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)] |
1693 | pub struct RecordPat { | 1095 | pub struct RecordPat { |
1694 | pub(crate) syntax: SyntaxNode, | 1096 | pub(crate) syntax: SyntaxNode, |
1695 | } | 1097 | } |
1696 | impl RecordPat { | 1098 | impl 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)] |
1710 | pub struct RecordFieldPatList { | 1105 | pub struct RecordFieldPatList { |
1711 | pub(crate) syntax: SyntaxNode, | 1106 | pub(crate) syntax: SyntaxNode, |
1712 | } | 1107 | } |
1713 | impl RecordFieldPatList { | 1108 | impl 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)] |
1733 | pub struct RecordFieldPat { | 1118 | pub 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)] |
1750 | pub struct TupleStructPat { | 1128 | pub 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)] |
1768 | pub struct TuplePat { | 1138 | pub 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)] | ||
1788 | pub struct Visibility { | ||
1789 | pub(crate) syntax: SyntaxNode, | ||
1790 | } | ||
1791 | impl 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)] | ||
1821 | pub struct Name { | ||
1822 | pub(crate) syntax: SyntaxNode, | ||
1823 | } | ||
1824 | impl 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)] | ||
1837 | pub struct NameRef { | ||
1838 | pub(crate) syntax: SyntaxNode, | ||
1839 | } | ||
1840 | impl 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)] |
1863 | pub struct MacroCall { | 1147 | pub struct MacroDef { |
1864 | pub(crate) syntax: SyntaxNode, | 1148 | pub(crate) syntax: SyntaxNode, |
1865 | } | 1149 | } |
1866 | impl ast::NameOwner for MacroCall {} | 1150 | impl ast::NameOwner for MacroDef {} |
1867 | impl ast::AttrsOwner for MacroCall {} | 1151 | impl MacroDef { |
1868 | impl ast::DocCommentsOwner for MacroCall {} | ||
1869 | impl 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)] | ||
1888 | pub struct Attr { | ||
1889 | pub(crate) syntax: SyntaxNode, | ||
1890 | } | 1153 | } |
1891 | impl 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)] |
1909 | pub struct TokenTree { | 1155 | pub struct MacroItems { |
1910 | pub(crate) syntax: SyntaxNode, | ||
1911 | } | ||
1912 | impl 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)] | ||
1927 | pub struct TypeParamList { | ||
1928 | pub(crate) syntax: SyntaxNode, | ||
1929 | } | ||
1930 | impl 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)] | ||
1946 | pub struct TypeParam { | ||
1947 | pub(crate) syntax: SyntaxNode, | ||
1948 | } | ||
1949 | impl ast::NameOwner for TypeParam {} | ||
1950 | impl ast::AttrsOwner for TypeParam {} | ||
1951 | impl ast::TypeBoundsOwner for TypeParam {} | ||
1952 | impl 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)] | ||
1963 | pub struct ConstParam { | ||
1964 | pub(crate) syntax: SyntaxNode, | 1156 | pub(crate) syntax: SyntaxNode, |
1965 | } | 1157 | } |
1966 | impl ast::NameOwner for ConstParam {} | 1158 | impl ast::ModuleItemOwner for MacroItems {} |
1967 | impl ast::AttrsOwner for ConstParam {} | 1159 | impl MacroItems {} |
1968 | impl ast::TypeAscriptionOwner for ConstParam {} | ||
1969 | impl 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)] |
1981 | pub struct LifetimeParam { | 1161 | pub struct MacroStmts { |
1982 | pub(crate) syntax: SyntaxNode, | 1162 | pub(crate) syntax: SyntaxNode, |
1983 | } | 1163 | } |
1984 | impl ast::AttrsOwner for LifetimeParam {} | 1164 | impl MacroStmts { |
1985 | impl 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)] |
2005 | pub struct TypeBound { | 1169 | pub 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)] | ||
2031 | pub struct TypeBoundList { | ||
2032 | pub(crate) syntax: SyntaxNode, | ||
2033 | } | ||
2034 | impl 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)] |
2050 | pub struct WherePred { | 1180 | pub struct WherePred { |
2051 | pub(crate) syntax: SyntaxNode, | 1181 | pub(crate) syntax: SyntaxNode, |
@@ -2053,64 +1183,12 @@ pub struct WherePred { | |||
2053 | impl ast::TypeBoundsOwner for WherePred {} | 1183 | impl ast::TypeBoundsOwner for WherePred {} |
2054 | impl WherePred { | 1184 | impl 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)] | ||
2071 | pub struct WhereClause { | ||
2072 | pub(crate) syntax: SyntaxNode, | ||
2073 | } | ||
2074 | impl 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)] | ||
2094 | pub struct Abi { | ||
2095 | pub(crate) syntax: SyntaxNode, | ||
2096 | } | ||
2097 | impl 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)] |
2115 | pub struct ExprStmt { | 1193 | pub 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)] |
2134 | pub struct LetStmt { | 1202 | pub struct LetStmt { |
2135 | pub(crate) syntax: SyntaxNode, | 1203 | pub(crate) syntax: SyntaxNode, |
2136 | } | 1204 | } |
2137 | impl ast::AttrsOwner for LetStmt {} | 1205 | impl ast::AttrsOwner for LetStmt {} |
2138 | impl ast::TypeAscriptionOwner for LetStmt {} | ||
2139 | impl LetStmt { | 1206 | impl 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)] | ||
2159 | pub struct Condition { | ||
2160 | pub(crate) syntax: SyntaxNode, | ||
2161 | } | ||
2162 | impl 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)] | ||
2181 | pub struct ParamList { | ||
2182 | pub(crate) syntax: SyntaxNode, | ||
2183 | } | ||
2184 | impl 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)] | ||
2204 | pub struct SelfParam { | ||
2205 | pub(crate) syntax: SyntaxNode, | ||
2206 | } | ||
2207 | impl ast::TypeAscriptionOwner for SelfParam {} | ||
2208 | impl ast::AttrsOwner for SelfParam {} | ||
2209 | impl 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)] | ||
2229 | pub struct Param { | ||
2230 | pub(crate) syntax: SyntaxNode, | ||
2231 | } | ||
2232 | impl ast::TypeAscriptionOwner for Param {} | ||
2233 | impl ast::AttrsOwner for Param {} | ||
2234 | impl 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)] | ||
2249 | pub struct UseItem { | ||
2250 | pub(crate) syntax: SyntaxNode, | ||
2251 | } | ||
2252 | impl ast::AttrsOwner for UseItem {} | ||
2253 | impl ast::VisibilityOwner for UseItem {} | ||
2254 | impl 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)] | ||
2269 | pub struct UseTree { | ||
2270 | pub(crate) syntax: SyntaxNode, | ||
2271 | } | ||
2272 | impl 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)] | ||
2289 | pub struct Alias { | ||
2290 | pub(crate) syntax: SyntaxNode, | ||
2291 | } | ||
2292 | impl ast::NameOwner for Alias {} | ||
2293 | impl 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)] | ||
2305 | pub struct UseTreeList { | ||
2306 | pub(crate) syntax: SyntaxNode, | ||
2307 | } | ||
2308 | impl 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)] | ||
2322 | pub struct ExternCrateItem { | ||
2323 | pub(crate) syntax: SyntaxNode, | ||
2324 | } | ||
2325 | impl ast::AttrsOwner for ExternCrateItem {} | ||
2326 | impl ast::VisibilityOwner for ExternCrateItem {} | ||
2327 | impl 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)] | ||
2341 | pub struct ArgList { | ||
2342 | pub(crate) syntax: SyntaxNode, | ||
2343 | } | ||
2344 | impl 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)] | ||
2361 | pub struct Path { | ||
2362 | pub(crate) syntax: SyntaxNode, | ||
2363 | } | ||
2364 | impl 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)] |
2385 | pub struct PathSegment { | 1216 | pub 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)] |
2411 | pub struct TypeArgList { | 1233 | pub struct TypeArg { |
2412 | pub(crate) syntax: SyntaxNode, | 1234 | pub(crate) syntax: SyntaxNode, |
2413 | } | 1235 | } |
2414 | impl TypeArgList { | 1236 | impl 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)] |
2432 | pub struct TypeArg { | 1240 | pub struct LifetimeArg { |
2433 | pub(crate) syntax: SyntaxNode, | 1241 | pub(crate) syntax: SyntaxNode, |
2434 | } | 1242 | } |
2435 | impl TypeArg { | 1243 | impl 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)] |
2446 | pub struct AssocTypeArg { | 1249 | pub 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)] | ||
2465 | pub struct LifetimeArg { | ||
2466 | pub(crate) syntax: SyntaxNode, | ||
2467 | } | ||
2468 | impl 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)] |
2483 | pub struct ConstArg { | 1259 | pub 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)] | ||
2495 | pub struct MacroItems { | ||
2496 | pub(crate) syntax: SyntaxNode, | ||
2497 | } | ||
2498 | impl ast::ModuleItemOwner for MacroItems {} | ||
2499 | impl 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)] | ||
2509 | pub struct MacroStmts { | ||
2510 | pub(crate) syntax: SyntaxNode, | ||
2511 | } | ||
2512 | impl 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)] | ||
2529 | pub struct ExternItemList { | ||
2530 | pub(crate) syntax: SyntaxNode, | ||
2531 | } | ||
2532 | impl ast::ModuleItemOwner for ExternItemList {} | ||
2533 | impl 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)] | ||
2551 | pub struct ExternBlock { | ||
2552 | pub(crate) syntax: SyntaxNode, | ||
2553 | } | ||
2554 | impl 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)] | ||
2568 | pub struct MetaItem { | ||
2569 | pub(crate) syntax: SyntaxNode, | ||
2570 | } | ||
2571 | impl 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)] | ||
2587 | pub struct MacroDef { | ||
2588 | pub(crate) syntax: SyntaxNode, | ||
2589 | } | ||
2590 | impl 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)] |
2596 | pub enum NominalDef { | 1267 | pub enum Item { |
2597 | StructDef(StructDef), | 1268 | Const(Const), |
2598 | EnumDef(EnumDef), | 1269 | Enum(Enum), |
2599 | UnionDef(UnionDef), | 1270 | ExternBlock(ExternBlock), |
2600 | } | 1271 | ExternCrate(ExternCrate), |
2601 | impl ast::NameOwner for NominalDef {} | 1272 | Fn(Fn), |
2602 | impl ast::TypeParamsOwner for NominalDef {} | 1273 | Impl(Impl), |
2603 | impl 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), |
2606 | pub 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)] | ||
2613 | pub 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 | 1283 | impl ast::AttrsOwner for Item {} |
2620 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1284 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
2621 | pub enum TypeRef { | 1285 | pub 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)] | ||
2638 | pub 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 | } | ||
2654 | impl ast::NameOwner for ModuleItem {} | ||
2655 | impl ast::AttrsOwner for ModuleItem {} | ||
2656 | impl 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)] |
2661 | pub enum AssocItem { | 1301 | pub 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 | } |
2666 | impl ast::NameOwner for AssocItem {} | ||
2667 | impl 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)] |
2672 | pub enum ExternItem { | 1319 | pub enum FieldList { |
2673 | FnDef(FnDef), | 1320 | RecordFieldList(RecordFieldList), |
2674 | StaticDef(StaticDef), | 1321 | TupleFieldList(TupleFieldList), |
2675 | } | 1322 | } |
2676 | impl ast::NameOwner for ExternItem {} | ||
2677 | impl ast::AttrsOwner for ExternItem {} | ||
2678 | impl ast::VisibilityOwner for ExternItem {} | ||
2679 | /// Any kind of expression | ||
2680 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1323 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
2681 | pub enum Expr { | 1324 | pub 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 | } |
2714 | impl ast::AttrsOwner for Expr {} | ||
2715 | /// Any kind of pattern | ||
2716 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1357 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
2717 | pub enum Pat { | 1358 | pub 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 | 1364 | impl ast::AttrsOwner for AssocItem {} |
2735 | /// braces of a record pattern | 1365 | impl ast::NameOwner for AssocItem {} |
2736 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1366 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
2737 | pub enum RecordInnerPat { | 1367 | pub 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 | 1372 | impl ast::AttrsOwner for ExternItem {} |
1373 | impl ast::NameOwner for ExternItem {} | ||
2742 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1374 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
2743 | pub enum AttrInput { | 1375 | pub enum GenericParam { |
2744 | Literal(Literal), | 1376 | LifetimeParam(LifetimeParam), |
2745 | TokenTree(TokenTree), | 1377 | TypeParam(TypeParam), |
1378 | ConstParam(ConstParam), | ||
2746 | } | 1379 | } |
2747 | /// Any kind of statement | 1380 | impl 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)] |
2751 | pub enum Stmt { | 1382 | pub 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) | 1386 | impl ast::AttrsOwner for Stmt {} |
2756 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1387 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
2757 | pub enum FieldDefList { | 1388 | pub enum AdtDef { |
2758 | RecordFieldDefList(RecordFieldDefList), | 1389 | Struct(Struct), |
2759 | TupleFieldDefList(TupleFieldDefList), | 1390 | Enum(Enum), |
1391 | Union(Union), | ||
2760 | } | 1392 | } |
1393 | impl ast::AttrsOwner for AdtDef {} | ||
1394 | impl ast::GenericParamsOwner for AdtDef {} | ||
1395 | impl ast::NameOwner for AdtDef {} | ||
1396 | impl ast::VisibilityOwner for AdtDef {} | ||
2761 | impl AstNode for SourceFile { | 1397 | impl 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 | } |
2772 | impl AstNode for FnDef { | 1408 | impl 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 | } |
2783 | impl AstNode for RetType { | 1419 | impl 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 | } |
2794 | impl AstNode for StructDef { | 1430 | impl 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 | } |
2805 | impl AstNode for UnionDef { | 1441 | impl 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 | } |
2816 | impl AstNode for RecordFieldDefList { | 1452 | impl 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 | } |
2827 | impl AstNode for RecordFieldDef { | 1463 | impl 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 | } |
2838 | impl AstNode for TupleFieldDefList { | 1474 | impl 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 | } |
2849 | impl AstNode for TupleFieldDef { | 1485 | impl 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 | } |
2860 | impl AstNode for EnumDef { | 1496 | impl 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 | } |
2871 | impl AstNode for EnumVariantList { | 1507 | impl 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 | } |
2882 | impl AstNode for EnumVariant { | 1518 | impl 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 | } |
2893 | impl AstNode for TraitDef { | 1529 | impl 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 | } |
2904 | impl AstNode for Module { | 1540 | impl 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 | } |
2915 | impl AstNode for ItemList { | 1551 | impl 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 | } |
2926 | impl AstNode for ConstDef { | 1562 | impl 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 | } |
2937 | impl AstNode for StaticDef { | 1573 | impl 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 | } |
2948 | impl AstNode for TypeAliasDef { | 1584 | impl 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 | } |
2959 | impl AstNode for ImplDef { | 1595 | impl 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 | } |
2970 | impl AstNode for ParenType { | 1606 | impl 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 | } |
2981 | impl AstNode for TupleType { | 1617 | impl 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 | } |
2992 | impl AstNode for NeverType { | 1628 | impl 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 | } |
3003 | impl AstNode for PathType { | 1639 | impl 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 | } |
3014 | impl AstNode for PointerType { | 1650 | impl 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 | } |
3025 | impl AstNode for ArrayType { | 1661 | impl 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 | } |
3036 | impl AstNode for SliceType { | 1672 | impl 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 | } |
3047 | impl AstNode for ReferenceType { | 1683 | impl 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 | } |
3058 | impl AstNode for PlaceholderType { | 1694 | impl 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 | } |
3069 | impl AstNode for FnPointerType { | 1705 | impl 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 | } |
3080 | impl AstNode for ForType { | 1716 | impl 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 | } |
3091 | impl AstNode for ImplTraitType { | 1727 | impl 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 | } |
3102 | impl AstNode for DynTraitType { | 1738 | impl 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 | } |
3113 | impl AstNode for TupleExpr { | 1749 | impl 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 | } |
3124 | impl AstNode for ArrayExpr { | 1760 | impl 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 | } |
3135 | impl AstNode for ParenExpr { | 1771 | impl 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 | } |
3146 | impl AstNode for PathExpr { | 1782 | impl 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 | } |
3157 | impl AstNode for LambdaExpr { | 1793 | impl 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 | } |
3168 | impl AstNode for IfExpr { | 1804 | impl 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 | } |
3179 | impl AstNode for LoopExpr { | 1815 | impl 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 | } |
3190 | impl AstNode for EffectExpr { | 1826 | impl 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 | } |
3201 | impl AstNode for ForExpr { | 1837 | impl 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 | } |
3212 | impl AstNode for WhileExpr { | 1848 | impl 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 | } |
3223 | impl AstNode for ContinueExpr { | 1859 | impl 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 | } |
3234 | impl AstNode for BreakExpr { | 1870 | impl 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 | } |
3245 | impl AstNode for Label { | 1881 | impl 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 | } |
3256 | impl AstNode for BlockExpr { | 1892 | impl 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 | } |
3267 | impl AstNode for ReturnExpr { | 1903 | impl 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 | } |
3278 | impl AstNode for CallExpr { | 1914 | impl 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 | } |
3289 | impl AstNode for MethodCallExpr { | 1925 | impl 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 | } |
3300 | impl AstNode for IndexExpr { | 1936 | impl 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 | } |
3311 | impl AstNode for FieldExpr { | 1947 | impl 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 | } |
3322 | impl AstNode for AwaitExpr { | 1958 | impl 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 | } |
3333 | impl AstNode for TryExpr { | 1969 | impl 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 | } |
3344 | impl AstNode for CastExpr { | 1980 | impl 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 | } |
3355 | impl AstNode for RefExpr { | 1991 | impl 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 | } |
3366 | impl AstNode for PrefixExpr { | 2002 | impl 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 | } |
3377 | impl AstNode for BoxExpr { | 2013 | impl 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 | } |
3388 | impl AstNode for RangeExpr { | 2024 | impl 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 | } |
3399 | impl AstNode for BinExpr { | 2035 | impl 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 | } |
3410 | impl AstNode for Literal { | 2046 | impl 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 | } |
3421 | impl AstNode for MatchExpr { | 2057 | impl 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 | } |
3432 | impl AstNode for MatchArmList { | 2068 | impl 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 | } |
3443 | impl AstNode for MatchArm { | 2079 | impl 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 | } |
3454 | impl AstNode for MatchGuard { | 2090 | impl 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 | } |
3465 | impl AstNode for RecordLit { | 2101 | impl 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 | } |
3476 | impl AstNode for RecordFieldList { | 2112 | impl 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 | } |
3487 | impl AstNode for RecordField { | 2123 | impl 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 | } |
3498 | impl AstNode for OrPat { | 2134 | impl 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 | } |
3509 | impl AstNode for ParenPat { | 2145 | impl 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 | } |
3520 | impl AstNode for RefPat { | 2156 | impl 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 | } |
3531 | impl AstNode for BoxPat { | 2167 | impl 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 | } |
3542 | impl AstNode for BindPat { | 2178 | impl 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 | } |
3553 | impl AstNode for PlaceholderPat { | 2189 | impl 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 | } |
3564 | impl AstNode for DotDotPat { | 2200 | impl 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 | } |
3575 | impl AstNode for PathPat { | 2211 | impl 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 | } |
3586 | impl AstNode for SlicePat { | 2222 | impl 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 | } |
3597 | impl AstNode for RangePat { | 2233 | impl 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 | } |
3608 | impl AstNode for LiteralPat { | 2244 | impl 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 | } |
3619 | impl AstNode for MacroPat { | 2255 | impl 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 | } |
3630 | impl AstNode for RecordPat { | 2266 | impl 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 | } |
3641 | impl AstNode for RecordFieldPatList { | 2277 | impl 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 | } |
3652 | impl AstNode for RecordFieldPat { | 2288 | impl 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 | } |
3663 | impl AstNode for TupleStructPat { | 2299 | impl 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 | } |
3674 | impl AstNode for TuplePat { | 2310 | impl 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 | } |
3685 | impl AstNode for Visibility { | 2321 | impl 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 | } |
3696 | impl AstNode for Name { | 2332 | impl 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 | } |
3707 | impl AstNode for NameRef { | 2343 | impl 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 | } |
3718 | impl AstNode for MacroCall { | 2354 | impl 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 | } |
3729 | impl AstNode for Attr { | 2365 | impl 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 | } |
3740 | impl AstNode for TokenTree { | 2376 | impl 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 | } |
3751 | impl AstNode for TypeParamList { | 2387 | impl 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 | } |
3762 | impl AstNode for TypeParam { | 2398 | impl 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 | } |
3773 | impl AstNode for ConstParam { | 2409 | impl 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 | } |
3784 | impl AstNode for LifetimeParam { | 2420 | impl 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 | } |
3795 | impl AstNode for TypeBound { | 2431 | impl 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 | } |
3806 | impl AstNode for TypeBoundList { | 2442 | impl 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 | } |
3817 | impl AstNode for WherePred { | 2453 | impl 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 | } |
3828 | impl AstNode for WhereClause { | 2464 | impl 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 | } |
3839 | impl AstNode for Abi { | 2475 | impl 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 | } |
3850 | impl AstNode for ExprStmt { | 2486 | impl 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 | } |
3861 | impl AstNode for LetStmt { | 2497 | impl 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 | } |
3872 | impl AstNode for Condition { | 2508 | impl 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 | } |
3883 | impl AstNode for ParamList { | 2519 | impl 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 | } |
3894 | impl AstNode for SelfParam { | 2530 | impl 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 | } |
3905 | impl AstNode for Param { | 2541 | impl 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 | } |
3916 | impl AstNode for UseItem { | 2552 | impl 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 | } |
3927 | impl AstNode for UseTree { | 2563 | impl 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 | } |
3938 | impl AstNode for Alias { | 2574 | impl 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 | } |
3949 | impl AstNode for UseTreeList { | 2585 | impl 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 | } |
3960 | impl AstNode for ExternCrateItem { | 2596 | impl 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 | } |
3971 | impl AstNode for ArgList { | 2607 | impl 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 | } |
3982 | impl AstNode for Path { | 2618 | impl 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> { |
3985 | if Self::can_cast(syntax.kind()) { | 2621 | if Self::can_cast(syntax.kind()) { |
3986 | Some(Self { syntax }) | 2622 | Some(Self { syntax }) |
@@ -3990,8 +2626,8 @@ impl AstNode for Path { | |||
3990 | } | 2626 | } |
3991 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2627 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
3992 | } | 2628 | } |
3993 | impl AstNode for PathSegment { | 2629 | impl AstNode for MacroDef { |
3994 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT } | 2630 | fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_DEF } |
3995 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2631 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
3996 | if Self::can_cast(syntax.kind()) { | 2632 | if Self::can_cast(syntax.kind()) { |
3997 | Some(Self { syntax }) | 2633 | Some(Self { syntax }) |
@@ -4001,8 +2637,8 @@ impl AstNode for PathSegment { | |||
4001 | } | 2637 | } |
4002 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2638 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
4003 | } | 2639 | } |
4004 | impl AstNode for TypeArgList { | 2640 | impl AstNode for MacroItems { |
4005 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG_LIST } | 2641 | fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_ITEMS } |
4006 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2642 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
4007 | if Self::can_cast(syntax.kind()) { | 2643 | if Self::can_cast(syntax.kind()) { |
4008 | Some(Self { syntax }) | 2644 | Some(Self { syntax }) |
@@ -4012,8 +2648,8 @@ impl AstNode for TypeArgList { | |||
4012 | } | 2648 | } |
4013 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2649 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
4014 | } | 2650 | } |
4015 | impl AstNode for TypeArg { | 2651 | impl AstNode for MacroStmts { |
4016 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG } | 2652 | fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_STMTS } |
4017 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2653 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
4018 | if Self::can_cast(syntax.kind()) { | 2654 | if Self::can_cast(syntax.kind()) { |
4019 | Some(Self { syntax }) | 2655 | Some(Self { syntax }) |
@@ -4023,8 +2659,8 @@ impl AstNode for TypeArg { | |||
4023 | } | 2659 | } |
4024 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2660 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
4025 | } | 2661 | } |
4026 | impl AstNode for AssocTypeArg { | 2662 | impl AstNode for TypeBound { |
4027 | fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_TYPE_ARG } | 2663 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND } |
4028 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2664 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
4029 | if Self::can_cast(syntax.kind()) { | 2665 | if Self::can_cast(syntax.kind()) { |
4030 | Some(Self { syntax }) | 2666 | Some(Self { syntax }) |
@@ -4034,8 +2670,8 @@ impl AstNode for AssocTypeArg { | |||
4034 | } | 2670 | } |
4035 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2671 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
4036 | } | 2672 | } |
4037 | impl AstNode for LifetimeArg { | 2673 | impl AstNode for WherePred { |
4038 | fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_ARG } | 2674 | fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_PRED } |
4039 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2675 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
4040 | if Self::can_cast(syntax.kind()) { | 2676 | if Self::can_cast(syntax.kind()) { |
4041 | Some(Self { syntax }) | 2677 | Some(Self { syntax }) |
@@ -4045,8 +2681,8 @@ impl AstNode for LifetimeArg { | |||
4045 | } | 2681 | } |
4046 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2682 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
4047 | } | 2683 | } |
4048 | impl AstNode for ConstArg { | 2684 | impl AstNode for ExprStmt { |
4049 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_ARG } | 2685 | fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_STMT } |
4050 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2686 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
4051 | if Self::can_cast(syntax.kind()) { | 2687 | if Self::can_cast(syntax.kind()) { |
4052 | Some(Self { syntax }) | 2688 | Some(Self { syntax }) |
@@ -4056,8 +2692,8 @@ impl AstNode for ConstArg { | |||
4056 | } | 2692 | } |
4057 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2693 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
4058 | } | 2694 | } |
4059 | impl AstNode for MacroItems { | 2695 | impl AstNode for LetStmt { |
4060 | fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_ITEMS } | 2696 | fn can_cast(kind: SyntaxKind) -> bool { kind == LET_STMT } |
4061 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2697 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
4062 | if Self::can_cast(syntax.kind()) { | 2698 | if Self::can_cast(syntax.kind()) { |
4063 | Some(Self { syntax }) | 2699 | Some(Self { syntax }) |
@@ -4067,8 +2703,8 @@ impl AstNode for MacroItems { | |||
4067 | } | 2703 | } |
4068 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2704 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
4069 | } | 2705 | } |
4070 | impl AstNode for MacroStmts { | 2706 | impl AstNode for PathSegment { |
4071 | fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_STMTS } | 2707 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT } |
4072 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2708 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
4073 | if Self::can_cast(syntax.kind()) { | 2709 | if Self::can_cast(syntax.kind()) { |
4074 | Some(Self { syntax }) | 2710 | Some(Self { syntax }) |
@@ -4078,8 +2714,8 @@ impl AstNode for MacroStmts { | |||
4078 | } | 2714 | } |
4079 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2715 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
4080 | } | 2716 | } |
4081 | impl AstNode for ExternItemList { | 2717 | impl AstNode for TypeArg { |
4082 | fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_ITEM_LIST } | 2718 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG } |
4083 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2719 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
4084 | if Self::can_cast(syntax.kind()) { | 2720 | if Self::can_cast(syntax.kind()) { |
4085 | Some(Self { syntax }) | 2721 | Some(Self { syntax }) |
@@ -4089,8 +2725,8 @@ impl AstNode for ExternItemList { | |||
4089 | } | 2725 | } |
4090 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2726 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
4091 | } | 2727 | } |
4092 | impl AstNode for ExternBlock { | 2728 | impl AstNode for LifetimeArg { |
4093 | fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_BLOCK } | 2729 | fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_ARG } |
4094 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2730 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
4095 | if Self::can_cast(syntax.kind()) { | 2731 | if Self::can_cast(syntax.kind()) { |
4096 | Some(Self { syntax }) | 2732 | Some(Self { syntax }) |
@@ -4100,8 +2736,8 @@ impl AstNode for ExternBlock { | |||
4100 | } | 2736 | } |
4101 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2737 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
4102 | } | 2738 | } |
4103 | impl AstNode for MetaItem { | 2739 | impl AstNode for AssocTypeArg { |
4104 | fn can_cast(kind: SyntaxKind) -> bool { kind == META_ITEM } | 2740 | fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_TYPE_ARG } |
4105 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2741 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
4106 | if Self::can_cast(syntax.kind()) { | 2742 | if Self::can_cast(syntax.kind()) { |
4107 | Some(Self { syntax }) | 2743 | Some(Self { syntax }) |
@@ -4111,8 +2747,8 @@ impl AstNode for MetaItem { | |||
4111 | } | 2747 | } |
4112 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2748 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
4113 | } | 2749 | } |
4114 | impl AstNode for MacroDef { | 2750 | impl AstNode for ConstArg { |
4115 | fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_DEF } | 2751 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_ARG } |
4116 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2752 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
4117 | if Self::can_cast(syntax.kind()) { | 2753 | if Self::can_cast(syntax.kind()) { |
4118 | Some(Self { syntax }) | 2754 | Some(Self { syntax }) |
@@ -4122,107 +2758,92 @@ impl AstNode for MacroDef { | |||
4122 | } | 2758 | } |
4123 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2759 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
4124 | } | 2760 | } |
4125 | impl From<StructDef> for NominalDef { | 2761 | impl From<Const> for Item { |
4126 | fn from(node: StructDef) -> NominalDef { NominalDef::StructDef(node) } | 2762 | fn from(node: Const) -> Item { Item::Const(node) } |
4127 | } | 2763 | } |
4128 | impl From<EnumDef> for NominalDef { | 2764 | impl From<Enum> for Item { |
4129 | fn from(node: EnumDef) -> NominalDef { NominalDef::EnumDef(node) } | 2765 | fn from(node: Enum) -> Item { Item::Enum(node) } |
4130 | } | 2766 | } |
4131 | impl From<UnionDef> for NominalDef { | 2767 | impl From<ExternBlock> for Item { |
4132 | fn from(node: UnionDef) -> NominalDef { NominalDef::UnionDef(node) } | 2768 | fn from(node: ExternBlock) -> Item { Item::ExternBlock(node) } |
4133 | } | 2769 | } |
4134 | impl AstNode for NominalDef { | 2770 | impl From<ExternCrate> for Item { |
4135 | fn can_cast(kind: SyntaxKind) -> bool { | 2771 | fn from(node: ExternCrate) -> Item { Item::ExternCrate(node) } |
4136 | match kind { | ||
4137 | STRUCT_DEF | ENUM_DEF | UNION_DEF => true, | ||
4138 | _ => false, | ||
4139 | } | ||
4140 | } | ||
4141 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4142 | let res = match syntax.kind() { | ||
4143 | STRUCT_DEF => NominalDef::StructDef(StructDef { syntax }), | ||
4144 | ENUM_DEF => NominalDef::EnumDef(EnumDef { syntax }), | ||
4145 | UNION_DEF => NominalDef::UnionDef(UnionDef { syntax }), | ||
4146 | _ => return None, | ||
4147 | }; | ||
4148 | Some(res) | ||
4149 | } | ||
4150 | fn syntax(&self) -> &SyntaxNode { | ||
4151 | match self { | ||
4152 | NominalDef::StructDef(it) => &it.syntax, | ||
4153 | NominalDef::EnumDef(it) => &it.syntax, | ||
4154 | NominalDef::UnionDef(it) => &it.syntax, | ||
4155 | } | ||
4156 | } | ||
4157 | } | 2772 | } |
4158 | impl From<LifetimeParam> for GenericParam { | 2773 | impl From<Fn> for Item { |
4159 | fn from(node: LifetimeParam) -> GenericParam { GenericParam::LifetimeParam(node) } | 2774 | fn from(node: Fn) -> Item { Item::Fn(node) } |
4160 | } | 2775 | } |
4161 | impl From<TypeParam> for GenericParam { | 2776 | impl From<Impl> for Item { |
4162 | fn from(node: TypeParam) -> GenericParam { GenericParam::TypeParam(node) } | 2777 | fn from(node: Impl) -> Item { Item::Impl(node) } |
4163 | } | 2778 | } |
4164 | impl From<ConstParam> for GenericParam { | 2779 | impl From<MacroCall> for Item { |
4165 | fn from(node: ConstParam) -> GenericParam { GenericParam::ConstParam(node) } | 2780 | fn from(node: MacroCall) -> Item { Item::MacroCall(node) } |
4166 | } | 2781 | } |
4167 | impl AstNode for GenericParam { | 2782 | impl From<Module> for Item { |
4168 | fn can_cast(kind: SyntaxKind) -> bool { | 2783 | fn from(node: Module) -> Item { Item::Module(node) } |
4169 | match kind { | 2784 | } |
4170 | LIFETIME_PARAM | TYPE_PARAM | CONST_PARAM => true, | 2785 | impl From<Static> for Item { |
4171 | _ => false, | 2786 | fn from(node: Static) -> Item { Item::Static(node) } |
4172 | } | 2787 | } |
4173 | } | 2788 | impl From<Struct> for Item { |
4174 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2789 | fn from(node: Struct) -> Item { Item::Struct(node) } |
4175 | let res = match syntax.kind() { | ||
4176 | LIFETIME_PARAM => GenericParam::LifetimeParam(LifetimeParam { syntax }), | ||
4177 | TYPE_PARAM => GenericParam::TypeParam(TypeParam { syntax }), | ||
4178 | CONST_PARAM => GenericParam::ConstParam(ConstParam { syntax }), | ||
4179 | _ => return None, | ||
4180 | }; | ||
4181 | Some(res) | ||
4182 | } | ||
4183 | fn syntax(&self) -> &SyntaxNode { | ||
4184 | match self { | ||
4185 | GenericParam::LifetimeParam(it) => &it.syntax, | ||
4186 | GenericParam::TypeParam(it) => &it.syntax, | ||
4187 | GenericParam::ConstParam(it) => &it.syntax, | ||
4188 | } | ||
4189 | } | ||
4190 | } | 2790 | } |
4191 | impl From<LifetimeArg> for GenericArg { | 2791 | impl From<Trait> for Item { |
4192 | fn from(node: LifetimeArg) -> GenericArg { GenericArg::LifetimeArg(node) } | 2792 | fn from(node: Trait) -> Item { Item::Trait(node) } |
4193 | } | 2793 | } |
4194 | impl From<TypeArg> for GenericArg { | 2794 | impl From<TypeAlias> for Item { |
4195 | fn from(node: TypeArg) -> GenericArg { GenericArg::TypeArg(node) } | 2795 | fn from(node: TypeAlias) -> Item { Item::TypeAlias(node) } |
4196 | } | 2796 | } |
4197 | impl From<ConstArg> for GenericArg { | 2797 | impl From<Union> for Item { |
4198 | fn from(node: ConstArg) -> GenericArg { GenericArg::ConstArg(node) } | 2798 | fn from(node: Union) -> Item { Item::Union(node) } |
4199 | } | 2799 | } |
4200 | impl From<AssocTypeArg> for GenericArg { | 2800 | impl From<Use> for Item { |
4201 | fn from(node: AssocTypeArg) -> GenericArg { GenericArg::AssocTypeArg(node) } | 2801 | fn from(node: Use) -> Item { Item::Use(node) } |
4202 | } | 2802 | } |
4203 | impl AstNode for GenericArg { | 2803 | impl AstNode for Item { |
4204 | fn can_cast(kind: SyntaxKind) -> bool { | 2804 | fn can_cast(kind: SyntaxKind) -> bool { |
4205 | match kind { | 2805 | match kind { |
4206 | LIFETIME_ARG | TYPE_ARG | CONST_ARG | ASSOC_TYPE_ARG => true, | 2806 | CONST | ENUM | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL | MACRO_CALL | MODULE |
2807 | | STATIC | STRUCT | TRAIT | TYPE_ALIAS | UNION | USE => true, | ||
4207 | _ => false, | 2808 | _ => false, |
4208 | } | 2809 | } |
4209 | } | 2810 | } |
4210 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2811 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
4211 | let res = match syntax.kind() { | 2812 | let res = match syntax.kind() { |
4212 | LIFETIME_ARG => GenericArg::LifetimeArg(LifetimeArg { syntax }), | 2813 | CONST => Item::Const(Const { syntax }), |
4213 | TYPE_ARG => GenericArg::TypeArg(TypeArg { syntax }), | 2814 | ENUM => Item::Enum(Enum { syntax }), |
4214 | CONST_ARG => GenericArg::ConstArg(ConstArg { syntax }), | 2815 | EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }), |
4215 | ASSOC_TYPE_ARG => GenericArg::AssocTypeArg(AssocTypeArg { syntax }), | 2816 | EXTERN_CRATE => Item::ExternCrate(ExternCrate { syntax }), |
2817 | FN => Item::Fn(Fn { syntax }), | ||
2818 | IMPL => Item::Impl(Impl { syntax }), | ||
2819 | MACRO_CALL => Item::MacroCall(MacroCall { syntax }), | ||
2820 | MODULE => Item::Module(Module { syntax }), | ||
2821 | STATIC => Item::Static(Static { syntax }), | ||
2822 | STRUCT => Item::Struct(Struct { syntax }), | ||
2823 | TRAIT => Item::Trait(Trait { syntax }), | ||
2824 | TYPE_ALIAS => Item::TypeAlias(TypeAlias { syntax }), | ||
2825 | UNION => Item::Union(Union { syntax }), | ||
2826 | USE => Item::Use(Use { syntax }), | ||
4216 | _ => return None, | 2827 | _ => return None, |
4217 | }; | 2828 | }; |
4218 | Some(res) | 2829 | Some(res) |
4219 | } | 2830 | } |
4220 | fn syntax(&self) -> &SyntaxNode { | 2831 | fn syntax(&self) -> &SyntaxNode { |
4221 | match self { | 2832 | match self { |
4222 | GenericArg::LifetimeArg(it) => &it.syntax, | 2833 | Item::Const(it) => &it.syntax, |
4223 | GenericArg::TypeArg(it) => &it.syntax, | 2834 | Item::Enum(it) => &it.syntax, |
4224 | GenericArg::ConstArg(it) => &it.syntax, | 2835 | Item::ExternBlock(it) => &it.syntax, |
4225 | GenericArg::AssocTypeArg(it) => &it.syntax, | 2836 | Item::ExternCrate(it) => &it.syntax, |
2837 | Item::Fn(it) => &it.syntax, | ||
2838 | Item::Impl(it) => &it.syntax, | ||
2839 | Item::MacroCall(it) => &it.syntax, | ||
2840 | Item::Module(it) => &it.syntax, | ||
2841 | Item::Static(it) => &it.syntax, | ||
2842 | Item::Struct(it) => &it.syntax, | ||
2843 | Item::Trait(it) => &it.syntax, | ||
2844 | Item::TypeAlias(it) => &it.syntax, | ||
2845 | Item::Union(it) => &it.syntax, | ||
2846 | Item::Use(it) => &it.syntax, | ||
4226 | } | 2847 | } |
4227 | } | 2848 | } |
4228 | } | 2849 | } |
@@ -4311,154 +2932,126 @@ impl AstNode for TypeRef { | |||
4311 | } | 2932 | } |
4312 | } | 2933 | } |
4313 | } | 2934 | } |
4314 | impl From<StructDef> for ModuleItem { | 2935 | impl From<OrPat> for Pat { |
4315 | fn from(node: StructDef) -> ModuleItem { ModuleItem::StructDef(node) } | 2936 | fn from(node: OrPat) -> Pat { Pat::OrPat(node) } |
4316 | } | ||
4317 | impl From<UnionDef> for ModuleItem { | ||
4318 | fn from(node: UnionDef) -> ModuleItem { ModuleItem::UnionDef(node) } | ||
4319 | } | ||
4320 | impl From<EnumDef> for ModuleItem { | ||
4321 | fn from(node: EnumDef) -> ModuleItem { ModuleItem::EnumDef(node) } | ||
4322 | } | ||
4323 | impl From<FnDef> for ModuleItem { | ||
4324 | fn from(node: FnDef) -> ModuleItem { ModuleItem::FnDef(node) } | ||
4325 | } | 2937 | } |
4326 | impl From<TraitDef> for ModuleItem { | 2938 | impl From<ParenPat> for Pat { |
4327 | fn from(node: TraitDef) -> ModuleItem { ModuleItem::TraitDef(node) } | 2939 | fn from(node: ParenPat) -> Pat { Pat::ParenPat(node) } |
4328 | } | 2940 | } |
4329 | impl From<TypeAliasDef> for ModuleItem { | 2941 | impl From<RefPat> for Pat { |
4330 | fn from(node: TypeAliasDef) -> ModuleItem { ModuleItem::TypeAliasDef(node) } | 2942 | fn from(node: RefPat) -> Pat { Pat::RefPat(node) } |
4331 | } | 2943 | } |
4332 | impl From<ImplDef> for ModuleItem { | 2944 | impl From<BoxPat> for Pat { |
4333 | fn from(node: ImplDef) -> ModuleItem { ModuleItem::ImplDef(node) } | 2945 | fn from(node: BoxPat) -> Pat { Pat::BoxPat(node) } |
4334 | } | 2946 | } |
4335 | impl From<UseItem> for ModuleItem { | 2947 | impl From<BindPat> for Pat { |
4336 | fn from(node: UseItem) -> ModuleItem { ModuleItem::UseItem(node) } | 2948 | fn from(node: BindPat) -> Pat { Pat::BindPat(node) } |
4337 | } | 2949 | } |
4338 | impl From<ExternCrateItem> for ModuleItem { | 2950 | impl From<PlaceholderPat> for Pat { |
4339 | fn from(node: ExternCrateItem) -> ModuleItem { ModuleItem::ExternCrateItem(node) } | 2951 | fn from(node: PlaceholderPat) -> Pat { Pat::PlaceholderPat(node) } |
4340 | } | 2952 | } |
4341 | impl From<ConstDef> for ModuleItem { | 2953 | impl From<DotDotPat> for Pat { |
4342 | fn from(node: ConstDef) -> ModuleItem { ModuleItem::ConstDef(node) } | 2954 | fn from(node: DotDotPat) -> Pat { Pat::DotDotPat(node) } |
4343 | } | 2955 | } |
4344 | impl From<StaticDef> for ModuleItem { | 2956 | impl From<PathPat> for Pat { |
4345 | fn from(node: StaticDef) -> ModuleItem { ModuleItem::StaticDef(node) } | 2957 | fn from(node: PathPat) -> Pat { Pat::PathPat(node) } |
4346 | } | 2958 | } |
4347 | impl From<Module> for ModuleItem { | 2959 | impl From<RecordPat> for Pat { |
4348 | fn from(node: Module) -> ModuleItem { ModuleItem::Module(node) } | 2960 | fn from(node: RecordPat) -> Pat { Pat::RecordPat(node) } |
4349 | } | 2961 | } |
4350 | impl From<MacroCall> for ModuleItem { | 2962 | impl From<TupleStructPat> for Pat { |
4351 | fn from(node: MacroCall) -> ModuleItem { ModuleItem::MacroCall(node) } | 2963 | fn from(node: TupleStructPat) -> Pat { Pat::TupleStructPat(node) } |
4352 | } | 2964 | } |
4353 | impl From<ExternBlock> for ModuleItem { | 2965 | impl From<TuplePat> for Pat { |
4354 | fn from(node: ExternBlock) -> ModuleItem { ModuleItem::ExternBlock(node) } | 2966 | fn from(node: TuplePat) -> Pat { Pat::TuplePat(node) } |
4355 | } | 2967 | } |
4356 | impl AstNode for ModuleItem { | 2968 | impl From<SlicePat> for Pat { |
4357 | fn can_cast(kind: SyntaxKind) -> bool { | 2969 | fn from(node: SlicePat) -> Pat { Pat::SlicePat(node) } |
4358 | match kind { | ||
4359 | STRUCT_DEF | UNION_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | IMPL_DEF | ||
4360 | | USE_ITEM | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE | MACRO_CALL | ||
4361 | | EXTERN_BLOCK => true, | ||
4362 | _ => false, | ||
4363 | } | ||
4364 | } | ||
4365 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4366 | let res = match syntax.kind() { | ||
4367 | STRUCT_DEF => ModuleItem::StructDef(StructDef { syntax }), | ||
4368 | UNION_DEF => ModuleItem::UnionDef(UnionDef { syntax }), | ||
4369 | ENUM_DEF => ModuleItem::EnumDef(EnumDef { syntax }), | ||
4370 | FN_DEF => ModuleItem::FnDef(FnDef { syntax }), | ||
4371 | TRAIT_DEF => ModuleItem::TraitDef(TraitDef { syntax }), | ||
4372 | TYPE_ALIAS_DEF => ModuleItem::TypeAliasDef(TypeAliasDef { syntax }), | ||
4373 | IMPL_DEF => ModuleItem::ImplDef(ImplDef { syntax }), | ||
4374 | USE_ITEM => ModuleItem::UseItem(UseItem { syntax }), | ||
4375 | EXTERN_CRATE_ITEM => ModuleItem::ExternCrateItem(ExternCrateItem { syntax }), | ||
4376 | CONST_DEF => ModuleItem::ConstDef(ConstDef { syntax }), | ||
4377 | STATIC_DEF => ModuleItem::StaticDef(StaticDef { syntax }), | ||
4378 | MODULE => ModuleItem::Module(Module { syntax }), | ||
4379 | MACRO_CALL => ModuleItem::MacroCall(MacroCall { syntax }), | ||
4380 | EXTERN_BLOCK => ModuleItem::ExternBlock(ExternBlock { syntax }), | ||
4381 | _ => return None, | ||
4382 | }; | ||
4383 | Some(res) | ||
4384 | } | ||
4385 | fn syntax(&self) -> &SyntaxNode { | ||
4386 | match self { | ||
4387 | ModuleItem::StructDef(it) => &it.syntax, | ||
4388 | ModuleItem::UnionDef(it) => &it.syntax, | ||
4389 | ModuleItem::EnumDef(it) => &it.syntax, | ||
4390 | ModuleItem::FnDef(it) => &it.syntax, | ||
4391 | ModuleItem::TraitDef(it) => &it.syntax, | ||
4392 | ModuleItem::TypeAliasDef(it) => &it.syntax, | ||
4393 | ModuleItem::ImplDef(it) => &it.syntax, | ||
4394 | ModuleItem::UseItem(it) => &it.syntax, | ||
4395 | ModuleItem::ExternCrateItem(it) => &it.syntax, | ||
4396 | ModuleItem::ConstDef(it) => &it.syntax, | ||
4397 | ModuleItem::StaticDef(it) => &it.syntax, | ||
4398 | ModuleItem::Module(it) => &it.syntax, | ||
4399 | ModuleItem::MacroCall(it) => &it.syntax, | ||
4400 | ModuleItem::ExternBlock(it) => &it.syntax, | ||
4401 | } | ||
4402 | } | ||
4403 | } | 2970 | } |
4404 | impl From<FnDef> for AssocItem { | 2971 | impl From<RangePat> for Pat { |
4405 | fn from(node: FnDef) -> AssocItem { AssocItem::FnDef(node) } | 2972 | fn from(node: RangePat) -> Pat { Pat::RangePat(node) } |
4406 | } | 2973 | } |
4407 | impl From<TypeAliasDef> for AssocItem { | 2974 | impl From<LiteralPat> for Pat { |
4408 | fn from(node: TypeAliasDef) -> AssocItem { AssocItem::TypeAliasDef(node) } | 2975 | fn from(node: LiteralPat) -> Pat { Pat::LiteralPat(node) } |
4409 | } | 2976 | } |
4410 | impl From<ConstDef> for AssocItem { | 2977 | impl From<MacroPat> for Pat { |
4411 | fn from(node: ConstDef) -> AssocItem { AssocItem::ConstDef(node) } | 2978 | fn from(node: MacroPat) -> Pat { Pat::MacroPat(node) } |
4412 | } | 2979 | } |
4413 | impl AstNode for AssocItem { | 2980 | impl AstNode for Pat { |
4414 | fn can_cast(kind: SyntaxKind) -> bool { | 2981 | fn can_cast(kind: SyntaxKind) -> bool { |
4415 | match kind { | 2982 | match kind { |
4416 | FN_DEF | TYPE_ALIAS_DEF | CONST_DEF => true, | 2983 | OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT |
2984 | | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT | ||
2985 | | LITERAL_PAT | MACRO_PAT => true, | ||
4417 | _ => false, | 2986 | _ => false, |
4418 | } | 2987 | } |
4419 | } | 2988 | } |
4420 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2989 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
4421 | let res = match syntax.kind() { | 2990 | let res = match syntax.kind() { |
4422 | FN_DEF => AssocItem::FnDef(FnDef { syntax }), | 2991 | OR_PAT => Pat::OrPat(OrPat { syntax }), |
4423 | TYPE_ALIAS_DEF => AssocItem::TypeAliasDef(TypeAliasDef { syntax }), | 2992 | PAREN_PAT => Pat::ParenPat(ParenPat { syntax }), |
4424 | CONST_DEF => AssocItem::ConstDef(ConstDef { syntax }), | 2993 | REF_PAT => Pat::RefPat(RefPat { syntax }), |
2994 | BOX_PAT => Pat::BoxPat(BoxPat { syntax }), | ||
2995 | BIND_PAT => Pat::BindPat(BindPat { syntax }), | ||
2996 | PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }), | ||
2997 | DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }), | ||
2998 | PATH_PAT => Pat::PathPat(PathPat { syntax }), | ||
2999 | RECORD_PAT => Pat::RecordPat(RecordPat { syntax }), | ||
3000 | TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }), | ||
3001 | TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }), | ||
3002 | SLICE_PAT => Pat::SlicePat(SlicePat { syntax }), | ||
3003 | RANGE_PAT => Pat::RangePat(RangePat { syntax }), | ||
3004 | LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }), | ||
3005 | MACRO_PAT => Pat::MacroPat(MacroPat { syntax }), | ||
4425 | _ => return None, | 3006 | _ => return None, |
4426 | }; | 3007 | }; |
4427 | Some(res) | 3008 | Some(res) |
4428 | } | 3009 | } |
4429 | fn syntax(&self) -> &SyntaxNode { | 3010 | fn syntax(&self) -> &SyntaxNode { |
4430 | match self { | 3011 | match self { |
4431 | AssocItem::FnDef(it) => &it.syntax, | 3012 | Pat::OrPat(it) => &it.syntax, |
4432 | AssocItem::TypeAliasDef(it) => &it.syntax, | 3013 | Pat::ParenPat(it) => &it.syntax, |
4433 | AssocItem::ConstDef(it) => &it.syntax, | 3014 | Pat::RefPat(it) => &it.syntax, |
3015 | Pat::BoxPat(it) => &it.syntax, | ||
3016 | Pat::BindPat(it) => &it.syntax, | ||
3017 | Pat::PlaceholderPat(it) => &it.syntax, | ||
3018 | Pat::DotDotPat(it) => &it.syntax, | ||
3019 | Pat::PathPat(it) => &it.syntax, | ||
3020 | Pat::RecordPat(it) => &it.syntax, | ||
3021 | Pat::TupleStructPat(it) => &it.syntax, | ||
3022 | Pat::TuplePat(it) => &it.syntax, | ||
3023 | Pat::SlicePat(it) => &it.syntax, | ||
3024 | Pat::RangePat(it) => &it.syntax, | ||
3025 | Pat::LiteralPat(it) => &it.syntax, | ||
3026 | Pat::MacroPat(it) => &it.syntax, | ||
4434 | } | 3027 | } |
4435 | } | 3028 | } |
4436 | } | 3029 | } |
4437 | impl From<FnDef> for ExternItem { | 3030 | impl From<RecordFieldList> for FieldList { |
4438 | fn from(node: FnDef) -> ExternItem { ExternItem::FnDef(node) } | 3031 | fn from(node: RecordFieldList) -> FieldList { FieldList::RecordFieldList(node) } |
4439 | } | 3032 | } |
4440 | impl From<StaticDef> for ExternItem { | 3033 | impl From<TupleFieldList> for FieldList { |
4441 | fn from(node: StaticDef) -> ExternItem { ExternItem::StaticDef(node) } | 3034 | fn from(node: TupleFieldList) -> FieldList { FieldList::TupleFieldList(node) } |
4442 | } | 3035 | } |
4443 | impl AstNode for ExternItem { | 3036 | impl AstNode for FieldList { |
4444 | fn can_cast(kind: SyntaxKind) -> bool { | 3037 | fn can_cast(kind: SyntaxKind) -> bool { |
4445 | match kind { | 3038 | match kind { |
4446 | FN_DEF | STATIC_DEF => true, | 3039 | RECORD_FIELD_LIST | TUPLE_FIELD_LIST => true, |
4447 | _ => false, | 3040 | _ => false, |
4448 | } | 3041 | } |
4449 | } | 3042 | } |
4450 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 3043 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
4451 | let res = match syntax.kind() { | 3044 | let res = match syntax.kind() { |
4452 | FN_DEF => ExternItem::FnDef(FnDef { syntax }), | 3045 | RECORD_FIELD_LIST => FieldList::RecordFieldList(RecordFieldList { syntax }), |
4453 | STATIC_DEF => ExternItem::StaticDef(StaticDef { syntax }), | 3046 | TUPLE_FIELD_LIST => FieldList::TupleFieldList(TupleFieldList { syntax }), |
4454 | _ => return None, | 3047 | _ => return None, |
4455 | }; | 3048 | }; |
4456 | Some(res) | 3049 | Some(res) |
4457 | } | 3050 | } |
4458 | fn syntax(&self) -> &SyntaxNode { | 3051 | fn syntax(&self) -> &SyntaxNode { |
4459 | match self { | 3052 | match self { |
4460 | ExternItem::FnDef(it) => &it.syntax, | 3053 | FieldList::RecordFieldList(it) => &it.syntax, |
4461 | ExternItem::StaticDef(it) => &it.syntax, | 3054 | FieldList::TupleFieldList(it) => &it.syntax, |
4462 | } | 3055 | } |
4463 | } | 3056 | } |
4464 | } | 3057 | } |
@@ -4507,8 +3100,8 @@ impl From<ReturnExpr> for Expr { | |||
4507 | impl From<MatchExpr> for Expr { | 3100 | impl From<MatchExpr> for Expr { |
4508 | fn from(node: MatchExpr) -> Expr { Expr::MatchExpr(node) } | 3101 | fn from(node: MatchExpr) -> Expr { Expr::MatchExpr(node) } |
4509 | } | 3102 | } |
4510 | impl From<RecordLit> for Expr { | 3103 | impl From<RecordExpr> for Expr { |
4511 | fn from(node: RecordLit) -> Expr { Expr::RecordLit(node) } | 3104 | fn from(node: RecordExpr) -> Expr { Expr::RecordExpr(node) } |
4512 | } | 3105 | } |
4513 | impl From<CallExpr> for Expr { | 3106 | impl From<CallExpr> for Expr { |
4514 | fn from(node: CallExpr) -> Expr { Expr::CallExpr(node) } | 3107 | fn from(node: CallExpr) -> Expr { Expr::CallExpr(node) } |
@@ -4560,7 +3153,7 @@ impl AstNode for Expr { | |||
4560 | match kind { | 3153 | match kind { |
4561 | TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR | 3154 | TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR |
4562 | | LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL | 3155 | | LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL |
4563 | | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | RECORD_LIT | CALL_EXPR | INDEX_EXPR | 3156 | | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | RECORD_EXPR | CALL_EXPR | INDEX_EXPR |
4564 | | METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | EFFECT_EXPR | CAST_EXPR | 3157 | | METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | EFFECT_EXPR | CAST_EXPR |
4565 | | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL | BOX_EXPR => { | 3158 | | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL | BOX_EXPR => { |
4566 | true | 3159 | true |
@@ -4585,7 +3178,7 @@ impl AstNode for Expr { | |||
4585 | BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }), | 3178 | BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }), |
4586 | RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }), | 3179 | RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }), |
4587 | MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }), | 3180 | MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }), |
4588 | RECORD_LIT => Expr::RecordLit(RecordLit { syntax }), | 3181 | RECORD_EXPR => Expr::RecordExpr(RecordExpr { syntax }), |
4589 | CALL_EXPR => Expr::CallExpr(CallExpr { syntax }), | 3182 | CALL_EXPR => Expr::CallExpr(CallExpr { syntax }), |
4590 | INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }), | 3183 | INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }), |
4591 | METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }), | 3184 | METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }), |
@@ -4622,7 +3215,7 @@ impl AstNode for Expr { | |||
4622 | Expr::BlockExpr(it) => &it.syntax, | 3215 | Expr::BlockExpr(it) => &it.syntax, |
4623 | Expr::ReturnExpr(it) => &it.syntax, | 3216 | Expr::ReturnExpr(it) => &it.syntax, |
4624 | Expr::MatchExpr(it) => &it.syntax, | 3217 | Expr::MatchExpr(it) => &it.syntax, |
4625 | Expr::RecordLit(it) => &it.syntax, | 3218 | Expr::RecordExpr(it) => &it.syntax, |
4626 | Expr::CallExpr(it) => &it.syntax, | 3219 | Expr::CallExpr(it) => &it.syntax, |
4627 | Expr::IndexExpr(it) => &it.syntax, | 3220 | Expr::IndexExpr(it) => &it.syntax, |
4628 | Expr::MethodCallExpr(it) => &it.syntax, | 3221 | Expr::MethodCallExpr(it) => &it.syntax, |
@@ -4641,154 +3234,107 @@ impl AstNode for Expr { | |||
4641 | } | 3234 | } |
4642 | } | 3235 | } |
4643 | } | 3236 | } |
4644 | impl From<OrPat> for Pat { | 3237 | impl From<Fn> for AssocItem { |
4645 | fn from(node: OrPat) -> Pat { Pat::OrPat(node) } | 3238 | fn from(node: Fn) -> AssocItem { AssocItem::Fn(node) } |
4646 | } | ||
4647 | impl From<ParenPat> for Pat { | ||
4648 | fn from(node: ParenPat) -> Pat { Pat::ParenPat(node) } | ||
4649 | } | ||
4650 | impl From<RefPat> for Pat { | ||
4651 | fn from(node: RefPat) -> Pat { Pat::RefPat(node) } | ||
4652 | } | ||
4653 | impl From<BoxPat> for Pat { | ||
4654 | fn from(node: BoxPat) -> Pat { Pat::BoxPat(node) } | ||
4655 | } | ||
4656 | impl From<BindPat> for Pat { | ||
4657 | fn from(node: BindPat) -> Pat { Pat::BindPat(node) } | ||
4658 | } | ||
4659 | impl From<PlaceholderPat> for Pat { | ||
4660 | fn from(node: PlaceholderPat) -> Pat { Pat::PlaceholderPat(node) } | ||
4661 | } | ||
4662 | impl From<DotDotPat> for Pat { | ||
4663 | fn from(node: DotDotPat) -> Pat { Pat::DotDotPat(node) } | ||
4664 | } | ||
4665 | impl From<PathPat> for Pat { | ||
4666 | fn from(node: PathPat) -> Pat { Pat::PathPat(node) } | ||
4667 | } | ||
4668 | impl From<RecordPat> for Pat { | ||
4669 | fn from(node: RecordPat) -> Pat { Pat::RecordPat(node) } | ||
4670 | } | ||
4671 | impl From<TupleStructPat> for Pat { | ||
4672 | fn from(node: TupleStructPat) -> Pat { Pat::TupleStructPat(node) } | ||
4673 | } | ||
4674 | impl From<TuplePat> for Pat { | ||
4675 | fn from(node: TuplePat) -> Pat { Pat::TuplePat(node) } | ||
4676 | } | ||
4677 | impl From<SlicePat> for Pat { | ||
4678 | fn from(node: SlicePat) -> Pat { Pat::SlicePat(node) } | ||
4679 | } | 3239 | } |
4680 | impl From<RangePat> for Pat { | 3240 | impl From<TypeAlias> for AssocItem { |
4681 | fn from(node: RangePat) -> Pat { Pat::RangePat(node) } | 3241 | fn from(node: TypeAlias) -> AssocItem { AssocItem::TypeAlias(node) } |
4682 | } | 3242 | } |
4683 | impl From<LiteralPat> for Pat { | 3243 | impl From<Const> for AssocItem { |
4684 | fn from(node: LiteralPat) -> Pat { Pat::LiteralPat(node) } | 3244 | fn from(node: Const) -> AssocItem { AssocItem::Const(node) } |
4685 | } | 3245 | } |
4686 | impl From<MacroPat> for Pat { | 3246 | impl From<MacroCall> for AssocItem { |
4687 | fn from(node: MacroPat) -> Pat { Pat::MacroPat(node) } | 3247 | fn from(node: MacroCall) -> AssocItem { AssocItem::MacroCall(node) } |
4688 | } | 3248 | } |
4689 | impl AstNode for Pat { | 3249 | impl AstNode for AssocItem { |
4690 | fn can_cast(kind: SyntaxKind) -> bool { | 3250 | fn can_cast(kind: SyntaxKind) -> bool { |
4691 | match kind { | 3251 | match kind { |
4692 | OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT | 3252 | FN | TYPE_ALIAS | CONST | MACRO_CALL => true, |
4693 | | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT | ||
4694 | | LITERAL_PAT | MACRO_PAT => true, | ||
4695 | _ => false, | 3253 | _ => false, |
4696 | } | 3254 | } |
4697 | } | 3255 | } |
4698 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 3256 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
4699 | let res = match syntax.kind() { | 3257 | let res = match syntax.kind() { |
4700 | OR_PAT => Pat::OrPat(OrPat { syntax }), | 3258 | FN => AssocItem::Fn(Fn { syntax }), |
4701 | PAREN_PAT => Pat::ParenPat(ParenPat { syntax }), | 3259 | TYPE_ALIAS => AssocItem::TypeAlias(TypeAlias { syntax }), |
4702 | REF_PAT => Pat::RefPat(RefPat { syntax }), | 3260 | CONST => AssocItem::Const(Const { syntax }), |
4703 | BOX_PAT => Pat::BoxPat(BoxPat { syntax }), | 3261 | MACRO_CALL => AssocItem::MacroCall(MacroCall { syntax }), |
4704 | BIND_PAT => Pat::BindPat(BindPat { syntax }), | ||
4705 | PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }), | ||
4706 | DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }), | ||
4707 | PATH_PAT => Pat::PathPat(PathPat { syntax }), | ||
4708 | RECORD_PAT => Pat::RecordPat(RecordPat { syntax }), | ||
4709 | TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }), | ||
4710 | TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }), | ||
4711 | SLICE_PAT => Pat::SlicePat(SlicePat { syntax }), | ||
4712 | RANGE_PAT => Pat::RangePat(RangePat { syntax }), | ||
4713 | LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }), | ||
4714 | MACRO_PAT => Pat::MacroPat(MacroPat { syntax }), | ||
4715 | _ => return None, | 3262 | _ => return None, |
4716 | }; | 3263 | }; |
4717 | Some(res) | 3264 | Some(res) |
4718 | } | 3265 | } |
4719 | fn syntax(&self) -> &SyntaxNode { | 3266 | fn syntax(&self) -> &SyntaxNode { |
4720 | match self { | 3267 | match self { |
4721 | Pat::OrPat(it) => &it.syntax, | 3268 | AssocItem::Fn(it) => &it.syntax, |
4722 | Pat::ParenPat(it) => &it.syntax, | 3269 | AssocItem::TypeAlias(it) => &it.syntax, |
4723 | Pat::RefPat(it) => &it.syntax, | 3270 | AssocItem::Const(it) => &it.syntax, |
4724 | Pat::BoxPat(it) => &it.syntax, | 3271 | AssocItem::MacroCall(it) => &it.syntax, |
4725 | Pat::BindPat(it) => &it.syntax, | ||
4726 | Pat::PlaceholderPat(it) => &it.syntax, | ||
4727 | Pat::DotDotPat(it) => &it.syntax, | ||
4728 | Pat::PathPat(it) => &it.syntax, | ||
4729 | Pat::RecordPat(it) => &it.syntax, | ||
4730 | Pat::TupleStructPat(it) => &it.syntax, | ||
4731 | Pat::TuplePat(it) => &it.syntax, | ||
4732 | Pat::SlicePat(it) => &it.syntax, | ||
4733 | Pat::RangePat(it) => &it.syntax, | ||
4734 | Pat::LiteralPat(it) => &it.syntax, | ||
4735 | Pat::MacroPat(it) => &it.syntax, | ||
4736 | } | 3272 | } |
4737 | } | 3273 | } |
4738 | } | 3274 | } |
4739 | impl From<RecordFieldPat> for RecordInnerPat { | 3275 | impl From<Fn> for ExternItem { |
4740 | fn from(node: RecordFieldPat) -> RecordInnerPat { RecordInnerPat::RecordFieldPat(node) } | 3276 | fn from(node: Fn) -> ExternItem { ExternItem::Fn(node) } |
4741 | } | 3277 | } |
4742 | impl From<BindPat> for RecordInnerPat { | 3278 | impl From<Static> for ExternItem { |
4743 | fn from(node: BindPat) -> RecordInnerPat { RecordInnerPat::BindPat(node) } | 3279 | fn from(node: Static) -> ExternItem { ExternItem::Static(node) } |
4744 | } | 3280 | } |
4745 | impl AstNode for RecordInnerPat { | 3281 | impl From<MacroCall> for ExternItem { |
3282 | fn from(node: MacroCall) -> ExternItem { ExternItem::MacroCall(node) } | ||
3283 | } | ||
3284 | impl AstNode for ExternItem { | ||
4746 | fn can_cast(kind: SyntaxKind) -> bool { | 3285 | fn can_cast(kind: SyntaxKind) -> bool { |
4747 | match kind { | 3286 | match kind { |
4748 | RECORD_FIELD_PAT | BIND_PAT => true, | 3287 | FN | STATIC | MACRO_CALL => true, |
4749 | _ => false, | 3288 | _ => false, |
4750 | } | 3289 | } |
4751 | } | 3290 | } |
4752 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 3291 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
4753 | let res = match syntax.kind() { | 3292 | let res = match syntax.kind() { |
4754 | RECORD_FIELD_PAT => RecordInnerPat::RecordFieldPat(RecordFieldPat { syntax }), | 3293 | FN => ExternItem::Fn(Fn { syntax }), |
4755 | BIND_PAT => RecordInnerPat::BindPat(BindPat { syntax }), | 3294 | STATIC => ExternItem::Static(Static { syntax }), |
3295 | MACRO_CALL => ExternItem::MacroCall(MacroCall { syntax }), | ||
4756 | _ => return None, | 3296 | _ => return None, |
4757 | }; | 3297 | }; |
4758 | Some(res) | 3298 | Some(res) |
4759 | } | 3299 | } |
4760 | fn syntax(&self) -> &SyntaxNode { | 3300 | fn syntax(&self) -> &SyntaxNode { |
4761 | match self { | 3301 | match self { |
4762 | RecordInnerPat::RecordFieldPat(it) => &it.syntax, | 3302 | ExternItem::Fn(it) => &it.syntax, |
4763 | RecordInnerPat::BindPat(it) => &it.syntax, | 3303 | ExternItem::Static(it) => &it.syntax, |
3304 | ExternItem::MacroCall(it) => &it.syntax, | ||
4764 | } | 3305 | } |
4765 | } | 3306 | } |
4766 | } | 3307 | } |
4767 | impl From<Literal> for AttrInput { | 3308 | impl From<LifetimeParam> for GenericParam { |
4768 | fn from(node: Literal) -> AttrInput { AttrInput::Literal(node) } | 3309 | fn from(node: LifetimeParam) -> GenericParam { GenericParam::LifetimeParam(node) } |
3310 | } | ||
3311 | impl From<TypeParam> for GenericParam { | ||
3312 | fn from(node: TypeParam) -> GenericParam { GenericParam::TypeParam(node) } | ||
4769 | } | 3313 | } |
4770 | impl From<TokenTree> for AttrInput { | 3314 | impl From<ConstParam> for GenericParam { |
4771 | fn from(node: TokenTree) -> AttrInput { AttrInput::TokenTree(node) } | 3315 | fn from(node: ConstParam) -> GenericParam { GenericParam::ConstParam(node) } |
4772 | } | 3316 | } |
4773 | impl AstNode for AttrInput { | 3317 | impl AstNode for GenericParam { |
4774 | fn can_cast(kind: SyntaxKind) -> bool { | 3318 | fn can_cast(kind: SyntaxKind) -> bool { |
4775 | match kind { | 3319 | match kind { |
4776 | LITERAL | TOKEN_TREE => true, | 3320 | LIFETIME_PARAM | TYPE_PARAM | CONST_PARAM => true, |
4777 | _ => false, | 3321 | _ => false, |
4778 | } | 3322 | } |
4779 | } | 3323 | } |
4780 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 3324 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
4781 | let res = match syntax.kind() { | 3325 | let res = match syntax.kind() { |
4782 | LITERAL => AttrInput::Literal(Literal { syntax }), | 3326 | LIFETIME_PARAM => GenericParam::LifetimeParam(LifetimeParam { syntax }), |
4783 | TOKEN_TREE => AttrInput::TokenTree(TokenTree { syntax }), | 3327 | TYPE_PARAM => GenericParam::TypeParam(TypeParam { syntax }), |
3328 | CONST_PARAM => GenericParam::ConstParam(ConstParam { syntax }), | ||
4784 | _ => return None, | 3329 | _ => return None, |
4785 | }; | 3330 | }; |
4786 | Some(res) | 3331 | Some(res) |
4787 | } | 3332 | } |
4788 | fn syntax(&self) -> &SyntaxNode { | 3333 | fn syntax(&self) -> &SyntaxNode { |
4789 | match self { | 3334 | match self { |
4790 | AttrInput::Literal(it) => &it.syntax, | 3335 | GenericParam::LifetimeParam(it) => &it.syntax, |
4791 | AttrInput::TokenTree(it) => &it.syntax, | 3336 | GenericParam::TypeParam(it) => &it.syntax, |
3337 | GenericParam::ConstParam(it) => &it.syntax, | ||
4792 | } | 3338 | } |
4793 | } | 3339 | } |
4794 | } | 3340 | } |
@@ -4820,47 +3366,40 @@ impl AstNode for Stmt { | |||
4820 | } | 3366 | } |
4821 | } | 3367 | } |
4822 | } | 3368 | } |
4823 | impl From<RecordFieldDefList> for FieldDefList { | 3369 | impl From<Struct> for AdtDef { |
4824 | fn from(node: RecordFieldDefList) -> FieldDefList { FieldDefList::RecordFieldDefList(node) } | 3370 | fn from(node: Struct) -> AdtDef { AdtDef::Struct(node) } |
3371 | } | ||
3372 | impl From<Enum> for AdtDef { | ||
3373 | fn from(node: Enum) -> AdtDef { AdtDef::Enum(node) } | ||
4825 | } | 3374 | } |
4826 | impl From<TupleFieldDefList> for FieldDefList { | 3375 | impl From<Union> for AdtDef { |
4827 | fn from(node: TupleFieldDefList) -> FieldDefList { FieldDefList::TupleFieldDefList(node) } | 3376 | fn from(node: Union) -> AdtDef { AdtDef::Union(node) } |
4828 | } | 3377 | } |
4829 | impl AstNode for FieldDefList { | 3378 | impl AstNode for AdtDef { |
4830 | fn can_cast(kind: SyntaxKind) -> bool { | 3379 | fn can_cast(kind: SyntaxKind) -> bool { |
4831 | match kind { | 3380 | match kind { |
4832 | RECORD_FIELD_DEF_LIST | TUPLE_FIELD_DEF_LIST => true, | 3381 | STRUCT | ENUM | UNION => true, |
4833 | _ => false, | 3382 | _ => false, |
4834 | } | 3383 | } |
4835 | } | 3384 | } |
4836 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 3385 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
4837 | let res = match syntax.kind() { | 3386 | let res = match syntax.kind() { |
4838 | RECORD_FIELD_DEF_LIST => { | 3387 | STRUCT => AdtDef::Struct(Struct { syntax }), |
4839 | FieldDefList::RecordFieldDefList(RecordFieldDefList { syntax }) | 3388 | ENUM => AdtDef::Enum(Enum { syntax }), |
4840 | } | 3389 | UNION => AdtDef::Union(Union { syntax }), |
4841 | TUPLE_FIELD_DEF_LIST => FieldDefList::TupleFieldDefList(TupleFieldDefList { syntax }), | ||
4842 | _ => return None, | 3390 | _ => return None, |
4843 | }; | 3391 | }; |
4844 | Some(res) | 3392 | Some(res) |
4845 | } | 3393 | } |
4846 | fn syntax(&self) -> &SyntaxNode { | 3394 | fn syntax(&self) -> &SyntaxNode { |
4847 | match self { | 3395 | match self { |
4848 | FieldDefList::RecordFieldDefList(it) => &it.syntax, | 3396 | AdtDef::Struct(it) => &it.syntax, |
4849 | FieldDefList::TupleFieldDefList(it) => &it.syntax, | 3397 | AdtDef::Enum(it) => &it.syntax, |
3398 | AdtDef::Union(it) => &it.syntax, | ||
4850 | } | 3399 | } |
4851 | } | 3400 | } |
4852 | } | 3401 | } |
4853 | impl std::fmt::Display for NominalDef { | 3402 | impl std::fmt::Display for Item { |
4854 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
4855 | std::fmt::Display::fmt(self.syntax(), f) | ||
4856 | } | ||
4857 | } | ||
4858 | impl std::fmt::Display for GenericParam { | ||
4859 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
4860 | std::fmt::Display::fmt(self.syntax(), f) | ||
4861 | } | ||
4862 | } | ||
4863 | impl std::fmt::Display for GenericArg { | ||
4864 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3403 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4865 | std::fmt::Display::fmt(self.syntax(), f) | 3404 | std::fmt::Display::fmt(self.syntax(), f) |
4866 | } | 3405 | } |
@@ -4870,17 +3409,12 @@ impl std::fmt::Display for TypeRef { | |||
4870 | std::fmt::Display::fmt(self.syntax(), f) | 3409 | std::fmt::Display::fmt(self.syntax(), f) |
4871 | } | 3410 | } |
4872 | } | 3411 | } |
4873 | impl std::fmt::Display for ModuleItem { | 3412 | impl std::fmt::Display for Pat { |
4874 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
4875 | std::fmt::Display::fmt(self.syntax(), f) | ||
4876 | } | ||
4877 | } | ||
4878 | impl std::fmt::Display for AssocItem { | ||
4879 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3413 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4880 | std::fmt::Display::fmt(self.syntax(), f) | 3414 | std::fmt::Display::fmt(self.syntax(), f) |
4881 | } | 3415 | } |
4882 | } | 3416 | } |
4883 | impl std::fmt::Display for ExternItem { | 3417 | impl std::fmt::Display for FieldList { |
4884 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3418 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4885 | std::fmt::Display::fmt(self.syntax(), f) | 3419 | std::fmt::Display::fmt(self.syntax(), f) |
4886 | } | 3420 | } |
@@ -4890,17 +3424,17 @@ impl std::fmt::Display for Expr { | |||
4890 | std::fmt::Display::fmt(self.syntax(), f) | 3424 | std::fmt::Display::fmt(self.syntax(), f) |
4891 | } | 3425 | } |
4892 | } | 3426 | } |
4893 | impl std::fmt::Display for Pat { | 3427 | impl std::fmt::Display for AssocItem { |
4894 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3428 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4895 | std::fmt::Display::fmt(self.syntax(), f) | 3429 | std::fmt::Display::fmt(self.syntax(), f) |
4896 | } | 3430 | } |
4897 | } | 3431 | } |
4898 | impl std::fmt::Display for RecordInnerPat { | 3432 | impl std::fmt::Display for ExternItem { |
4899 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3433 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4900 | std::fmt::Display::fmt(self.syntax(), f) | 3434 | std::fmt::Display::fmt(self.syntax(), f) |
4901 | } | 3435 | } |
4902 | } | 3436 | } |
4903 | impl std::fmt::Display for AttrInput { | 3437 | impl std::fmt::Display for GenericParam { |
4904 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3438 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4905 | std::fmt::Display::fmt(self.syntax(), f) | 3439 | std::fmt::Display::fmt(self.syntax(), f) |
4906 | } | 3440 | } |
@@ -4910,7 +3444,7 @@ impl std::fmt::Display for Stmt { | |||
4910 | std::fmt::Display::fmt(self.syntax(), f) | 3444 | std::fmt::Display::fmt(self.syntax(), f) |
4911 | } | 3445 | } |
4912 | } | 3446 | } |
4913 | impl std::fmt::Display for FieldDefList { | 3447 | impl std::fmt::Display for AdtDef { |
4914 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3448 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4915 | std::fmt::Display::fmt(self.syntax(), f) | 3449 | std::fmt::Display::fmt(self.syntax(), f) |
4916 | } | 3450 | } |
@@ -4920,617 +3454,617 @@ impl std::fmt::Display for SourceFile { | |||
4920 | std::fmt::Display::fmt(self.syntax(), f) | 3454 | std::fmt::Display::fmt(self.syntax(), f) |
4921 | } | 3455 | } |
4922 | } | 3456 | } |
4923 | impl std::fmt::Display for FnDef { | 3457 | impl std::fmt::Display for Attr { |
4924 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3458 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4925 | std::fmt::Display::fmt(self.syntax(), f) | 3459 | std::fmt::Display::fmt(self.syntax(), f) |
4926 | } | 3460 | } |
4927 | } | 3461 | } |
4928 | impl std::fmt::Display for RetType { | 3462 | impl std::fmt::Display for Const { |
4929 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3463 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4930 | std::fmt::Display::fmt(self.syntax(), f) | 3464 | std::fmt::Display::fmt(self.syntax(), f) |
4931 | } | 3465 | } |
4932 | } | 3466 | } |
4933 | impl std::fmt::Display for StructDef { | 3467 | impl std::fmt::Display for Enum { |
4934 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3468 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4935 | std::fmt::Display::fmt(self.syntax(), f) | 3469 | std::fmt::Display::fmt(self.syntax(), f) |
4936 | } | 3470 | } |
4937 | } | 3471 | } |
4938 | impl std::fmt::Display for UnionDef { | 3472 | impl std::fmt::Display for ExternBlock { |
4939 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3473 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4940 | std::fmt::Display::fmt(self.syntax(), f) | 3474 | std::fmt::Display::fmt(self.syntax(), f) |
4941 | } | 3475 | } |
4942 | } | 3476 | } |
4943 | impl std::fmt::Display for RecordFieldDefList { | 3477 | impl std::fmt::Display for ExternCrate { |
4944 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3478 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4945 | std::fmt::Display::fmt(self.syntax(), f) | 3479 | std::fmt::Display::fmt(self.syntax(), f) |
4946 | } | 3480 | } |
4947 | } | 3481 | } |
4948 | impl std::fmt::Display for RecordFieldDef { | 3482 | impl std::fmt::Display for Fn { |
4949 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3483 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4950 | std::fmt::Display::fmt(self.syntax(), f) | 3484 | std::fmt::Display::fmt(self.syntax(), f) |
4951 | } | 3485 | } |
4952 | } | 3486 | } |
4953 | impl std::fmt::Display for TupleFieldDefList { | 3487 | impl std::fmt::Display for Impl { |
4954 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3488 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4955 | std::fmt::Display::fmt(self.syntax(), f) | 3489 | std::fmt::Display::fmt(self.syntax(), f) |
4956 | } | 3490 | } |
4957 | } | 3491 | } |
4958 | impl std::fmt::Display for TupleFieldDef { | 3492 | impl std::fmt::Display for MacroCall { |
4959 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3493 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4960 | std::fmt::Display::fmt(self.syntax(), f) | 3494 | std::fmt::Display::fmt(self.syntax(), f) |
4961 | } | 3495 | } |
4962 | } | 3496 | } |
4963 | impl std::fmt::Display for EnumDef { | 3497 | impl std::fmt::Display for Module { |
4964 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3498 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4965 | std::fmt::Display::fmt(self.syntax(), f) | 3499 | std::fmt::Display::fmt(self.syntax(), f) |
4966 | } | 3500 | } |
4967 | } | 3501 | } |
4968 | impl std::fmt::Display for EnumVariantList { | 3502 | impl std::fmt::Display for Static { |
4969 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3503 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4970 | std::fmt::Display::fmt(self.syntax(), f) | 3504 | std::fmt::Display::fmt(self.syntax(), f) |
4971 | } | 3505 | } |
4972 | } | 3506 | } |
4973 | impl std::fmt::Display for EnumVariant { | 3507 | impl std::fmt::Display for Struct { |
4974 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3508 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4975 | std::fmt::Display::fmt(self.syntax(), f) | 3509 | std::fmt::Display::fmt(self.syntax(), f) |
4976 | } | 3510 | } |
4977 | } | 3511 | } |
4978 | impl std::fmt::Display for TraitDef { | 3512 | impl std::fmt::Display for Trait { |
4979 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3513 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4980 | std::fmt::Display::fmt(self.syntax(), f) | 3514 | std::fmt::Display::fmt(self.syntax(), f) |
4981 | } | 3515 | } |
4982 | } | 3516 | } |
4983 | impl std::fmt::Display for Module { | 3517 | impl std::fmt::Display for TypeAlias { |
4984 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3518 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4985 | std::fmt::Display::fmt(self.syntax(), f) | 3519 | std::fmt::Display::fmt(self.syntax(), f) |
4986 | } | 3520 | } |
4987 | } | 3521 | } |
4988 | impl std::fmt::Display for ItemList { | 3522 | impl std::fmt::Display for Union { |
4989 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3523 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4990 | std::fmt::Display::fmt(self.syntax(), f) | 3524 | std::fmt::Display::fmt(self.syntax(), f) |
4991 | } | 3525 | } |
4992 | } | 3526 | } |
4993 | impl std::fmt::Display for ConstDef { | 3527 | impl std::fmt::Display for Use { |
4994 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3528 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4995 | std::fmt::Display::fmt(self.syntax(), f) | 3529 | std::fmt::Display::fmt(self.syntax(), f) |
4996 | } | 3530 | } |
4997 | } | 3531 | } |
4998 | impl std::fmt::Display for StaticDef { | 3532 | impl std::fmt::Display for Visibility { |
4999 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3533 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5000 | std::fmt::Display::fmt(self.syntax(), f) | 3534 | std::fmt::Display::fmt(self.syntax(), f) |
5001 | } | 3535 | } |
5002 | } | 3536 | } |
5003 | impl std::fmt::Display for TypeAliasDef { | 3537 | impl std::fmt::Display for Name { |
5004 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3538 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5005 | std::fmt::Display::fmt(self.syntax(), f) | 3539 | std::fmt::Display::fmt(self.syntax(), f) |
5006 | } | 3540 | } |
5007 | } | 3541 | } |
5008 | impl std::fmt::Display for ImplDef { | 3542 | impl std::fmt::Display for ItemList { |
5009 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3543 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5010 | std::fmt::Display::fmt(self.syntax(), f) | 3544 | std::fmt::Display::fmt(self.syntax(), f) |
5011 | } | 3545 | } |
5012 | } | 3546 | } |
5013 | impl std::fmt::Display for ParenType { | 3547 | impl std::fmt::Display for NameRef { |
5014 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3548 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5015 | std::fmt::Display::fmt(self.syntax(), f) | 3549 | std::fmt::Display::fmt(self.syntax(), f) |
5016 | } | 3550 | } |
5017 | } | 3551 | } |
5018 | impl std::fmt::Display for TupleType { | 3552 | impl std::fmt::Display for Rename { |
5019 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3553 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5020 | std::fmt::Display::fmt(self.syntax(), f) | 3554 | std::fmt::Display::fmt(self.syntax(), f) |
5021 | } | 3555 | } |
5022 | } | 3556 | } |
5023 | impl std::fmt::Display for NeverType { | 3557 | impl std::fmt::Display for UseTree { |
5024 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3558 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5025 | std::fmt::Display::fmt(self.syntax(), f) | 3559 | std::fmt::Display::fmt(self.syntax(), f) |
5026 | } | 3560 | } |
5027 | } | 3561 | } |
5028 | impl std::fmt::Display for PathType { | 3562 | impl std::fmt::Display for Path { |
5029 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3563 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5030 | std::fmt::Display::fmt(self.syntax(), f) | 3564 | std::fmt::Display::fmt(self.syntax(), f) |
5031 | } | 3565 | } |
5032 | } | 3566 | } |
5033 | impl std::fmt::Display for PointerType { | 3567 | impl std::fmt::Display for UseTreeList { |
5034 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3568 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5035 | std::fmt::Display::fmt(self.syntax(), f) | 3569 | std::fmt::Display::fmt(self.syntax(), f) |
5036 | } | 3570 | } |
5037 | } | 3571 | } |
5038 | impl std::fmt::Display for ArrayType { | 3572 | impl std::fmt::Display for Abi { |
5039 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3573 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5040 | std::fmt::Display::fmt(self.syntax(), f) | 3574 | std::fmt::Display::fmt(self.syntax(), f) |
5041 | } | 3575 | } |
5042 | } | 3576 | } |
5043 | impl std::fmt::Display for SliceType { | 3577 | impl std::fmt::Display for GenericParamList { |
5044 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3578 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5045 | std::fmt::Display::fmt(self.syntax(), f) | 3579 | std::fmt::Display::fmt(self.syntax(), f) |
5046 | } | 3580 | } |
5047 | } | 3581 | } |
5048 | impl std::fmt::Display for ReferenceType { | 3582 | impl std::fmt::Display for ParamList { |
5049 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3583 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5050 | std::fmt::Display::fmt(self.syntax(), f) | 3584 | std::fmt::Display::fmt(self.syntax(), f) |
5051 | } | 3585 | } |
5052 | } | 3586 | } |
5053 | impl std::fmt::Display for PlaceholderType { | 3587 | impl std::fmt::Display for RetType { |
5054 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3588 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5055 | std::fmt::Display::fmt(self.syntax(), f) | 3589 | std::fmt::Display::fmt(self.syntax(), f) |
5056 | } | 3590 | } |
5057 | } | 3591 | } |
5058 | impl std::fmt::Display for FnPointerType { | 3592 | impl std::fmt::Display for WhereClause { |
5059 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3593 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5060 | std::fmt::Display::fmt(self.syntax(), f) | 3594 | std::fmt::Display::fmt(self.syntax(), f) |
5061 | } | 3595 | } |
5062 | } | 3596 | } |
5063 | impl std::fmt::Display for ForType { | 3597 | impl std::fmt::Display for BlockExpr { |
5064 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3598 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5065 | std::fmt::Display::fmt(self.syntax(), f) | 3599 | std::fmt::Display::fmt(self.syntax(), f) |
5066 | } | 3600 | } |
5067 | } | 3601 | } |
5068 | impl std::fmt::Display for ImplTraitType { | 3602 | impl std::fmt::Display for SelfParam { |
5069 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3603 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5070 | std::fmt::Display::fmt(self.syntax(), f) | 3604 | std::fmt::Display::fmt(self.syntax(), f) |
5071 | } | 3605 | } |
5072 | } | 3606 | } |
5073 | impl std::fmt::Display for DynTraitType { | 3607 | impl std::fmt::Display for Param { |
5074 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3608 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5075 | std::fmt::Display::fmt(self.syntax(), f) | 3609 | std::fmt::Display::fmt(self.syntax(), f) |
5076 | } | 3610 | } |
5077 | } | 3611 | } |
5078 | impl std::fmt::Display for TupleExpr { | 3612 | impl std::fmt::Display for TypeBoundList { |
5079 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3613 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5080 | std::fmt::Display::fmt(self.syntax(), f) | 3614 | std::fmt::Display::fmt(self.syntax(), f) |
5081 | } | 3615 | } |
5082 | } | 3616 | } |
5083 | impl std::fmt::Display for ArrayExpr { | 3617 | impl std::fmt::Display for RecordFieldList { |
5084 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3618 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5085 | std::fmt::Display::fmt(self.syntax(), f) | 3619 | std::fmt::Display::fmt(self.syntax(), f) |
5086 | } | 3620 | } |
5087 | } | 3621 | } |
5088 | impl std::fmt::Display for ParenExpr { | 3622 | impl std::fmt::Display for TupleFieldList { |
5089 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3623 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5090 | std::fmt::Display::fmt(self.syntax(), f) | 3624 | std::fmt::Display::fmt(self.syntax(), f) |
5091 | } | 3625 | } |
5092 | } | 3626 | } |
5093 | impl std::fmt::Display for PathExpr { | 3627 | impl std::fmt::Display for RecordField { |
5094 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3628 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5095 | std::fmt::Display::fmt(self.syntax(), f) | 3629 | std::fmt::Display::fmt(self.syntax(), f) |
5096 | } | 3630 | } |
5097 | } | 3631 | } |
5098 | impl std::fmt::Display for LambdaExpr { | 3632 | impl std::fmt::Display for TupleField { |
5099 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3633 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5100 | std::fmt::Display::fmt(self.syntax(), f) | 3634 | std::fmt::Display::fmt(self.syntax(), f) |
5101 | } | 3635 | } |
5102 | } | 3636 | } |
5103 | impl std::fmt::Display for IfExpr { | 3637 | impl std::fmt::Display for VariantList { |
5104 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3638 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5105 | std::fmt::Display::fmt(self.syntax(), f) | 3639 | std::fmt::Display::fmt(self.syntax(), f) |
5106 | } | 3640 | } |
5107 | } | 3641 | } |
5108 | impl std::fmt::Display for LoopExpr { | 3642 | impl std::fmt::Display for Variant { |
5109 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3643 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5110 | std::fmt::Display::fmt(self.syntax(), f) | 3644 | std::fmt::Display::fmt(self.syntax(), f) |
5111 | } | 3645 | } |
5112 | } | 3646 | } |
5113 | impl std::fmt::Display for EffectExpr { | 3647 | impl std::fmt::Display for AssocItemList { |
5114 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3648 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5115 | std::fmt::Display::fmt(self.syntax(), f) | 3649 | std::fmt::Display::fmt(self.syntax(), f) |
5116 | } | 3650 | } |
5117 | } | 3651 | } |
5118 | impl std::fmt::Display for ForExpr { | 3652 | impl std::fmt::Display for ExternItemList { |
5119 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3653 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5120 | std::fmt::Display::fmt(self.syntax(), f) | 3654 | std::fmt::Display::fmt(self.syntax(), f) |
5121 | } | 3655 | } |
5122 | } | 3656 | } |
5123 | impl std::fmt::Display for WhileExpr { | 3657 | impl std::fmt::Display for LifetimeParam { |
5124 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3658 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5125 | std::fmt::Display::fmt(self.syntax(), f) | 3659 | std::fmt::Display::fmt(self.syntax(), f) |
5126 | } | 3660 | } |
5127 | } | 3661 | } |
5128 | impl std::fmt::Display for ContinueExpr { | 3662 | impl std::fmt::Display for TypeParam { |
5129 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3663 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5130 | std::fmt::Display::fmt(self.syntax(), f) | 3664 | std::fmt::Display::fmt(self.syntax(), f) |
5131 | } | 3665 | } |
5132 | } | 3666 | } |
5133 | impl std::fmt::Display for BreakExpr { | 3667 | impl std::fmt::Display for ConstParam { |
5134 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3668 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5135 | std::fmt::Display::fmt(self.syntax(), f) | 3669 | std::fmt::Display::fmt(self.syntax(), f) |
5136 | } | 3670 | } |
5137 | } | 3671 | } |
5138 | impl std::fmt::Display for Label { | 3672 | impl std::fmt::Display for Literal { |
5139 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3673 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5140 | std::fmt::Display::fmt(self.syntax(), f) | 3674 | std::fmt::Display::fmt(self.syntax(), f) |
5141 | } | 3675 | } |
5142 | } | 3676 | } |
5143 | impl std::fmt::Display for BlockExpr { | 3677 | impl std::fmt::Display for TokenTree { |
5144 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3678 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5145 | std::fmt::Display::fmt(self.syntax(), f) | 3679 | std::fmt::Display::fmt(self.syntax(), f) |
5146 | } | 3680 | } |
5147 | } | 3681 | } |
5148 | impl std::fmt::Display for ReturnExpr { | 3682 | impl std::fmt::Display for ParenType { |
5149 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3683 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5150 | std::fmt::Display::fmt(self.syntax(), f) | 3684 | std::fmt::Display::fmt(self.syntax(), f) |
5151 | } | 3685 | } |
5152 | } | 3686 | } |
5153 | impl std::fmt::Display for CallExpr { | 3687 | impl std::fmt::Display for TupleType { |
5154 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3688 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5155 | std::fmt::Display::fmt(self.syntax(), f) | 3689 | std::fmt::Display::fmt(self.syntax(), f) |
5156 | } | 3690 | } |
5157 | } | 3691 | } |
5158 | impl std::fmt::Display for MethodCallExpr { | 3692 | impl std::fmt::Display for NeverType { |
5159 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3693 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5160 | std::fmt::Display::fmt(self.syntax(), f) | 3694 | std::fmt::Display::fmt(self.syntax(), f) |
5161 | } | 3695 | } |
5162 | } | 3696 | } |
5163 | impl std::fmt::Display for IndexExpr { | 3697 | impl std::fmt::Display for PathType { |
5164 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3698 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5165 | std::fmt::Display::fmt(self.syntax(), f) | 3699 | std::fmt::Display::fmt(self.syntax(), f) |
5166 | } | 3700 | } |
5167 | } | 3701 | } |
5168 | impl std::fmt::Display for FieldExpr { | 3702 | impl std::fmt::Display for PointerType { |
5169 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3703 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5170 | std::fmt::Display::fmt(self.syntax(), f) | 3704 | std::fmt::Display::fmt(self.syntax(), f) |
5171 | } | 3705 | } |
5172 | } | 3706 | } |
5173 | impl std::fmt::Display for AwaitExpr { | 3707 | impl std::fmt::Display for ArrayType { |
5174 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3708 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5175 | std::fmt::Display::fmt(self.syntax(), f) | 3709 | std::fmt::Display::fmt(self.syntax(), f) |
5176 | } | 3710 | } |
5177 | } | 3711 | } |
5178 | impl std::fmt::Display for TryExpr { | 3712 | impl std::fmt::Display for SliceType { |
5179 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3713 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5180 | std::fmt::Display::fmt(self.syntax(), f) | 3714 | std::fmt::Display::fmt(self.syntax(), f) |
5181 | } | 3715 | } |
5182 | } | 3716 | } |
5183 | impl std::fmt::Display for CastExpr { | 3717 | impl std::fmt::Display for ReferenceType { |
5184 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3718 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5185 | std::fmt::Display::fmt(self.syntax(), f) | 3719 | std::fmt::Display::fmt(self.syntax(), f) |
5186 | } | 3720 | } |
5187 | } | 3721 | } |
5188 | impl std::fmt::Display for RefExpr { | 3722 | impl std::fmt::Display for PlaceholderType { |
5189 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3723 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5190 | std::fmt::Display::fmt(self.syntax(), f) | 3724 | std::fmt::Display::fmt(self.syntax(), f) |
5191 | } | 3725 | } |
5192 | } | 3726 | } |
5193 | impl std::fmt::Display for PrefixExpr { | 3727 | impl std::fmt::Display for FnPointerType { |
5194 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3728 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5195 | std::fmt::Display::fmt(self.syntax(), f) | 3729 | std::fmt::Display::fmt(self.syntax(), f) |
5196 | } | 3730 | } |
5197 | } | 3731 | } |
5198 | impl std::fmt::Display for BoxExpr { | 3732 | impl std::fmt::Display for ForType { |
5199 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3733 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5200 | std::fmt::Display::fmt(self.syntax(), f) | 3734 | std::fmt::Display::fmt(self.syntax(), f) |
5201 | } | 3735 | } |
5202 | } | 3736 | } |
5203 | impl std::fmt::Display for RangeExpr { | 3737 | impl std::fmt::Display for ImplTraitType { |
5204 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3738 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5205 | std::fmt::Display::fmt(self.syntax(), f) | 3739 | std::fmt::Display::fmt(self.syntax(), f) |
5206 | } | 3740 | } |
5207 | } | 3741 | } |
5208 | impl std::fmt::Display for BinExpr { | 3742 | impl std::fmt::Display for DynTraitType { |
5209 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3743 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5210 | std::fmt::Display::fmt(self.syntax(), f) | 3744 | std::fmt::Display::fmt(self.syntax(), f) |
5211 | } | 3745 | } |
5212 | } | 3746 | } |
5213 | impl std::fmt::Display for Literal { | 3747 | impl std::fmt::Display for TupleExpr { |
5214 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3748 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5215 | std::fmt::Display::fmt(self.syntax(), f) | 3749 | std::fmt::Display::fmt(self.syntax(), f) |
5216 | } | 3750 | } |
5217 | } | 3751 | } |
5218 | impl std::fmt::Display for MatchExpr { | 3752 | impl std::fmt::Display for ArrayExpr { |
5219 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3753 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5220 | std::fmt::Display::fmt(self.syntax(), f) | 3754 | std::fmt::Display::fmt(self.syntax(), f) |
5221 | } | 3755 | } |
5222 | } | 3756 | } |
5223 | impl std::fmt::Display for MatchArmList { | 3757 | impl std::fmt::Display for ParenExpr { |
5224 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3758 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5225 | std::fmt::Display::fmt(self.syntax(), f) | 3759 | std::fmt::Display::fmt(self.syntax(), f) |
5226 | } | 3760 | } |
5227 | } | 3761 | } |
5228 | impl std::fmt::Display for MatchArm { | 3762 | impl std::fmt::Display for PathExpr { |
5229 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3763 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5230 | std::fmt::Display::fmt(self.syntax(), f) | 3764 | std::fmt::Display::fmt(self.syntax(), f) |
5231 | } | 3765 | } |
5232 | } | 3766 | } |
5233 | impl std::fmt::Display for MatchGuard { | 3767 | impl std::fmt::Display for LambdaExpr { |
5234 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3768 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5235 | std::fmt::Display::fmt(self.syntax(), f) | 3769 | std::fmt::Display::fmt(self.syntax(), f) |
5236 | } | 3770 | } |
5237 | } | 3771 | } |
5238 | impl std::fmt::Display for RecordLit { | 3772 | impl std::fmt::Display for IfExpr { |
5239 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3773 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5240 | std::fmt::Display::fmt(self.syntax(), f) | 3774 | std::fmt::Display::fmt(self.syntax(), f) |
5241 | } | 3775 | } |
5242 | } | 3776 | } |
5243 | impl std::fmt::Display for RecordFieldList { | 3777 | impl std::fmt::Display for Condition { |
5244 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3778 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5245 | std::fmt::Display::fmt(self.syntax(), f) | 3779 | std::fmt::Display::fmt(self.syntax(), f) |
5246 | } | 3780 | } |
5247 | } | 3781 | } |
5248 | impl std::fmt::Display for RecordField { | 3782 | impl std::fmt::Display for EffectExpr { |
5249 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3783 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5250 | std::fmt::Display::fmt(self.syntax(), f) | 3784 | std::fmt::Display::fmt(self.syntax(), f) |
5251 | } | 3785 | } |
5252 | } | 3786 | } |
5253 | impl std::fmt::Display for OrPat { | 3787 | impl std::fmt::Display for Label { |
5254 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3788 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5255 | std::fmt::Display::fmt(self.syntax(), f) | 3789 | std::fmt::Display::fmt(self.syntax(), f) |
5256 | } | 3790 | } |
5257 | } | 3791 | } |
5258 | impl std::fmt::Display for ParenPat { | 3792 | impl std::fmt::Display for LoopExpr { |
5259 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3793 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5260 | std::fmt::Display::fmt(self.syntax(), f) | 3794 | std::fmt::Display::fmt(self.syntax(), f) |
5261 | } | 3795 | } |
5262 | } | 3796 | } |
5263 | impl std::fmt::Display for RefPat { | 3797 | impl std::fmt::Display for ForExpr { |
5264 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3798 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5265 | std::fmt::Display::fmt(self.syntax(), f) | 3799 | std::fmt::Display::fmt(self.syntax(), f) |
5266 | } | 3800 | } |
5267 | } | 3801 | } |
5268 | impl std::fmt::Display for BoxPat { | 3802 | impl std::fmt::Display for WhileExpr { |
5269 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3803 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5270 | std::fmt::Display::fmt(self.syntax(), f) | 3804 | std::fmt::Display::fmt(self.syntax(), f) |
5271 | } | 3805 | } |
5272 | } | 3806 | } |
5273 | impl std::fmt::Display for BindPat { | 3807 | impl std::fmt::Display for ContinueExpr { |
5274 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3808 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5275 | std::fmt::Display::fmt(self.syntax(), f) | 3809 | std::fmt::Display::fmt(self.syntax(), f) |
5276 | } | 3810 | } |
5277 | } | 3811 | } |
5278 | impl std::fmt::Display for PlaceholderPat { | 3812 | impl std::fmt::Display for BreakExpr { |
5279 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3813 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5280 | std::fmt::Display::fmt(self.syntax(), f) | 3814 | std::fmt::Display::fmt(self.syntax(), f) |
5281 | } | 3815 | } |
5282 | } | 3816 | } |
5283 | impl std::fmt::Display for DotDotPat { | 3817 | impl std::fmt::Display for ReturnExpr { |
5284 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3818 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5285 | std::fmt::Display::fmt(self.syntax(), f) | 3819 | std::fmt::Display::fmt(self.syntax(), f) |
5286 | } | 3820 | } |
5287 | } | 3821 | } |
5288 | impl std::fmt::Display for PathPat { | 3822 | impl std::fmt::Display for CallExpr { |
5289 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3823 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5290 | std::fmt::Display::fmt(self.syntax(), f) | 3824 | std::fmt::Display::fmt(self.syntax(), f) |
5291 | } | 3825 | } |
5292 | } | 3826 | } |
5293 | impl std::fmt::Display for SlicePat { | 3827 | impl std::fmt::Display for ArgList { |
5294 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3828 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5295 | std::fmt::Display::fmt(self.syntax(), f) | 3829 | std::fmt::Display::fmt(self.syntax(), f) |
5296 | } | 3830 | } |
5297 | } | 3831 | } |
5298 | impl std::fmt::Display for RangePat { | 3832 | impl std::fmt::Display for MethodCallExpr { |
5299 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3833 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5300 | std::fmt::Display::fmt(self.syntax(), f) | 3834 | std::fmt::Display::fmt(self.syntax(), f) |
5301 | } | 3835 | } |
5302 | } | 3836 | } |
5303 | impl std::fmt::Display for LiteralPat { | 3837 | impl std::fmt::Display for TypeArgList { |
5304 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3838 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5305 | std::fmt::Display::fmt(self.syntax(), f) | 3839 | std::fmt::Display::fmt(self.syntax(), f) |
5306 | } | 3840 | } |
5307 | } | 3841 | } |
5308 | impl std::fmt::Display for MacroPat { | 3842 | impl std::fmt::Display for FieldExpr { |
5309 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3843 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5310 | std::fmt::Display::fmt(self.syntax(), f) | 3844 | std::fmt::Display::fmt(self.syntax(), f) |
5311 | } | 3845 | } |
5312 | } | 3846 | } |
5313 | impl std::fmt::Display for RecordPat { | 3847 | impl std::fmt::Display for IndexExpr { |
5314 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3848 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5315 | std::fmt::Display::fmt(self.syntax(), f) | 3849 | std::fmt::Display::fmt(self.syntax(), f) |
5316 | } | 3850 | } |
5317 | } | 3851 | } |
5318 | impl std::fmt::Display for RecordFieldPatList { | 3852 | impl std::fmt::Display for AwaitExpr { |
5319 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3853 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5320 | std::fmt::Display::fmt(self.syntax(), f) | 3854 | std::fmt::Display::fmt(self.syntax(), f) |
5321 | } | 3855 | } |
5322 | } | 3856 | } |
5323 | impl std::fmt::Display for RecordFieldPat { | 3857 | impl std::fmt::Display for TryExpr { |
5324 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3858 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5325 | std::fmt::Display::fmt(self.syntax(), f) | 3859 | std::fmt::Display::fmt(self.syntax(), f) |
5326 | } | 3860 | } |
5327 | } | 3861 | } |
5328 | impl std::fmt::Display for TupleStructPat { | 3862 | impl std::fmt::Display for CastExpr { |
5329 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3863 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5330 | std::fmt::Display::fmt(self.syntax(), f) | 3864 | std::fmt::Display::fmt(self.syntax(), f) |
5331 | } | 3865 | } |
5332 | } | 3866 | } |
5333 | impl std::fmt::Display for TuplePat { | 3867 | impl std::fmt::Display for RefExpr { |
5334 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3868 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5335 | std::fmt::Display::fmt(self.syntax(), f) | 3869 | std::fmt::Display::fmt(self.syntax(), f) |
5336 | } | 3870 | } |
5337 | } | 3871 | } |
5338 | impl std::fmt::Display for Visibility { | 3872 | impl std::fmt::Display for PrefixExpr { |
5339 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3873 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5340 | std::fmt::Display::fmt(self.syntax(), f) | 3874 | std::fmt::Display::fmt(self.syntax(), f) |
5341 | } | 3875 | } |
5342 | } | 3876 | } |
5343 | impl std::fmt::Display for Name { | 3877 | impl std::fmt::Display for BoxExpr { |
5344 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3878 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5345 | std::fmt::Display::fmt(self.syntax(), f) | 3879 | std::fmt::Display::fmt(self.syntax(), f) |
5346 | } | 3880 | } |
5347 | } | 3881 | } |
5348 | impl std::fmt::Display for NameRef { | 3882 | impl std::fmt::Display for RangeExpr { |
5349 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3883 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5350 | std::fmt::Display::fmt(self.syntax(), f) | 3884 | std::fmt::Display::fmt(self.syntax(), f) |
5351 | } | 3885 | } |
5352 | } | 3886 | } |
5353 | impl std::fmt::Display for MacroCall { | 3887 | impl std::fmt::Display for BinExpr { |
5354 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3888 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5355 | std::fmt::Display::fmt(self.syntax(), f) | 3889 | std::fmt::Display::fmt(self.syntax(), f) |
5356 | } | 3890 | } |
5357 | } | 3891 | } |
5358 | impl std::fmt::Display for Attr { | 3892 | impl std::fmt::Display for MatchExpr { |
5359 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3893 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5360 | std::fmt::Display::fmt(self.syntax(), f) | 3894 | std::fmt::Display::fmt(self.syntax(), f) |
5361 | } | 3895 | } |
5362 | } | 3896 | } |
5363 | impl std::fmt::Display for TokenTree { | 3897 | impl std::fmt::Display for MatchArmList { |
5364 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3898 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5365 | std::fmt::Display::fmt(self.syntax(), f) | 3899 | std::fmt::Display::fmt(self.syntax(), f) |
5366 | } | 3900 | } |
5367 | } | 3901 | } |
5368 | impl std::fmt::Display for TypeParamList { | 3902 | impl std::fmt::Display for MatchArm { |
5369 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3903 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5370 | std::fmt::Display::fmt(self.syntax(), f) | 3904 | std::fmt::Display::fmt(self.syntax(), f) |
5371 | } | 3905 | } |
5372 | } | 3906 | } |
5373 | impl std::fmt::Display for TypeParam { | 3907 | impl std::fmt::Display for MatchGuard { |
5374 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3908 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5375 | std::fmt::Display::fmt(self.syntax(), f) | 3909 | std::fmt::Display::fmt(self.syntax(), f) |
5376 | } | 3910 | } |
5377 | } | 3911 | } |
5378 | impl std::fmt::Display for ConstParam { | 3912 | impl std::fmt::Display for RecordExpr { |
5379 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3913 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5380 | std::fmt::Display::fmt(self.syntax(), f) | 3914 | std::fmt::Display::fmt(self.syntax(), f) |
5381 | } | 3915 | } |
5382 | } | 3916 | } |
5383 | impl std::fmt::Display for LifetimeParam { | 3917 | impl std::fmt::Display for RecordExprFieldList { |
5384 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3918 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5385 | std::fmt::Display::fmt(self.syntax(), f) | 3919 | std::fmt::Display::fmt(self.syntax(), f) |
5386 | } | 3920 | } |
5387 | } | 3921 | } |
5388 | impl std::fmt::Display for TypeBound { | 3922 | impl std::fmt::Display for RecordExprField { |
5389 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3923 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5390 | std::fmt::Display::fmt(self.syntax(), f) | 3924 | std::fmt::Display::fmt(self.syntax(), f) |
5391 | } | 3925 | } |
5392 | } | 3926 | } |
5393 | impl std::fmt::Display for TypeBoundList { | 3927 | impl std::fmt::Display for OrPat { |
5394 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3928 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5395 | std::fmt::Display::fmt(self.syntax(), f) | 3929 | std::fmt::Display::fmt(self.syntax(), f) |
5396 | } | 3930 | } |
5397 | } | 3931 | } |
5398 | impl std::fmt::Display for WherePred { | 3932 | impl std::fmt::Display for ParenPat { |
5399 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3933 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5400 | std::fmt::Display::fmt(self.syntax(), f) | 3934 | std::fmt::Display::fmt(self.syntax(), f) |
5401 | } | 3935 | } |
5402 | } | 3936 | } |
5403 | impl std::fmt::Display for WhereClause { | 3937 | impl std::fmt::Display for RefPat { |
5404 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3938 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5405 | std::fmt::Display::fmt(self.syntax(), f) | 3939 | std::fmt::Display::fmt(self.syntax(), f) |
5406 | } | 3940 | } |
5407 | } | 3941 | } |
5408 | impl std::fmt::Display for Abi { | 3942 | impl std::fmt::Display for BoxPat { |
5409 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3943 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5410 | std::fmt::Display::fmt(self.syntax(), f) | 3944 | std::fmt::Display::fmt(self.syntax(), f) |
5411 | } | 3945 | } |
5412 | } | 3946 | } |
5413 | impl std::fmt::Display for ExprStmt { | 3947 | impl std::fmt::Display for BindPat { |
5414 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3948 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5415 | std::fmt::Display::fmt(self.syntax(), f) | 3949 | std::fmt::Display::fmt(self.syntax(), f) |
5416 | } | 3950 | } |
5417 | } | 3951 | } |
5418 | impl std::fmt::Display for LetStmt { | 3952 | impl std::fmt::Display for PlaceholderPat { |
5419 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3953 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5420 | std::fmt::Display::fmt(self.syntax(), f) | 3954 | std::fmt::Display::fmt(self.syntax(), f) |
5421 | } | 3955 | } |
5422 | } | 3956 | } |
5423 | impl std::fmt::Display for Condition { | 3957 | impl std::fmt::Display for DotDotPat { |
5424 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3958 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5425 | std::fmt::Display::fmt(self.syntax(), f) | 3959 | std::fmt::Display::fmt(self.syntax(), f) |
5426 | } | 3960 | } |
5427 | } | 3961 | } |
5428 | impl std::fmt::Display for ParamList { | 3962 | impl std::fmt::Display for PathPat { |
5429 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3963 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5430 | std::fmt::Display::fmt(self.syntax(), f) | 3964 | std::fmt::Display::fmt(self.syntax(), f) |
5431 | } | 3965 | } |
5432 | } | 3966 | } |
5433 | impl std::fmt::Display for SelfParam { | 3967 | impl std::fmt::Display for SlicePat { |
5434 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3968 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5435 | std::fmt::Display::fmt(self.syntax(), f) | 3969 | std::fmt::Display::fmt(self.syntax(), f) |
5436 | } | 3970 | } |
5437 | } | 3971 | } |
5438 | impl std::fmt::Display for Param { | 3972 | impl std::fmt::Display for RangePat { |
5439 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3973 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5440 | std::fmt::Display::fmt(self.syntax(), f) | 3974 | std::fmt::Display::fmt(self.syntax(), f) |
5441 | } | 3975 | } |
5442 | } | 3976 | } |
5443 | impl std::fmt::Display for UseItem { | 3977 | impl std::fmt::Display for LiteralPat { |
5444 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3978 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5445 | std::fmt::Display::fmt(self.syntax(), f) | 3979 | std::fmt::Display::fmt(self.syntax(), f) |
5446 | } | 3980 | } |
5447 | } | 3981 | } |
5448 | impl std::fmt::Display for UseTree { | 3982 | impl std::fmt::Display for MacroPat { |
5449 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3983 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5450 | std::fmt::Display::fmt(self.syntax(), f) | 3984 | std::fmt::Display::fmt(self.syntax(), f) |
5451 | } | 3985 | } |
5452 | } | 3986 | } |
5453 | impl std::fmt::Display for Alias { | 3987 | impl std::fmt::Display for RecordPat { |
5454 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3988 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5455 | std::fmt::Display::fmt(self.syntax(), f) | 3989 | std::fmt::Display::fmt(self.syntax(), f) |
5456 | } | 3990 | } |
5457 | } | 3991 | } |
5458 | impl std::fmt::Display for UseTreeList { | 3992 | impl std::fmt::Display for RecordFieldPatList { |
5459 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3993 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5460 | std::fmt::Display::fmt(self.syntax(), f) | 3994 | std::fmt::Display::fmt(self.syntax(), f) |
5461 | } | 3995 | } |
5462 | } | 3996 | } |
5463 | impl std::fmt::Display for ExternCrateItem { | 3997 | impl std::fmt::Display for RecordFieldPat { |
5464 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3998 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5465 | std::fmt::Display::fmt(self.syntax(), f) | 3999 | std::fmt::Display::fmt(self.syntax(), f) |
5466 | } | 4000 | } |
5467 | } | 4001 | } |
5468 | impl std::fmt::Display for ArgList { | 4002 | impl std::fmt::Display for TupleStructPat { |
5469 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 4003 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5470 | std::fmt::Display::fmt(self.syntax(), f) | 4004 | std::fmt::Display::fmt(self.syntax(), f) |
5471 | } | 4005 | } |
5472 | } | 4006 | } |
5473 | impl std::fmt::Display for Path { | 4007 | impl std::fmt::Display for TuplePat { |
5474 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 4008 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5475 | std::fmt::Display::fmt(self.syntax(), f) | 4009 | std::fmt::Display::fmt(self.syntax(), f) |
5476 | } | 4010 | } |
5477 | } | 4011 | } |
5478 | impl std::fmt::Display for PathSegment { | 4012 | impl std::fmt::Display for MacroDef { |
5479 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 4013 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5480 | std::fmt::Display::fmt(self.syntax(), f) | 4014 | std::fmt::Display::fmt(self.syntax(), f) |
5481 | } | 4015 | } |
5482 | } | 4016 | } |
5483 | impl std::fmt::Display for TypeArgList { | 4017 | impl std::fmt::Display for MacroItems { |
5484 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 4018 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5485 | std::fmt::Display::fmt(self.syntax(), f) | 4019 | std::fmt::Display::fmt(self.syntax(), f) |
5486 | } | 4020 | } |
5487 | } | 4021 | } |
5488 | impl std::fmt::Display for TypeArg { | 4022 | impl std::fmt::Display for MacroStmts { |
5489 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 4023 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5490 | std::fmt::Display::fmt(self.syntax(), f) | 4024 | std::fmt::Display::fmt(self.syntax(), f) |
5491 | } | 4025 | } |
5492 | } | 4026 | } |
5493 | impl std::fmt::Display for AssocTypeArg { | 4027 | impl std::fmt::Display for TypeBound { |
5494 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 4028 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5495 | std::fmt::Display::fmt(self.syntax(), f) | 4029 | std::fmt::Display::fmt(self.syntax(), f) |
5496 | } | 4030 | } |
5497 | } | 4031 | } |
5498 | impl std::fmt::Display for LifetimeArg { | 4032 | impl std::fmt::Display for WherePred { |
5499 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 4033 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5500 | std::fmt::Display::fmt(self.syntax(), f) | 4034 | std::fmt::Display::fmt(self.syntax(), f) |
5501 | } | 4035 | } |
5502 | } | 4036 | } |
5503 | impl std::fmt::Display for ConstArg { | 4037 | impl std::fmt::Display for ExprStmt { |
5504 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 4038 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5505 | std::fmt::Display::fmt(self.syntax(), f) | 4039 | std::fmt::Display::fmt(self.syntax(), f) |
5506 | } | 4040 | } |
5507 | } | 4041 | } |
5508 | impl std::fmt::Display for MacroItems { | 4042 | impl std::fmt::Display for LetStmt { |
5509 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 4043 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5510 | std::fmt::Display::fmt(self.syntax(), f) | 4044 | std::fmt::Display::fmt(self.syntax(), f) |
5511 | } | 4045 | } |
5512 | } | 4046 | } |
5513 | impl std::fmt::Display for MacroStmts { | 4047 | impl std::fmt::Display for PathSegment { |
5514 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 4048 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5515 | std::fmt::Display::fmt(self.syntax(), f) | 4049 | std::fmt::Display::fmt(self.syntax(), f) |
5516 | } | 4050 | } |
5517 | } | 4051 | } |
5518 | impl std::fmt::Display for ExternItemList { | 4052 | impl std::fmt::Display for TypeArg { |
5519 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 4053 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5520 | std::fmt::Display::fmt(self.syntax(), f) | 4054 | std::fmt::Display::fmt(self.syntax(), f) |
5521 | } | 4055 | } |
5522 | } | 4056 | } |
5523 | impl std::fmt::Display for ExternBlock { | 4057 | impl std::fmt::Display for LifetimeArg { |
5524 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 4058 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5525 | std::fmt::Display::fmt(self.syntax(), f) | 4059 | std::fmt::Display::fmt(self.syntax(), f) |
5526 | } | 4060 | } |
5527 | } | 4061 | } |
5528 | impl std::fmt::Display for MetaItem { | 4062 | impl std::fmt::Display for AssocTypeArg { |
5529 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 4063 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5530 | std::fmt::Display::fmt(self.syntax(), f) | 4064 | std::fmt::Display::fmt(self.syntax(), f) |
5531 | } | 4065 | } |
5532 | } | 4066 | } |
5533 | impl std::fmt::Display for MacroDef { | 4067 | impl std::fmt::Display for ConstArg { |
5534 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 4068 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
5535 | std::fmt::Display::fmt(self.syntax(), f) | 4069 | std::fmt::Display::fmt(self.syntax(), f) |
5536 | } | 4070 | } |
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs index 192c610f1..509e8ae7a 100644 --- a/crates/ra_syntax/src/ast/make.rs +++ b/crates/ra_syntax/src/ast/make.rs | |||
@@ -37,7 +37,7 @@ fn path_from_text(text: &str) -> ast::Path { | |||
37 | pub fn use_tree( | 37 | pub fn use_tree( |
38 | path: ast::Path, | 38 | path: ast::Path, |
39 | use_tree_list: Option<ast::UseTreeList>, | 39 | use_tree_list: Option<ast::UseTreeList>, |
40 | alias: Option<ast::Alias>, | 40 | alias: Option<ast::Rename>, |
41 | add_star: bool, | 41 | add_star: bool, |
42 | ) -> ast::UseTree { | 42 | ) -> ast::UseTree { |
43 | let mut buf = "use ".to_string(); | 43 | let mut buf = "use ".to_string(); |
@@ -60,22 +60,22 @@ pub fn use_tree_list(use_trees: impl IntoIterator<Item = ast::UseTree>) -> ast:: | |||
60 | ast_from_text(&format!("use {{{}}};", use_trees)) | 60 | ast_from_text(&format!("use {{{}}};", use_trees)) |
61 | } | 61 | } |
62 | 62 | ||
63 | pub fn use_item(use_tree: ast::UseTree) -> ast::UseItem { | 63 | pub fn use_item(use_tree: ast::UseTree) -> ast::Use { |
64 | ast_from_text(&format!("use {};", use_tree)) | 64 | ast_from_text(&format!("use {};", use_tree)) |
65 | } | 65 | } |
66 | 66 | ||
67 | pub fn record_field(name: ast::NameRef, expr: Option<ast::Expr>) -> ast::RecordField { | 67 | pub fn record_field(name: ast::NameRef, expr: Option<ast::Expr>) -> ast::RecordExprField { |
68 | return match expr { | 68 | return match expr { |
69 | Some(expr) => from_text(&format!("{}: {}", name, expr)), | 69 | Some(expr) => from_text(&format!("{}: {}", name, expr)), |
70 | None => from_text(&name.to_string()), | 70 | None => from_text(&name.to_string()), |
71 | }; | 71 | }; |
72 | 72 | ||
73 | fn from_text(text: &str) -> ast::RecordField { | 73 | fn from_text(text: &str) -> ast::RecordExprField { |
74 | ast_from_text(&format!("fn f() {{ S {{ {}, }} }}", text)) | 74 | ast_from_text(&format!("fn f() {{ S {{ {}, }} }}", text)) |
75 | } | 75 | } |
76 | } | 76 | } |
77 | 77 | ||
78 | pub fn record_field_def(name: ast::NameRef, ty: ast::TypeRef) -> ast::RecordFieldDef { | 78 | pub fn record_field_def(name: ast::NameRef, ty: ast::TypeRef) -> ast::RecordField { |
79 | ast_from_text(&format!("struct S {{ {}: {}, }}", name, ty)) | 79 | ast_from_text(&format!("struct S {{ {}: {}, }}", name, ty)) |
80 | } | 80 | } |
81 | 81 | ||
@@ -291,10 +291,10 @@ pub fn visibility_pub_crate() -> ast::Visibility { | |||
291 | pub fn fn_def( | 291 | pub fn fn_def( |
292 | visibility: Option<ast::Visibility>, | 292 | visibility: Option<ast::Visibility>, |
293 | fn_name: ast::Name, | 293 | fn_name: ast::Name, |
294 | type_params: Option<ast::TypeParamList>, | 294 | type_params: Option<ast::GenericParamList>, |
295 | params: ast::ParamList, | 295 | params: ast::ParamList, |
296 | body: ast::BlockExpr, | 296 | body: ast::BlockExpr, |
297 | ) -> ast::FnDef { | 297 | ) -> ast::Fn { |
298 | let type_params = | 298 | let type_params = |
299 | if let Some(type_params) = type_params { format!("<{}>", type_params) } else { "".into() }; | 299 | if let Some(type_params) = type_params { format!("<{}>", type_params) } else { "".into() }; |
300 | let visibility = match visibility { | 300 | let visibility = match visibility { |
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/node_ext.rs index 662c6f73e..bba7310ad 100644 --- a/crates/ra_syntax/src/ast/extensions.rs +++ b/crates/ra_syntax/src/ast/node_ext.rs | |||
@@ -7,7 +7,7 @@ use itertools::Itertools; | |||
7 | use ra_parser::SyntaxKind; | 7 | use ra_parser::SyntaxKind; |
8 | 8 | ||
9 | use crate::{ | 9 | use crate::{ |
10 | ast::{self, support, AstNode, AttrInput, NameOwner, SyntaxNode}, | 10 | ast::{self, support, AstNode, NameOwner, SyntaxNode}, |
11 | SmolStr, SyntaxElement, SyntaxToken, T, | 11 | SmolStr, SyntaxElement, SyntaxToken, T, |
12 | }; | 12 | }; |
13 | 13 | ||
@@ -39,29 +39,23 @@ pub enum AttrKind { | |||
39 | 39 | ||
40 | impl ast::Attr { | 40 | impl ast::Attr { |
41 | pub fn as_simple_atom(&self) -> Option<SmolStr> { | 41 | pub fn as_simple_atom(&self) -> Option<SmolStr> { |
42 | match self.input() { | 42 | if self.eq_token().is_some() || self.token_tree().is_some() { |
43 | None => self.simple_name(), | 43 | return None; |
44 | Some(_) => None, | ||
45 | } | 44 | } |
45 | self.simple_name() | ||
46 | } | 46 | } |
47 | 47 | ||
48 | pub fn as_simple_call(&self) -> Option<(SmolStr, ast::TokenTree)> { | 48 | pub fn as_simple_call(&self) -> Option<(SmolStr, ast::TokenTree)> { |
49 | match self.input() { | 49 | let tt = self.token_tree()?; |
50 | Some(AttrInput::TokenTree(tt)) => Some((self.simple_name()?, tt)), | 50 | Some((self.simple_name()?, tt)) |
51 | _ => None, | ||
52 | } | ||
53 | } | 51 | } |
54 | 52 | ||
55 | pub fn as_simple_key_value(&self) -> Option<(SmolStr, SmolStr)> { | 53 | pub fn as_simple_key_value(&self) -> Option<(SmolStr, SmolStr)> { |
56 | match self.input() { | 54 | let lit = self.literal()?; |
57 | Some(AttrInput::Literal(lit)) => { | 55 | let key = self.simple_name()?; |
58 | let key = self.simple_name()?; | 56 | // FIXME: escape? raw string? |
59 | // FIXME: escape? raw string? | 57 | let value = lit.syntax().first_token()?.text().trim_matches('"').into(); |
60 | let value = lit.syntax().first_token()?.text().trim_matches('"').into(); | 58 | Some((key, value)) |
61 | Some((key, value)) | ||
62 | } | ||
63 | _ => None, | ||
64 | } | ||
65 | } | 59 | } |
66 | 60 | ||
67 | pub fn simple_name(&self) -> Option<SmolStr> { | 61 | pub fn simple_name(&self) -> Option<SmolStr> { |
@@ -141,7 +135,7 @@ impl ast::UseTreeList { | |||
141 | } | 135 | } |
142 | } | 136 | } |
143 | 137 | ||
144 | impl ast::ImplDef { | 138 | impl ast::Impl { |
145 | pub fn target_type(&self) -> Option<ast::TypeRef> { | 139 | pub fn target_type(&self) -> Option<ast::TypeRef> { |
146 | match self.target() { | 140 | match self.target() { |
147 | (Some(t), None) | (_, Some(t)) => Some(t), | 141 | (Some(t), None) | (_, Some(t)) => Some(t), |
@@ -166,16 +160,16 @@ impl ast::ImplDef { | |||
166 | 160 | ||
167 | #[derive(Debug, Clone, PartialEq, Eq)] | 161 | #[derive(Debug, Clone, PartialEq, Eq)] |
168 | pub enum StructKind { | 162 | pub enum StructKind { |
169 | Record(ast::RecordFieldDefList), | 163 | Record(ast::RecordFieldList), |
170 | Tuple(ast::TupleFieldDefList), | 164 | Tuple(ast::TupleFieldList), |
171 | Unit, | 165 | Unit, |
172 | } | 166 | } |
173 | 167 | ||
174 | impl StructKind { | 168 | impl StructKind { |
175 | fn from_node<N: AstNode>(node: &N) -> StructKind { | 169 | fn from_node<N: AstNode>(node: &N) -> StructKind { |
176 | if let Some(nfdl) = support::child::<ast::RecordFieldDefList>(node.syntax()) { | 170 | if let Some(nfdl) = support::child::<ast::RecordFieldList>(node.syntax()) { |
177 | StructKind::Record(nfdl) | 171 | StructKind::Record(nfdl) |
178 | } else if let Some(pfl) = support::child::<ast::TupleFieldDefList>(node.syntax()) { | 172 | } else if let Some(pfl) = support::child::<ast::TupleFieldList>(node.syntax()) { |
179 | StructKind::Tuple(pfl) | 173 | StructKind::Tuple(pfl) |
180 | } else { | 174 | } else { |
181 | StructKind::Unit | 175 | StructKind::Unit |
@@ -183,17 +177,17 @@ impl StructKind { | |||
183 | } | 177 | } |
184 | } | 178 | } |
185 | 179 | ||
186 | impl ast::StructDef { | 180 | impl ast::Struct { |
187 | pub fn kind(&self) -> StructKind { | 181 | pub fn kind(&self) -> StructKind { |
188 | StructKind::from_node(self) | 182 | StructKind::from_node(self) |
189 | } | 183 | } |
190 | } | 184 | } |
191 | 185 | ||
192 | impl ast::RecordField { | 186 | impl ast::RecordExprField { |
193 | pub fn for_field_name(field_name: &ast::NameRef) -> Option<ast::RecordField> { | 187 | pub fn for_field_name(field_name: &ast::NameRef) -> Option<ast::RecordExprField> { |
194 | let candidate = | 188 | let candidate = |
195 | field_name.syntax().parent().and_then(ast::RecordField::cast).or_else(|| { | 189 | field_name.syntax().parent().and_then(ast::RecordExprField::cast).or_else(|| { |
196 | field_name.syntax().ancestors().nth(4).and_then(ast::RecordField::cast) | 190 | field_name.syntax().ancestors().nth(4).and_then(ast::RecordExprField::cast) |
197 | })?; | 191 | })?; |
198 | if candidate.field_name().as_ref() == Some(field_name) { | 192 | if candidate.field_name().as_ref() == Some(field_name) { |
199 | Some(candidate) | 193 | Some(candidate) |
@@ -247,12 +241,12 @@ impl ast::RecordFieldPat { | |||
247 | } | 241 | } |
248 | } | 242 | } |
249 | 243 | ||
250 | impl ast::EnumVariant { | 244 | impl ast::Variant { |
251 | pub fn parent_enum(&self) -> ast::EnumDef { | 245 | pub fn parent_enum(&self) -> ast::Enum { |
252 | self.syntax() | 246 | self.syntax() |
253 | .parent() | 247 | .parent() |
254 | .and_then(|it| it.parent()) | 248 | .and_then(|it| it.parent()) |
255 | .and_then(ast::EnumDef::cast) | 249 | .and_then(ast::Enum::cast) |
256 | .expect("EnumVariants are always nested in Enums") | 250 | .expect("EnumVariants are always nested in Enums") |
257 | } | 251 | } |
258 | pub fn kind(&self) -> StructKind { | 252 | pub fn kind(&self) -> StructKind { |
@@ -472,3 +466,40 @@ impl ast::TokenTree { | |||
472 | .filter(|it| matches!(it.kind(), T!['}'] | T![')'] | T![']'])) | 466 | .filter(|it| matches!(it.kind(), T!['}'] | T![')'] | T![']'])) |
473 | } | 467 | } |
474 | } | 468 | } |
469 | |||
470 | impl ast::GenericParamList { | ||
471 | pub fn lifetime_params(&self) -> impl Iterator<Item = ast::LifetimeParam> { | ||
472 | self.generic_params().filter_map(|param| match param { | ||
473 | ast::GenericParam::LifetimeParam(it) => Some(it), | ||
474 | ast::GenericParam::TypeParam(_) | ast::GenericParam::ConstParam(_) => None, | ||
475 | }) | ||
476 | } | ||
477 | pub fn type_params(&self) -> impl Iterator<Item = ast::TypeParam> { | ||
478 | self.generic_params().filter_map(|param| match param { | ||
479 | ast::GenericParam::TypeParam(it) => Some(it), | ||
480 | ast::GenericParam::LifetimeParam(_) | ast::GenericParam::ConstParam(_) => None, | ||
481 | }) | ||
482 | } | ||
483 | pub fn const_params(&self) -> impl Iterator<Item = ast::ConstParam> { | ||
484 | self.generic_params().filter_map(|param| match param { | ||
485 | ast::GenericParam::ConstParam(it) => Some(it), | ||
486 | ast::GenericParam::TypeParam(_) | ast::GenericParam::LifetimeParam(_) => None, | ||
487 | }) | ||
488 | } | ||
489 | } | ||
490 | |||
491 | impl ast::DocCommentsOwner for ast::SourceFile {} | ||
492 | impl ast::DocCommentsOwner for ast::Fn {} | ||
493 | impl ast::DocCommentsOwner for ast::Struct {} | ||
494 | impl ast::DocCommentsOwner for ast::Union {} | ||
495 | impl ast::DocCommentsOwner for ast::RecordField {} | ||
496 | impl ast::DocCommentsOwner for ast::TupleField {} | ||
497 | impl ast::DocCommentsOwner for ast::Enum {} | ||
498 | impl ast::DocCommentsOwner for ast::Variant {} | ||
499 | impl ast::DocCommentsOwner for ast::Trait {} | ||
500 | impl ast::DocCommentsOwner for ast::Module {} | ||
501 | impl ast::DocCommentsOwner for ast::Static {} | ||
502 | impl ast::DocCommentsOwner for ast::Const {} | ||
503 | impl ast::DocCommentsOwner for ast::TypeAlias {} | ||
504 | impl ast::DocCommentsOwner for ast::Impl {} | ||
505 | impl ast::DocCommentsOwner for ast::MacroCall {} | ||
diff --git a/crates/ra_syntax/src/ast/tokens.rs b/crates/ra_syntax/src/ast/token_ext.rs index 2e72d4927..c5ef92733 100644 --- a/crates/ra_syntax/src/ast/tokens.rs +++ b/crates/ra_syntax/src/ast/token_ext.rs | |||
@@ -1,12 +1,16 @@ | |||
1 | //! There are many AstNodes, but only a few tokens, so we hand-write them here. | 1 | //! There are many AstNodes, but only a few tokens, so we hand-write them here. |
2 | 2 | ||
3 | use std::convert::{TryFrom, TryInto}; | 3 | use std::{ |
4 | borrow::Cow, | ||
5 | convert::{TryFrom, TryInto}, | ||
6 | }; | ||
7 | |||
8 | use rustc_lexer::unescape::{unescape_literal, Mode}; | ||
4 | 9 | ||
5 | use crate::{ | 10 | use crate::{ |
6 | ast::{AstToken, Comment, RawString, String, Whitespace}, | 11 | ast::{AstToken, Comment, RawString, String, Whitespace}, |
7 | TextRange, TextSize, | 12 | TextRange, TextSize, |
8 | }; | 13 | }; |
9 | use rustc_lexer::unescape::{unescape_literal, Mode}; | ||
10 | 14 | ||
11 | impl Comment { | 15 | impl Comment { |
12 | pub fn kind(&self) -> CommentKind { | 16 | pub fn kind(&self) -> CommentKind { |
@@ -138,11 +142,11 @@ impl HasQuotes for String {} | |||
138 | impl HasQuotes for RawString {} | 142 | impl HasQuotes for RawString {} |
139 | 143 | ||
140 | pub trait HasStringValue: HasQuotes { | 144 | pub trait HasStringValue: HasQuotes { |
141 | fn value(&self) -> Option<std::string::String>; | 145 | fn value(&self) -> Option<Cow<'_, str>>; |
142 | } | 146 | } |
143 | 147 | ||
144 | impl HasStringValue for String { | 148 | impl HasStringValue for String { |
145 | fn value(&self) -> Option<std::string::String> { | 149 | fn value(&self) -> Option<Cow<'_, str>> { |
146 | let text = self.text().as_str(); | 150 | let text = self.text().as_str(); |
147 | let text = &text[self.text_range_between_quotes()? - self.syntax().text_range().start()]; | 151 | let text = &text[self.text_range_between_quotes()? - self.syntax().text_range().start()]; |
148 | 152 | ||
@@ -156,15 +160,17 @@ impl HasStringValue for String { | |||
156 | if has_error { | 160 | if has_error { |
157 | return None; | 161 | return None; |
158 | } | 162 | } |
159 | Some(buf) | 163 | // FIXME: don't actually allocate for borrowed case |
164 | let res = if buf == text { Cow::Borrowed(text) } else { Cow::Owned(buf) }; | ||
165 | Some(res) | ||
160 | } | 166 | } |
161 | } | 167 | } |
162 | 168 | ||
163 | impl HasStringValue for RawString { | 169 | impl HasStringValue for RawString { |
164 | fn value(&self) -> Option<std::string::String> { | 170 | fn value(&self) -> Option<Cow<'_, str>> { |
165 | let text = self.text().as_str(); | 171 | let text = self.text().as_str(); |
166 | let text = &text[self.text_range_between_quotes()? - self.syntax().text_range().start()]; | 172 | let text = &text[self.text_range_between_quotes()? - self.syntax().text_range().start()]; |
167 | Some(text.to_string()) | 173 | Some(Cow::Borrowed(text)) |
168 | } | 174 | } |
169 | } | 175 | } |
170 | 176 | ||
diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs index a8f2454fd..3a56b1674 100644 --- a/crates/ra_syntax/src/ast/traits.rs +++ b/crates/ra_syntax/src/ast/traits.rs | |||
@@ -9,12 +9,6 @@ use crate::{ | |||
9 | SyntaxToken, T, | 9 | SyntaxToken, T, |
10 | }; | 10 | }; |
11 | 11 | ||
12 | pub trait TypeAscriptionOwner: AstNode { | ||
13 | fn ascribed_type(&self) -> Option<ast::TypeRef> { | ||
14 | support::child(self.syntax()) | ||
15 | } | ||
16 | } | ||
17 | |||
18 | pub trait NameOwner: AstNode { | 12 | pub trait NameOwner: AstNode { |
19 | fn name(&self) -> Option<ast::Name> { | 13 | fn name(&self) -> Option<ast::Name> { |
20 | support::child(self.syntax()) | 14 | support::child(self.syntax()) |
@@ -44,13 +38,13 @@ pub trait ArgListOwner: AstNode { | |||
44 | } | 38 | } |
45 | 39 | ||
46 | pub trait ModuleItemOwner: AstNode { | 40 | pub trait ModuleItemOwner: AstNode { |
47 | fn items(&self) -> AstChildren<ast::ModuleItem> { | 41 | fn items(&self) -> AstChildren<ast::Item> { |
48 | support::children(self.syntax()) | 42 | support::children(self.syntax()) |
49 | } | 43 | } |
50 | } | 44 | } |
51 | 45 | ||
52 | pub trait TypeParamsOwner: AstNode { | 46 | pub trait GenericParamsOwner: AstNode { |
53 | fn type_param_list(&self) -> Option<ast::TypeParamList> { | 47 | fn generic_param_list(&self) -> Option<ast::GenericParamList> { |
54 | support::child(self.syntax()) | 48 | support::child(self.syntax()) |
55 | } | 49 | } |
56 | 50 | ||