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