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