diff options
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r-- | crates/ra_syntax/src/ast/edit.rs | 8 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated/nodes.rs | 1251 |
2 files changed, 650 insertions, 609 deletions
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs index 8d3e42f25..04746ef8f 100644 --- a/crates/ra_syntax/src/ast/edit.rs +++ b/crates/ra_syntax/src/ast/edit.rs | |||
@@ -237,17 +237,17 @@ impl ast::Path { | |||
237 | 237 | ||
238 | impl ast::PathSegment { | 238 | impl ast::PathSegment { |
239 | #[must_use] | 239 | #[must_use] |
240 | pub fn with_type_args(&self, type_args: ast::TypeArgList) -> ast::PathSegment { | 240 | pub fn with_type_args(&self, type_args: ast::GenericArgList) -> ast::PathSegment { |
241 | self._with_type_args(type_args, false) | 241 | self._with_type_args(type_args, false) |
242 | } | 242 | } |
243 | 243 | ||
244 | #[must_use] | 244 | #[must_use] |
245 | pub fn with_turbo_fish(&self, type_args: ast::TypeArgList) -> ast::PathSegment { | 245 | pub fn with_turbo_fish(&self, type_args: ast::GenericArgList) -> ast::PathSegment { |
246 | self._with_type_args(type_args, true) | 246 | self._with_type_args(type_args, true) |
247 | } | 247 | } |
248 | 248 | ||
249 | fn _with_type_args(&self, type_args: ast::TypeArgList, turbo: bool) -> ast::PathSegment { | 249 | fn _with_type_args(&self, type_args: ast::GenericArgList, turbo: bool) -> ast::PathSegment { |
250 | if let Some(old) = self.type_arg_list() { | 250 | if let Some(old) = self.generic_arg_list() { |
251 | return self.replace_children( | 251 | return self.replace_children( |
252 | single_node(old.syntax().clone()), | 252 | single_node(old.syntax().clone()), |
253 | iter::once(type_args.syntax().clone().into()), | 253 | iter::once(type_args.syntax().clone().into()), |
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 3f075a5f8..6ce9c4adc 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs | |||
@@ -6,6 +6,116 @@ use crate::{ | |||
6 | SyntaxNode, SyntaxToken, T, | 6 | SyntaxNode, SyntaxToken, T, |
7 | }; | 7 | }; |
8 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 8 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
9 | pub struct Path { | ||
10 | pub(crate) syntax: SyntaxNode, | ||
11 | } | ||
12 | impl Path { | ||
13 | pub fn qualifier(&self) -> Option<Path> { support::child(&self.syntax) } | ||
14 | pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) } | ||
15 | pub fn segment(&self) -> Option<PathSegment> { support::child(&self.syntax) } | ||
16 | } | ||
17 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
18 | pub struct PathSegment { | ||
19 | pub(crate) syntax: SyntaxNode, | ||
20 | } | ||
21 | impl PathSegment { | ||
22 | pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) } | ||
23 | pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) } | ||
24 | pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) } | ||
25 | pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) } | ||
26 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | ||
27 | pub fn generic_arg_list(&self) -> Option<GenericArgList> { support::child(&self.syntax) } | ||
28 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } | ||
29 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } | ||
30 | pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) } | ||
31 | pub fn path_type(&self) -> Option<PathType> { support::child(&self.syntax) } | ||
32 | pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) } | ||
33 | pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) } | ||
34 | } | ||
35 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
36 | pub struct NameRef { | ||
37 | pub(crate) syntax: SyntaxNode, | ||
38 | } | ||
39 | impl NameRef { | ||
40 | pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) } | ||
41 | } | ||
42 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
43 | pub struct GenericArgList { | ||
44 | pub(crate) syntax: SyntaxNode, | ||
45 | } | ||
46 | impl GenericArgList { | ||
47 | pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) } | ||
48 | pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) } | ||
49 | pub fn generic_args(&self) -> AstChildren<GenericArg> { support::children(&self.syntax) } | ||
50 | pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) } | ||
51 | } | ||
52 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
53 | pub struct ParamList { | ||
54 | pub(crate) syntax: SyntaxNode, | ||
55 | } | ||
56 | impl ParamList { | ||
57 | pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } | ||
58 | pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) } | ||
59 | pub fn comma_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![,]) } | ||
60 | pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) } | ||
61 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | ||
62 | } | ||
63 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
64 | pub struct RetType { | ||
65 | pub(crate) syntax: SyntaxNode, | ||
66 | } | ||
67 | impl RetType { | ||
68 | pub fn thin_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![->]) } | ||
69 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } | ||
70 | } | ||
71 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
72 | pub struct PathType { | ||
73 | pub(crate) syntax: SyntaxNode, | ||
74 | } | ||
75 | impl PathType { | ||
76 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } | ||
77 | } | ||
78 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
79 | pub struct TypeArg { | ||
80 | pub(crate) syntax: SyntaxNode, | ||
81 | } | ||
82 | impl TypeArg { | ||
83 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } | ||
84 | } | ||
85 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
86 | pub struct AssocTypeArg { | ||
87 | pub(crate) syntax: SyntaxNode, | ||
88 | } | ||
89 | impl ast::TypeBoundsOwner for AssocTypeArg {} | ||
90 | impl AssocTypeArg { | ||
91 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | ||
92 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | ||
93 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } | ||
94 | } | ||
95 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
96 | pub struct LifetimeArg { | ||
97 | pub(crate) syntax: SyntaxNode, | ||
98 | } | ||
99 | impl LifetimeArg { | ||
100 | pub fn lifetime_token(&self) -> Option<SyntaxToken> { | ||
101 | support::token(&self.syntax, T![lifetime]) | ||
102 | } | ||
103 | } | ||
104 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
105 | pub struct ConstArg { | ||
106 | pub(crate) syntax: SyntaxNode, | ||
107 | } | ||
108 | impl ConstArg { | ||
109 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
110 | } | ||
111 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
112 | pub struct TypeBoundList { | ||
113 | pub(crate) syntax: SyntaxNode, | ||
114 | } | ||
115 | impl TypeBoundList { | ||
116 | pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) } | ||
117 | } | ||
118 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
9 | pub struct SourceFile { | 119 | pub struct SourceFile { |
10 | pub(crate) syntax: SyntaxNode, | 120 | pub(crate) syntax: SyntaxNode, |
11 | } | 121 | } |
@@ -256,13 +366,6 @@ impl ItemList { | |||
256 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | 366 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } |
257 | } | 367 | } |
258 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 368 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
259 | pub struct NameRef { | ||
260 | pub(crate) syntax: SyntaxNode, | ||
261 | } | ||
262 | impl NameRef { | ||
263 | pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) } | ||
264 | } | ||
265 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
266 | pub struct Rename { | 369 | pub struct Rename { |
267 | pub(crate) syntax: SyntaxNode, | 370 | pub(crate) syntax: SyntaxNode, |
268 | } | 371 | } |
@@ -283,15 +386,6 @@ impl UseTree { | |||
283 | pub fn rename(&self) -> Option<Rename> { support::child(&self.syntax) } | 386 | pub fn rename(&self) -> Option<Rename> { support::child(&self.syntax) } |
284 | } | 387 | } |
285 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 388 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
286 | pub struct Path { | ||
287 | pub(crate) syntax: SyntaxNode, | ||
288 | } | ||
289 | impl Path { | ||
290 | pub fn qualifier(&self) -> Option<Path> { support::child(&self.syntax) } | ||
291 | pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) } | ||
292 | pub fn segment(&self) -> Option<PathSegment> { support::child(&self.syntax) } | ||
293 | } | ||
294 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
295 | pub struct UseTreeList { | 389 | pub struct UseTreeList { |
296 | pub(crate) syntax: SyntaxNode, | 390 | pub(crate) syntax: SyntaxNode, |
297 | } | 391 | } |
@@ -317,25 +411,6 @@ impl GenericParamList { | |||
317 | pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) } | 411 | pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) } |
318 | } | 412 | } |
319 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 413 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
320 | pub struct ParamList { | ||
321 | pub(crate) syntax: SyntaxNode, | ||
322 | } | ||
323 | impl ParamList { | ||
324 | pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } | ||
325 | pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) } | ||
326 | pub fn comma_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![,]) } | ||
327 | pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) } | ||
328 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | ||
329 | } | ||
330 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
331 | pub struct RetType { | ||
332 | pub(crate) syntax: SyntaxNode, | ||
333 | } | ||
334 | impl RetType { | ||
335 | pub fn thin_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![->]) } | ||
336 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } | ||
337 | } | ||
338 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
339 | pub struct WhereClause { | 414 | pub struct WhereClause { |
340 | pub(crate) syntax: SyntaxNode, | 415 | pub(crate) syntax: SyntaxNode, |
341 | } | 416 | } |
@@ -381,13 +456,6 @@ impl Param { | |||
381 | pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) } | 456 | pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) } |
382 | } | 457 | } |
383 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 458 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
384 | pub struct TypeBoundList { | ||
385 | pub(crate) syntax: SyntaxNode, | ||
386 | } | ||
387 | impl TypeBoundList { | ||
388 | pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) } | ||
389 | } | ||
390 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
391 | pub struct RecordFieldList { | 459 | pub struct RecordFieldList { |
392 | pub(crate) syntax: SyntaxNode, | 460 | pub(crate) syntax: SyntaxNode, |
393 | } | 461 | } |
@@ -624,6 +692,19 @@ impl CastExpr { | |||
624 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } | 692 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } |
625 | } | 693 | } |
626 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 694 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
695 | pub struct ClosureExpr { | ||
696 | pub(crate) syntax: SyntaxNode, | ||
697 | } | ||
698 | impl ast::AttrsOwner for ClosureExpr {} | ||
699 | impl ClosureExpr { | ||
700 | pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) } | ||
701 | pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) } | ||
702 | pub fn move_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![move]) } | ||
703 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } | ||
704 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } | ||
705 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
706 | } | ||
707 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
627 | pub struct ContinueExpr { | 708 | pub struct ContinueExpr { |
628 | pub(crate) syntax: SyntaxNode, | 709 | pub(crate) syntax: SyntaxNode, |
629 | } | 710 | } |
@@ -690,28 +771,6 @@ impl IndexExpr { | |||
690 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } | 771 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } |
691 | } | 772 | } |
692 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 773 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
693 | pub struct Label { | ||
694 | pub(crate) syntax: SyntaxNode, | ||
695 | } | ||
696 | impl Label { | ||
697 | pub fn lifetime_token(&self) -> Option<SyntaxToken> { | ||
698 | support::token(&self.syntax, T![lifetime]) | ||
699 | } | ||
700 | } | ||
701 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
702 | pub struct ClosureExpr { | ||
703 | pub(crate) syntax: SyntaxNode, | ||
704 | } | ||
705 | impl ast::AttrsOwner for ClosureExpr {} | ||
706 | impl ClosureExpr { | ||
707 | pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) } | ||
708 | pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) } | ||
709 | pub fn move_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![move]) } | ||
710 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } | ||
711 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } | ||
712 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
713 | } | ||
714 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
715 | pub struct LoopExpr { | 774 | pub struct LoopExpr { |
716 | pub(crate) syntax: SyntaxNode, | 775 | pub(crate) syntax: SyntaxNode, |
717 | } | 776 | } |
@@ -740,7 +799,7 @@ impl MethodCallExpr { | |||
740 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 799 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
741 | pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) } | 800 | pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) } |
742 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | 801 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } |
743 | pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) } | 802 | pub fn generic_arg_list(&self) -> Option<GenericArgList> { support::child(&self.syntax) } |
744 | } | 803 | } |
745 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 804 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
746 | pub struct ParenExpr { | 805 | pub struct ParenExpr { |
@@ -835,6 +894,15 @@ impl WhileExpr { | |||
835 | pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } | 894 | pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } |
836 | } | 895 | } |
837 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 896 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
897 | pub struct Label { | ||
898 | pub(crate) syntax: SyntaxNode, | ||
899 | } | ||
900 | impl Label { | ||
901 | pub fn lifetime_token(&self) -> Option<SyntaxToken> { | ||
902 | support::token(&self.syntax, T![lifetime]) | ||
903 | } | ||
904 | } | ||
905 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
838 | pub struct RecordExprFieldList { | 906 | pub struct RecordExprFieldList { |
839 | pub(crate) syntax: SyntaxNode, | 907 | pub(crate) syntax: SyntaxNode, |
840 | } | 908 | } |
@@ -866,19 +934,6 @@ impl ArgList { | |||
866 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | 934 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } |
867 | } | 935 | } |
868 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 936 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
869 | pub struct TypeArgList { | ||
870 | pub(crate) syntax: SyntaxNode, | ||
871 | } | ||
872 | impl TypeArgList { | ||
873 | pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) } | ||
874 | pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) } | ||
875 | pub fn type_args(&self) -> AstChildren<TypeArg> { support::children(&self.syntax) } | ||
876 | pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> { support::children(&self.syntax) } | ||
877 | pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> { support::children(&self.syntax) } | ||
878 | pub fn const_args(&self) -> AstChildren<ConstArg> { support::children(&self.syntax) } | ||
879 | pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) } | ||
880 | } | ||
881 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
882 | pub struct Condition { | 937 | pub struct Condition { |
883 | pub(crate) syntax: SyntaxNode, | 938 | pub(crate) syntax: SyntaxNode, |
884 | } | 939 | } |
@@ -991,13 +1046,6 @@ impl ParenType { | |||
991 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | 1046 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } |
992 | } | 1047 | } |
993 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1048 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
994 | pub struct PathType { | ||
995 | pub(crate) syntax: SyntaxNode, | ||
996 | } | ||
997 | impl PathType { | ||
998 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } | ||
999 | } | ||
1000 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1001 | pub struct PointerType { | 1049 | pub struct PointerType { |
1002 | pub(crate) syntax: SyntaxNode, | 1050 | pub(crate) syntax: SyntaxNode, |
1003 | } | 1051 | } |
@@ -1212,75 +1260,13 @@ impl MacroStmts { | |||
1212 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 1260 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
1213 | } | 1261 | } |
1214 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1262 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1215 | pub struct PathSegment { | 1263 | pub enum GenericArg { |
1216 | pub(crate) syntax: SyntaxNode, | 1264 | TypeArg(TypeArg), |
1217 | } | 1265 | AssocTypeArg(AssocTypeArg), |
1218 | impl PathSegment { | 1266 | LifetimeArg(LifetimeArg), |
1219 | pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) } | 1267 | ConstArg(ConstArg), |
1220 | pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) } | ||
1221 | pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) } | ||
1222 | pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) } | ||
1223 | pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) } | ||
1224 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | ||
1225 | pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) } | ||
1226 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } | ||
1227 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } | ||
1228 | pub fn path_type(&self) -> Option<PathType> { support::child(&self.syntax) } | ||
1229 | pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) } | ||
1230 | } | ||
1231 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1232 | pub struct TypeArg { | ||
1233 | pub(crate) syntax: SyntaxNode, | ||
1234 | } | ||
1235 | impl TypeArg { | ||
1236 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } | ||
1237 | } | ||
1238 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1239 | pub struct LifetimeArg { | ||
1240 | pub(crate) syntax: SyntaxNode, | ||
1241 | } | ||
1242 | impl LifetimeArg { | ||
1243 | pub fn lifetime_token(&self) -> Option<SyntaxToken> { | ||
1244 | support::token(&self.syntax, T![lifetime]) | ||
1245 | } | ||
1246 | } | ||
1247 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1248 | pub struct AssocTypeArg { | ||
1249 | pub(crate) syntax: SyntaxNode, | ||
1250 | } | ||
1251 | impl ast::TypeBoundsOwner for AssocTypeArg {} | ||
1252 | impl AssocTypeArg { | ||
1253 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | ||
1254 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | ||
1255 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } | ||
1256 | } | ||
1257 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1258 | pub struct ConstArg { | ||
1259 | pub(crate) syntax: SyntaxNode, | ||
1260 | } | ||
1261 | impl ConstArg { | ||
1262 | pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) } | ||
1263 | pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) } | ||
1264 | } | 1268 | } |
1265 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1269 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1266 | pub enum Item { | ||
1267 | Const(Const), | ||
1268 | Enum(Enum), | ||
1269 | ExternBlock(ExternBlock), | ||
1270 | ExternCrate(ExternCrate), | ||
1271 | Fn(Fn), | ||
1272 | Impl(Impl), | ||
1273 | MacroCall(MacroCall), | ||
1274 | Module(Module), | ||
1275 | Static(Static), | ||
1276 | Struct(Struct), | ||
1277 | Trait(Trait), | ||
1278 | TypeAlias(TypeAlias), | ||
1279 | Union(Union), | ||
1280 | Use(Use), | ||
1281 | } | ||
1282 | impl ast::AttrsOwner for Item {} | ||
1283 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1284 | pub enum Type { | 1270 | pub enum Type { |
1285 | ArrayType(ArrayType), | 1271 | ArrayType(ArrayType), |
1286 | DynTraitType(DynTraitType), | 1272 | DynTraitType(DynTraitType), |
@@ -1297,29 +1283,6 @@ pub enum Type { | |||
1297 | TupleType(TupleType), | 1283 | TupleType(TupleType), |
1298 | } | 1284 | } |
1299 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1285 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1300 | pub enum Pat { | ||
1301 | OrPat(OrPat), | ||
1302 | ParenPat(ParenPat), | ||
1303 | RefPat(RefPat), | ||
1304 | BoxPat(BoxPat), | ||
1305 | BindPat(BindPat), | ||
1306 | PlaceholderPat(PlaceholderPat), | ||
1307 | DotDotPat(DotDotPat), | ||
1308 | PathPat(PathPat), | ||
1309 | RecordPat(RecordPat), | ||
1310 | TupleStructPat(TupleStructPat), | ||
1311 | TuplePat(TuplePat), | ||
1312 | SlicePat(SlicePat), | ||
1313 | RangePat(RangePat), | ||
1314 | LiteralPat(LiteralPat), | ||
1315 | MacroPat(MacroPat), | ||
1316 | } | ||
1317 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1318 | pub enum FieldList { | ||
1319 | RecordFieldList(RecordFieldList), | ||
1320 | TupleFieldList(TupleFieldList), | ||
1321 | } | ||
1322 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1323 | pub enum Expr { | 1286 | pub enum Expr { |
1324 | ArrayExpr(ArrayExpr), | 1287 | ArrayExpr(ArrayExpr), |
1325 | AwaitExpr(AwaitExpr), | 1288 | AwaitExpr(AwaitExpr), |
@@ -1329,14 +1292,13 @@ pub enum Expr { | |||
1329 | BreakExpr(BreakExpr), | 1292 | BreakExpr(BreakExpr), |
1330 | CallExpr(CallExpr), | 1293 | CallExpr(CallExpr), |
1331 | CastExpr(CastExpr), | 1294 | CastExpr(CastExpr), |
1295 | ClosureExpr(ClosureExpr), | ||
1332 | ContinueExpr(ContinueExpr), | 1296 | ContinueExpr(ContinueExpr), |
1333 | EffectExpr(EffectExpr), | 1297 | EffectExpr(EffectExpr), |
1334 | FieldExpr(FieldExpr), | 1298 | FieldExpr(FieldExpr), |
1335 | ForExpr(ForExpr), | 1299 | ForExpr(ForExpr), |
1336 | IfExpr(IfExpr), | 1300 | IfExpr(IfExpr), |
1337 | IndexExpr(IndexExpr), | 1301 | IndexExpr(IndexExpr), |
1338 | Label(Label), | ||
1339 | ClosureExpr(ClosureExpr), | ||
1340 | Literal(Literal), | 1302 | Literal(Literal), |
1341 | LoopExpr(LoopExpr), | 1303 | LoopExpr(LoopExpr), |
1342 | MacroCall(MacroCall), | 1304 | MacroCall(MacroCall), |
@@ -1354,6 +1316,47 @@ pub enum Expr { | |||
1354 | WhileExpr(WhileExpr), | 1316 | WhileExpr(WhileExpr), |
1355 | } | 1317 | } |
1356 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1318 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1319 | pub enum Item { | ||
1320 | Const(Const), | ||
1321 | Enum(Enum), | ||
1322 | ExternBlock(ExternBlock), | ||
1323 | ExternCrate(ExternCrate), | ||
1324 | Fn(Fn), | ||
1325 | Impl(Impl), | ||
1326 | MacroCall(MacroCall), | ||
1327 | Module(Module), | ||
1328 | Static(Static), | ||
1329 | Struct(Struct), | ||
1330 | Trait(Trait), | ||
1331 | TypeAlias(TypeAlias), | ||
1332 | Union(Union), | ||
1333 | Use(Use), | ||
1334 | } | ||
1335 | impl ast::AttrsOwner for Item {} | ||
1336 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1337 | pub enum Pat { | ||
1338 | OrPat(OrPat), | ||
1339 | ParenPat(ParenPat), | ||
1340 | RefPat(RefPat), | ||
1341 | BoxPat(BoxPat), | ||
1342 | BindPat(BindPat), | ||
1343 | PlaceholderPat(PlaceholderPat), | ||
1344 | DotDotPat(DotDotPat), | ||
1345 | PathPat(PathPat), | ||
1346 | RecordPat(RecordPat), | ||
1347 | TupleStructPat(TupleStructPat), | ||
1348 | TuplePat(TuplePat), | ||
1349 | SlicePat(SlicePat), | ||
1350 | RangePat(RangePat), | ||
1351 | LiteralPat(LiteralPat), | ||
1352 | MacroPat(MacroPat), | ||
1353 | } | ||
1354 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1355 | pub enum FieldList { | ||
1356 | RecordFieldList(RecordFieldList), | ||
1357 | TupleFieldList(TupleFieldList), | ||
1358 | } | ||
1359 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1357 | pub enum AdtDef { | 1360 | pub enum AdtDef { |
1358 | Enum(Enum), | 1361 | Enum(Enum), |
1359 | Struct(Struct), | 1362 | Struct(Struct), |
@@ -1393,6 +1396,138 @@ pub enum Stmt { | |||
1393 | Item(Item), | 1396 | Item(Item), |
1394 | LetStmt(LetStmt), | 1397 | LetStmt(LetStmt), |
1395 | } | 1398 | } |
1399 | impl AstNode for Path { | ||
1400 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH } | ||
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 AstNode for PathSegment { | ||
1411 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT } | ||
1412 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1413 | if Self::can_cast(syntax.kind()) { | ||
1414 | Some(Self { syntax }) | ||
1415 | } else { | ||
1416 | None | ||
1417 | } | ||
1418 | } | ||
1419 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1420 | } | ||
1421 | impl AstNode for NameRef { | ||
1422 | fn can_cast(kind: SyntaxKind) -> bool { kind == NAME_REF } | ||
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 AstNode for GenericArgList { | ||
1433 | fn can_cast(kind: SyntaxKind) -> bool { kind == GENERIC_ARG_LIST } | ||
1434 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1435 | if Self::can_cast(syntax.kind()) { | ||
1436 | Some(Self { syntax }) | ||
1437 | } else { | ||
1438 | None | ||
1439 | } | ||
1440 | } | ||
1441 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1442 | } | ||
1443 | impl AstNode for ParamList { | ||
1444 | fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM_LIST } | ||
1445 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1446 | if Self::can_cast(syntax.kind()) { | ||
1447 | Some(Self { syntax }) | ||
1448 | } else { | ||
1449 | None | ||
1450 | } | ||
1451 | } | ||
1452 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1453 | } | ||
1454 | impl AstNode for RetType { | ||
1455 | fn can_cast(kind: SyntaxKind) -> bool { kind == RET_TYPE } | ||
1456 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1457 | if Self::can_cast(syntax.kind()) { | ||
1458 | Some(Self { syntax }) | ||
1459 | } else { | ||
1460 | None | ||
1461 | } | ||
1462 | } | ||
1463 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1464 | } | ||
1465 | impl AstNode for PathType { | ||
1466 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_TYPE } | ||
1467 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1468 | if Self::can_cast(syntax.kind()) { | ||
1469 | Some(Self { syntax }) | ||
1470 | } else { | ||
1471 | None | ||
1472 | } | ||
1473 | } | ||
1474 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1475 | } | ||
1476 | impl AstNode for TypeArg { | ||
1477 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG } | ||
1478 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1479 | if Self::can_cast(syntax.kind()) { | ||
1480 | Some(Self { syntax }) | ||
1481 | } else { | ||
1482 | None | ||
1483 | } | ||
1484 | } | ||
1485 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1486 | } | ||
1487 | impl AstNode for AssocTypeArg { | ||
1488 | fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_TYPE_ARG } | ||
1489 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1490 | if Self::can_cast(syntax.kind()) { | ||
1491 | Some(Self { syntax }) | ||
1492 | } else { | ||
1493 | None | ||
1494 | } | ||
1495 | } | ||
1496 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1497 | } | ||
1498 | impl AstNode for LifetimeArg { | ||
1499 | fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_ARG } | ||
1500 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1501 | if Self::can_cast(syntax.kind()) { | ||
1502 | Some(Self { syntax }) | ||
1503 | } else { | ||
1504 | None | ||
1505 | } | ||
1506 | } | ||
1507 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1508 | } | ||
1509 | impl AstNode for ConstArg { | ||
1510 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_ARG } | ||
1511 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1512 | if Self::can_cast(syntax.kind()) { | ||
1513 | Some(Self { syntax }) | ||
1514 | } else { | ||
1515 | None | ||
1516 | } | ||
1517 | } | ||
1518 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1519 | } | ||
1520 | impl AstNode for TypeBoundList { | ||
1521 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST } | ||
1522 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1523 | if Self::can_cast(syntax.kind()) { | ||
1524 | Some(Self { syntax }) | ||
1525 | } else { | ||
1526 | None | ||
1527 | } | ||
1528 | } | ||
1529 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1530 | } | ||
1396 | impl AstNode for SourceFile { | 1531 | impl AstNode for SourceFile { |
1397 | fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE } | 1532 | fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE } |
1398 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1533 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -1602,17 +1737,6 @@ impl AstNode for ItemList { | |||
1602 | } | 1737 | } |
1603 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1738 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1604 | } | 1739 | } |
1605 | impl AstNode for NameRef { | ||
1606 | fn can_cast(kind: SyntaxKind) -> bool { kind == NAME_REF } | ||
1607 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1608 | if Self::can_cast(syntax.kind()) { | ||
1609 | Some(Self { syntax }) | ||
1610 | } else { | ||
1611 | None | ||
1612 | } | ||
1613 | } | ||
1614 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1615 | } | ||
1616 | impl AstNode for Rename { | 1740 | impl AstNode for Rename { |
1617 | fn can_cast(kind: SyntaxKind) -> bool { kind == RENAME } | 1741 | fn can_cast(kind: SyntaxKind) -> bool { kind == RENAME } |
1618 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1742 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -1635,17 +1759,6 @@ impl AstNode for UseTree { | |||
1635 | } | 1759 | } |
1636 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1760 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1637 | } | 1761 | } |
1638 | impl AstNode for Path { | ||
1639 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH } | ||
1640 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1641 | if Self::can_cast(syntax.kind()) { | ||
1642 | Some(Self { syntax }) | ||
1643 | } else { | ||
1644 | None | ||
1645 | } | ||
1646 | } | ||
1647 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1648 | } | ||
1649 | impl AstNode for UseTreeList { | 1762 | impl AstNode for UseTreeList { |
1650 | fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE_LIST } | 1763 | fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE_LIST } |
1651 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1764 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -1679,28 +1792,6 @@ impl AstNode for GenericParamList { | |||
1679 | } | 1792 | } |
1680 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1793 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1681 | } | 1794 | } |
1682 | impl AstNode for ParamList { | ||
1683 | fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM_LIST } | ||
1684 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1685 | if Self::can_cast(syntax.kind()) { | ||
1686 | Some(Self { syntax }) | ||
1687 | } else { | ||
1688 | None | ||
1689 | } | ||
1690 | } | ||
1691 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1692 | } | ||
1693 | impl AstNode for RetType { | ||
1694 | fn can_cast(kind: SyntaxKind) -> bool { kind == RET_TYPE } | ||
1695 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1696 | if Self::can_cast(syntax.kind()) { | ||
1697 | Some(Self { syntax }) | ||
1698 | } else { | ||
1699 | None | ||
1700 | } | ||
1701 | } | ||
1702 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1703 | } | ||
1704 | impl AstNode for WhereClause { | 1795 | impl AstNode for WhereClause { |
1705 | fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_CLAUSE } | 1796 | fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_CLAUSE } |
1706 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1797 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -1745,17 +1836,6 @@ impl AstNode for Param { | |||
1745 | } | 1836 | } |
1746 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1837 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1747 | } | 1838 | } |
1748 | impl AstNode for TypeBoundList { | ||
1749 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST } | ||
1750 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1751 | if Self::can_cast(syntax.kind()) { | ||
1752 | Some(Self { syntax }) | ||
1753 | } else { | ||
1754 | None | ||
1755 | } | ||
1756 | } | ||
1757 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1758 | } | ||
1759 | impl AstNode for RecordFieldList { | 1839 | impl AstNode for RecordFieldList { |
1760 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_LIST } | 1840 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_LIST } |
1761 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1841 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2009,6 +2089,17 @@ impl AstNode for CastExpr { | |||
2009 | } | 2089 | } |
2010 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2090 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2011 | } | 2091 | } |
2092 | impl AstNode for ClosureExpr { | ||
2093 | fn can_cast(kind: SyntaxKind) -> bool { kind == CLOSURE_EXPR } | ||
2094 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2095 | if Self::can_cast(syntax.kind()) { | ||
2096 | Some(Self { syntax }) | ||
2097 | } else { | ||
2098 | None | ||
2099 | } | ||
2100 | } | ||
2101 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2102 | } | ||
2012 | impl AstNode for ContinueExpr { | 2103 | impl AstNode for ContinueExpr { |
2013 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONTINUE_EXPR } | 2104 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONTINUE_EXPR } |
2014 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2105 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2075,28 +2166,6 @@ impl AstNode for IndexExpr { | |||
2075 | } | 2166 | } |
2076 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2167 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2077 | } | 2168 | } |
2078 | impl AstNode for Label { | ||
2079 | fn can_cast(kind: SyntaxKind) -> bool { kind == LABEL } | ||
2080 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2081 | if Self::can_cast(syntax.kind()) { | ||
2082 | Some(Self { syntax }) | ||
2083 | } else { | ||
2084 | None | ||
2085 | } | ||
2086 | } | ||
2087 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2088 | } | ||
2089 | impl AstNode for ClosureExpr { | ||
2090 | fn can_cast(kind: SyntaxKind) -> bool { kind == CLOSURE_EXPR } | ||
2091 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2092 | if Self::can_cast(syntax.kind()) { | ||
2093 | Some(Self { syntax }) | ||
2094 | } else { | ||
2095 | None | ||
2096 | } | ||
2097 | } | ||
2098 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2099 | } | ||
2100 | impl AstNode for LoopExpr { | 2169 | impl AstNode for LoopExpr { |
2101 | fn can_cast(kind: SyntaxKind) -> bool { kind == LOOP_EXPR } | 2170 | fn can_cast(kind: SyntaxKind) -> bool { kind == LOOP_EXPR } |
2102 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2171 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2240,8 +2309,8 @@ impl AstNode for WhileExpr { | |||
2240 | } | 2309 | } |
2241 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2310 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2242 | } | 2311 | } |
2243 | impl AstNode for RecordExprFieldList { | 2312 | impl AstNode for Label { |
2244 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR_FIELD_LIST } | 2313 | fn can_cast(kind: SyntaxKind) -> bool { kind == LABEL } |
2245 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2314 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
2246 | if Self::can_cast(syntax.kind()) { | 2315 | if Self::can_cast(syntax.kind()) { |
2247 | Some(Self { syntax }) | 2316 | Some(Self { syntax }) |
@@ -2251,8 +2320,8 @@ impl AstNode for RecordExprFieldList { | |||
2251 | } | 2320 | } |
2252 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2321 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2253 | } | 2322 | } |
2254 | impl AstNode for RecordExprField { | 2323 | impl AstNode for RecordExprFieldList { |
2255 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR_FIELD } | 2324 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR_FIELD_LIST } |
2256 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2325 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
2257 | if Self::can_cast(syntax.kind()) { | 2326 | if Self::can_cast(syntax.kind()) { |
2258 | Some(Self { syntax }) | 2327 | Some(Self { syntax }) |
@@ -2262,8 +2331,8 @@ impl AstNode for RecordExprField { | |||
2262 | } | 2331 | } |
2263 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2332 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2264 | } | 2333 | } |
2265 | impl AstNode for ArgList { | 2334 | impl AstNode for RecordExprField { |
2266 | fn can_cast(kind: SyntaxKind) -> bool { kind == ARG_LIST } | 2335 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR_FIELD } |
2267 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2336 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
2268 | if Self::can_cast(syntax.kind()) { | 2337 | if Self::can_cast(syntax.kind()) { |
2269 | Some(Self { syntax }) | 2338 | Some(Self { syntax }) |
@@ -2273,8 +2342,8 @@ impl AstNode for ArgList { | |||
2273 | } | 2342 | } |
2274 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2343 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2275 | } | 2344 | } |
2276 | impl AstNode for TypeArgList { | 2345 | impl AstNode for ArgList { |
2277 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG_LIST } | 2346 | fn can_cast(kind: SyntaxKind) -> bool { kind == ARG_LIST } |
2278 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2347 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
2279 | if Self::can_cast(syntax.kind()) { | 2348 | if Self::can_cast(syntax.kind()) { |
2280 | Some(Self { syntax }) | 2349 | Some(Self { syntax }) |
@@ -2416,17 +2485,6 @@ impl AstNode for ParenType { | |||
2416 | } | 2485 | } |
2417 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2486 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2418 | } | 2487 | } |
2419 | impl AstNode for PathType { | ||
2420 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_TYPE } | ||
2421 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2422 | if Self::can_cast(syntax.kind()) { | ||
2423 | Some(Self { syntax }) | ||
2424 | } else { | ||
2425 | None | ||
2426 | } | ||
2427 | } | ||
2428 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2429 | } | ||
2430 | impl AstNode for PointerType { | 2488 | impl AstNode for PointerType { |
2431 | fn can_cast(kind: SyntaxKind) -> bool { kind == POINTER_TYPE } | 2489 | fn can_cast(kind: SyntaxKind) -> bool { kind == POINTER_TYPE } |
2432 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2490 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2691,147 +2749,41 @@ impl AstNode for MacroStmts { | |||
2691 | } | 2749 | } |
2692 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2750 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2693 | } | 2751 | } |
2694 | impl AstNode for PathSegment { | 2752 | impl From<TypeArg> for GenericArg { |
2695 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT } | 2753 | fn from(node: TypeArg) -> GenericArg { GenericArg::TypeArg(node) } |
2696 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2697 | if Self::can_cast(syntax.kind()) { | ||
2698 | Some(Self { syntax }) | ||
2699 | } else { | ||
2700 | None | ||
2701 | } | ||
2702 | } | ||
2703 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2704 | } | 2754 | } |
2705 | impl AstNode for TypeArg { | 2755 | impl From<AssocTypeArg> for GenericArg { |
2706 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG } | 2756 | fn from(node: AssocTypeArg) -> GenericArg { GenericArg::AssocTypeArg(node) } |
2707 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2708 | if Self::can_cast(syntax.kind()) { | ||
2709 | Some(Self { syntax }) | ||
2710 | } else { | ||
2711 | None | ||
2712 | } | ||
2713 | } | ||
2714 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2715 | } | ||
2716 | impl AstNode for LifetimeArg { | ||
2717 | fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_ARG } | ||
2718 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2719 | if Self::can_cast(syntax.kind()) { | ||
2720 | Some(Self { syntax }) | ||
2721 | } else { | ||
2722 | None | ||
2723 | } | ||
2724 | } | ||
2725 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2726 | } | ||
2727 | impl AstNode for AssocTypeArg { | ||
2728 | fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_TYPE_ARG } | ||
2729 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2730 | if Self::can_cast(syntax.kind()) { | ||
2731 | Some(Self { syntax }) | ||
2732 | } else { | ||
2733 | None | ||
2734 | } | ||
2735 | } | ||
2736 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2737 | } | 2757 | } |
2738 | impl AstNode for ConstArg { | 2758 | impl From<LifetimeArg> for GenericArg { |
2739 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_ARG } | 2759 | fn from(node: LifetimeArg) -> GenericArg { GenericArg::LifetimeArg(node) } |
2740 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2741 | if Self::can_cast(syntax.kind()) { | ||
2742 | Some(Self { syntax }) | ||
2743 | } else { | ||
2744 | None | ||
2745 | } | ||
2746 | } | ||
2747 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2748 | } | 2760 | } |
2749 | impl From<Const> for Item { | 2761 | impl From<ConstArg> for GenericArg { |
2750 | fn from(node: Const) -> Item { Item::Const(node) } | 2762 | fn from(node: ConstArg) -> GenericArg { GenericArg::ConstArg(node) } |
2751 | } | ||
2752 | impl From<Enum> for Item { | ||
2753 | fn from(node: Enum) -> Item { Item::Enum(node) } | ||
2754 | } | 2763 | } |
2755 | impl From<ExternBlock> for Item { | 2764 | impl AstNode for GenericArg { |
2756 | fn from(node: ExternBlock) -> Item { Item::ExternBlock(node) } | ||
2757 | } | ||
2758 | impl From<ExternCrate> for Item { | ||
2759 | fn from(node: ExternCrate) -> Item { Item::ExternCrate(node) } | ||
2760 | } | ||
2761 | impl From<Fn> for Item { | ||
2762 | fn from(node: Fn) -> Item { Item::Fn(node) } | ||
2763 | } | ||
2764 | impl From<Impl> for Item { | ||
2765 | fn from(node: Impl) -> Item { Item::Impl(node) } | ||
2766 | } | ||
2767 | impl From<MacroCall> for Item { | ||
2768 | fn from(node: MacroCall) -> Item { Item::MacroCall(node) } | ||
2769 | } | ||
2770 | impl From<Module> for Item { | ||
2771 | fn from(node: Module) -> Item { Item::Module(node) } | ||
2772 | } | ||
2773 | impl From<Static> for Item { | ||
2774 | fn from(node: Static) -> Item { Item::Static(node) } | ||
2775 | } | ||
2776 | impl From<Struct> for Item { | ||
2777 | fn from(node: Struct) -> Item { Item::Struct(node) } | ||
2778 | } | ||
2779 | impl From<Trait> for Item { | ||
2780 | fn from(node: Trait) -> Item { Item::Trait(node) } | ||
2781 | } | ||
2782 | impl From<TypeAlias> for Item { | ||
2783 | fn from(node: TypeAlias) -> Item { Item::TypeAlias(node) } | ||
2784 | } | ||
2785 | impl From<Union> for Item { | ||
2786 | fn from(node: Union) -> Item { Item::Union(node) } | ||
2787 | } | ||
2788 | impl From<Use> for Item { | ||
2789 | fn from(node: Use) -> Item { Item::Use(node) } | ||
2790 | } | ||
2791 | impl AstNode for Item { | ||
2792 | fn can_cast(kind: SyntaxKind) -> bool { | 2765 | fn can_cast(kind: SyntaxKind) -> bool { |
2793 | match kind { | 2766 | match kind { |
2794 | CONST | ENUM | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL | MACRO_CALL | MODULE | 2767 | TYPE_ARG | ASSOC_TYPE_ARG | LIFETIME_ARG | CONST_ARG => true, |
2795 | | STATIC | STRUCT | TRAIT | TYPE_ALIAS | UNION | USE => true, | ||
2796 | _ => false, | 2768 | _ => false, |
2797 | } | 2769 | } |
2798 | } | 2770 | } |
2799 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2771 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
2800 | let res = match syntax.kind() { | 2772 | let res = match syntax.kind() { |
2801 | CONST => Item::Const(Const { syntax }), | 2773 | TYPE_ARG => GenericArg::TypeArg(TypeArg { syntax }), |
2802 | ENUM => Item::Enum(Enum { syntax }), | 2774 | ASSOC_TYPE_ARG => GenericArg::AssocTypeArg(AssocTypeArg { syntax }), |
2803 | EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }), | 2775 | LIFETIME_ARG => GenericArg::LifetimeArg(LifetimeArg { syntax }), |
2804 | EXTERN_CRATE => Item::ExternCrate(ExternCrate { syntax }), | 2776 | CONST_ARG => GenericArg::ConstArg(ConstArg { syntax }), |
2805 | FN => Item::Fn(Fn { syntax }), | ||
2806 | IMPL => Item::Impl(Impl { syntax }), | ||
2807 | MACRO_CALL => Item::MacroCall(MacroCall { syntax }), | ||
2808 | MODULE => Item::Module(Module { syntax }), | ||
2809 | STATIC => Item::Static(Static { syntax }), | ||
2810 | STRUCT => Item::Struct(Struct { syntax }), | ||
2811 | TRAIT => Item::Trait(Trait { syntax }), | ||
2812 | TYPE_ALIAS => Item::TypeAlias(TypeAlias { syntax }), | ||
2813 | UNION => Item::Union(Union { syntax }), | ||
2814 | USE => Item::Use(Use { syntax }), | ||
2815 | _ => return None, | 2777 | _ => return None, |
2816 | }; | 2778 | }; |
2817 | Some(res) | 2779 | Some(res) |
2818 | } | 2780 | } |
2819 | fn syntax(&self) -> &SyntaxNode { | 2781 | fn syntax(&self) -> &SyntaxNode { |
2820 | match self { | 2782 | match self { |
2821 | Item::Const(it) => &it.syntax, | 2783 | GenericArg::TypeArg(it) => &it.syntax, |
2822 | Item::Enum(it) => &it.syntax, | 2784 | GenericArg::AssocTypeArg(it) => &it.syntax, |
2823 | Item::ExternBlock(it) => &it.syntax, | 2785 | GenericArg::LifetimeArg(it) => &it.syntax, |
2824 | Item::ExternCrate(it) => &it.syntax, | 2786 | GenericArg::ConstArg(it) => &it.syntax, |
2825 | Item::Fn(it) => &it.syntax, | ||
2826 | Item::Impl(it) => &it.syntax, | ||
2827 | Item::MacroCall(it) => &it.syntax, | ||
2828 | Item::Module(it) => &it.syntax, | ||
2829 | Item::Static(it) => &it.syntax, | ||
2830 | Item::Struct(it) => &it.syntax, | ||
2831 | Item::Trait(it) => &it.syntax, | ||
2832 | Item::TypeAlias(it) => &it.syntax, | ||
2833 | Item::Union(it) => &it.syntax, | ||
2834 | Item::Use(it) => &it.syntax, | ||
2835 | } | 2787 | } |
2836 | } | 2788 | } |
2837 | } | 2789 | } |
@@ -2920,129 +2872,6 @@ impl AstNode for Type { | |||
2920 | } | 2872 | } |
2921 | } | 2873 | } |
2922 | } | 2874 | } |
2923 | impl From<OrPat> for Pat { | ||
2924 | fn from(node: OrPat) -> Pat { Pat::OrPat(node) } | ||
2925 | } | ||
2926 | impl From<ParenPat> for Pat { | ||
2927 | fn from(node: ParenPat) -> Pat { Pat::ParenPat(node) } | ||
2928 | } | ||
2929 | impl From<RefPat> for Pat { | ||
2930 | fn from(node: RefPat) -> Pat { Pat::RefPat(node) } | ||
2931 | } | ||
2932 | impl From<BoxPat> for Pat { | ||
2933 | fn from(node: BoxPat) -> Pat { Pat::BoxPat(node) } | ||
2934 | } | ||
2935 | impl From<BindPat> for Pat { | ||
2936 | fn from(node: BindPat) -> Pat { Pat::BindPat(node) } | ||
2937 | } | ||
2938 | impl From<PlaceholderPat> for Pat { | ||
2939 | fn from(node: PlaceholderPat) -> Pat { Pat::PlaceholderPat(node) } | ||
2940 | } | ||
2941 | impl From<DotDotPat> for Pat { | ||
2942 | fn from(node: DotDotPat) -> Pat { Pat::DotDotPat(node) } | ||
2943 | } | ||
2944 | impl From<PathPat> for Pat { | ||
2945 | fn from(node: PathPat) -> Pat { Pat::PathPat(node) } | ||
2946 | } | ||
2947 | impl From<RecordPat> for Pat { | ||
2948 | fn from(node: RecordPat) -> Pat { Pat::RecordPat(node) } | ||
2949 | } | ||
2950 | impl From<TupleStructPat> for Pat { | ||
2951 | fn from(node: TupleStructPat) -> Pat { Pat::TupleStructPat(node) } | ||
2952 | } | ||
2953 | impl From<TuplePat> for Pat { | ||
2954 | fn from(node: TuplePat) -> Pat { Pat::TuplePat(node) } | ||
2955 | } | ||
2956 | impl From<SlicePat> for Pat { | ||
2957 | fn from(node: SlicePat) -> Pat { Pat::SlicePat(node) } | ||
2958 | } | ||
2959 | impl From<RangePat> for Pat { | ||
2960 | fn from(node: RangePat) -> Pat { Pat::RangePat(node) } | ||
2961 | } | ||
2962 | impl From<LiteralPat> for Pat { | ||
2963 | fn from(node: LiteralPat) -> Pat { Pat::LiteralPat(node) } | ||
2964 | } | ||
2965 | impl From<MacroPat> for Pat { | ||
2966 | fn from(node: MacroPat) -> Pat { Pat::MacroPat(node) } | ||
2967 | } | ||
2968 | impl AstNode for Pat { | ||
2969 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2970 | match kind { | ||
2971 | OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT | ||
2972 | | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT | ||
2973 | | LITERAL_PAT | MACRO_PAT => true, | ||
2974 | _ => false, | ||
2975 | } | ||
2976 | } | ||
2977 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2978 | let res = match syntax.kind() { | ||
2979 | OR_PAT => Pat::OrPat(OrPat { syntax }), | ||
2980 | PAREN_PAT => Pat::ParenPat(ParenPat { syntax }), | ||
2981 | REF_PAT => Pat::RefPat(RefPat { syntax }), | ||
2982 | BOX_PAT => Pat::BoxPat(BoxPat { syntax }), | ||
2983 | BIND_PAT => Pat::BindPat(BindPat { syntax }), | ||
2984 | PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }), | ||
2985 | DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }), | ||
2986 | PATH_PAT => Pat::PathPat(PathPat { syntax }), | ||
2987 | RECORD_PAT => Pat::RecordPat(RecordPat { syntax }), | ||
2988 | TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }), | ||
2989 | TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }), | ||
2990 | SLICE_PAT => Pat::SlicePat(SlicePat { syntax }), | ||
2991 | RANGE_PAT => Pat::RangePat(RangePat { syntax }), | ||
2992 | LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }), | ||
2993 | MACRO_PAT => Pat::MacroPat(MacroPat { syntax }), | ||
2994 | _ => return None, | ||
2995 | }; | ||
2996 | Some(res) | ||
2997 | } | ||
2998 | fn syntax(&self) -> &SyntaxNode { | ||
2999 | match self { | ||
3000 | Pat::OrPat(it) => &it.syntax, | ||
3001 | Pat::ParenPat(it) => &it.syntax, | ||
3002 | Pat::RefPat(it) => &it.syntax, | ||
3003 | Pat::BoxPat(it) => &it.syntax, | ||
3004 | Pat::BindPat(it) => &it.syntax, | ||
3005 | Pat::PlaceholderPat(it) => &it.syntax, | ||
3006 | Pat::DotDotPat(it) => &it.syntax, | ||
3007 | Pat::PathPat(it) => &it.syntax, | ||
3008 | Pat::RecordPat(it) => &it.syntax, | ||
3009 | Pat::TupleStructPat(it) => &it.syntax, | ||
3010 | Pat::TuplePat(it) => &it.syntax, | ||
3011 | Pat::SlicePat(it) => &it.syntax, | ||
3012 | Pat::RangePat(it) => &it.syntax, | ||
3013 | Pat::LiteralPat(it) => &it.syntax, | ||
3014 | Pat::MacroPat(it) => &it.syntax, | ||
3015 | } | ||
3016 | } | ||
3017 | } | ||
3018 | impl From<RecordFieldList> for FieldList { | ||
3019 | fn from(node: RecordFieldList) -> FieldList { FieldList::RecordFieldList(node) } | ||
3020 | } | ||
3021 | impl From<TupleFieldList> for FieldList { | ||
3022 | fn from(node: TupleFieldList) -> FieldList { FieldList::TupleFieldList(node) } | ||
3023 | } | ||
3024 | impl AstNode for FieldList { | ||
3025 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3026 | match kind { | ||
3027 | RECORD_FIELD_LIST | TUPLE_FIELD_LIST => true, | ||
3028 | _ => false, | ||
3029 | } | ||
3030 | } | ||
3031 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3032 | let res = match syntax.kind() { | ||
3033 | RECORD_FIELD_LIST => FieldList::RecordFieldList(RecordFieldList { syntax }), | ||
3034 | TUPLE_FIELD_LIST => FieldList::TupleFieldList(TupleFieldList { syntax }), | ||
3035 | _ => return None, | ||
3036 | }; | ||
3037 | Some(res) | ||
3038 | } | ||
3039 | fn syntax(&self) -> &SyntaxNode { | ||
3040 | match self { | ||
3041 | FieldList::RecordFieldList(it) => &it.syntax, | ||
3042 | FieldList::TupleFieldList(it) => &it.syntax, | ||
3043 | } | ||
3044 | } | ||
3045 | } | ||
3046 | impl From<ArrayExpr> for Expr { | 2875 | impl From<ArrayExpr> for Expr { |
3047 | fn from(node: ArrayExpr) -> Expr { Expr::ArrayExpr(node) } | 2876 | fn from(node: ArrayExpr) -> Expr { Expr::ArrayExpr(node) } |
3048 | } | 2877 | } |
@@ -3067,6 +2896,9 @@ impl From<CallExpr> for Expr { | |||
3067 | impl From<CastExpr> for Expr { | 2896 | impl From<CastExpr> for Expr { |
3068 | fn from(node: CastExpr) -> Expr { Expr::CastExpr(node) } | 2897 | fn from(node: CastExpr) -> Expr { Expr::CastExpr(node) } |
3069 | } | 2898 | } |
2899 | impl From<ClosureExpr> for Expr { | ||
2900 | fn from(node: ClosureExpr) -> Expr { Expr::ClosureExpr(node) } | ||
2901 | } | ||
3070 | impl From<ContinueExpr> for Expr { | 2902 | impl From<ContinueExpr> for Expr { |
3071 | fn from(node: ContinueExpr) -> Expr { Expr::ContinueExpr(node) } | 2903 | fn from(node: ContinueExpr) -> Expr { Expr::ContinueExpr(node) } |
3072 | } | 2904 | } |
@@ -3085,12 +2917,6 @@ impl From<IfExpr> for Expr { | |||
3085 | impl From<IndexExpr> for Expr { | 2917 | impl From<IndexExpr> for Expr { |
3086 | fn from(node: IndexExpr) -> Expr { Expr::IndexExpr(node) } | 2918 | fn from(node: IndexExpr) -> Expr { Expr::IndexExpr(node) } |
3087 | } | 2919 | } |
3088 | impl From<Label> for Expr { | ||
3089 | fn from(node: Label) -> Expr { Expr::Label(node) } | ||
3090 | } | ||
3091 | impl From<ClosureExpr> for Expr { | ||
3092 | fn from(node: ClosureExpr) -> Expr { Expr::ClosureExpr(node) } | ||
3093 | } | ||
3094 | impl From<Literal> for Expr { | 2920 | impl From<Literal> for Expr { |
3095 | fn from(node: Literal) -> Expr { Expr::Literal(node) } | 2921 | fn from(node: Literal) -> Expr { Expr::Literal(node) } |
3096 | } | 2922 | } |
@@ -3140,8 +2966,8 @@ impl AstNode for Expr { | |||
3140 | fn can_cast(kind: SyntaxKind) -> bool { | 2966 | fn can_cast(kind: SyntaxKind) -> bool { |
3141 | match kind { | 2967 | match kind { |
3142 | ARRAY_EXPR | AWAIT_EXPR | BIN_EXPR | BLOCK_EXPR | BOX_EXPR | BREAK_EXPR | CALL_EXPR | 2968 | ARRAY_EXPR | AWAIT_EXPR | BIN_EXPR | BLOCK_EXPR | BOX_EXPR | BREAK_EXPR | CALL_EXPR |
3143 | | CAST_EXPR | CONTINUE_EXPR | EFFECT_EXPR | FIELD_EXPR | FOR_EXPR | IF_EXPR | 2969 | | CAST_EXPR | CLOSURE_EXPR | CONTINUE_EXPR | EFFECT_EXPR | FIELD_EXPR | FOR_EXPR |
3144 | | INDEX_EXPR | LABEL | CLOSURE_EXPR | LITERAL | LOOP_EXPR | MACRO_CALL | MATCH_EXPR | 2970 | | IF_EXPR | INDEX_EXPR | LITERAL | LOOP_EXPR | MACRO_CALL | MATCH_EXPR |
3145 | | METHOD_CALL_EXPR | PAREN_EXPR | PATH_EXPR | PREFIX_EXPR | RANGE_EXPR | 2971 | | METHOD_CALL_EXPR | PAREN_EXPR | PATH_EXPR | PREFIX_EXPR | RANGE_EXPR |
3146 | | RECORD_EXPR | REF_EXPR | RETURN_EXPR | TRY_EXPR | TUPLE_EXPR | WHILE_EXPR => true, | 2972 | | RECORD_EXPR | REF_EXPR | RETURN_EXPR | TRY_EXPR | TUPLE_EXPR | WHILE_EXPR => true, |
3147 | _ => false, | 2973 | _ => false, |
@@ -3157,14 +2983,13 @@ impl AstNode for Expr { | |||
3157 | BREAK_EXPR => Expr::BreakExpr(BreakExpr { syntax }), | 2983 | BREAK_EXPR => Expr::BreakExpr(BreakExpr { syntax }), |
3158 | CALL_EXPR => Expr::CallExpr(CallExpr { syntax }), | 2984 | CALL_EXPR => Expr::CallExpr(CallExpr { syntax }), |
3159 | CAST_EXPR => Expr::CastExpr(CastExpr { syntax }), | 2985 | CAST_EXPR => Expr::CastExpr(CastExpr { syntax }), |
2986 | CLOSURE_EXPR => Expr::ClosureExpr(ClosureExpr { syntax }), | ||
3160 | CONTINUE_EXPR => Expr::ContinueExpr(ContinueExpr { syntax }), | 2987 | CONTINUE_EXPR => Expr::ContinueExpr(ContinueExpr { syntax }), |
3161 | EFFECT_EXPR => Expr::EffectExpr(EffectExpr { syntax }), | 2988 | EFFECT_EXPR => Expr::EffectExpr(EffectExpr { syntax }), |
3162 | FIELD_EXPR => Expr::FieldExpr(FieldExpr { syntax }), | 2989 | FIELD_EXPR => Expr::FieldExpr(FieldExpr { syntax }), |
3163 | FOR_EXPR => Expr::ForExpr(ForExpr { syntax }), | 2990 | FOR_EXPR => Expr::ForExpr(ForExpr { syntax }), |
3164 | IF_EXPR => Expr::IfExpr(IfExpr { syntax }), | 2991 | IF_EXPR => Expr::IfExpr(IfExpr { syntax }), |
3165 | INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }), | 2992 | INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }), |
3166 | LABEL => Expr::Label(Label { syntax }), | ||
3167 | CLOSURE_EXPR => Expr::ClosureExpr(ClosureExpr { syntax }), | ||
3168 | LITERAL => Expr::Literal(Literal { syntax }), | 2993 | LITERAL => Expr::Literal(Literal { syntax }), |
3169 | LOOP_EXPR => Expr::LoopExpr(LoopExpr { syntax }), | 2994 | LOOP_EXPR => Expr::LoopExpr(LoopExpr { syntax }), |
3170 | MACRO_CALL => Expr::MacroCall(MacroCall { syntax }), | 2995 | MACRO_CALL => Expr::MacroCall(MacroCall { syntax }), |
@@ -3194,14 +3019,13 @@ impl AstNode for Expr { | |||
3194 | Expr::BreakExpr(it) => &it.syntax, | 3019 | Expr::BreakExpr(it) => &it.syntax, |
3195 | Expr::CallExpr(it) => &it.syntax, | 3020 | Expr::CallExpr(it) => &it.syntax, |
3196 | Expr::CastExpr(it) => &it.syntax, | 3021 | Expr::CastExpr(it) => &it.syntax, |
3022 | Expr::ClosureExpr(it) => &it.syntax, | ||
3197 | Expr::ContinueExpr(it) => &it.syntax, | 3023 | Expr::ContinueExpr(it) => &it.syntax, |
3198 | Expr::EffectExpr(it) => &it.syntax, | 3024 | Expr::EffectExpr(it) => &it.syntax, |
3199 | Expr::FieldExpr(it) => &it.syntax, | 3025 | Expr::FieldExpr(it) => &it.syntax, |
3200 | Expr::ForExpr(it) => &it.syntax, | 3026 | Expr::ForExpr(it) => &it.syntax, |
3201 | Expr::IfExpr(it) => &it.syntax, | 3027 | Expr::IfExpr(it) => &it.syntax, |
3202 | Expr::IndexExpr(it) => &it.syntax, | 3028 | Expr::IndexExpr(it) => &it.syntax, |
3203 | Expr::Label(it) => &it.syntax, | ||
3204 | Expr::ClosureExpr(it) => &it.syntax, | ||
3205 | Expr::Literal(it) => &it.syntax, | 3029 | Expr::Literal(it) => &it.syntax, |
3206 | Expr::LoopExpr(it) => &it.syntax, | 3030 | Expr::LoopExpr(it) => &it.syntax, |
3207 | Expr::MacroCall(it) => &it.syntax, | 3031 | Expr::MacroCall(it) => &it.syntax, |
@@ -3220,6 +3044,218 @@ impl AstNode for Expr { | |||
3220 | } | 3044 | } |
3221 | } | 3045 | } |
3222 | } | 3046 | } |
3047 | impl From<Const> for Item { | ||
3048 | fn from(node: Const) -> Item { Item::Const(node) } | ||
3049 | } | ||
3050 | impl From<Enum> for Item { | ||
3051 | fn from(node: Enum) -> Item { Item::Enum(node) } | ||
3052 | } | ||
3053 | impl From<ExternBlock> for Item { | ||
3054 | fn from(node: ExternBlock) -> Item { Item::ExternBlock(node) } | ||
3055 | } | ||
3056 | impl From<ExternCrate> for Item { | ||
3057 | fn from(node: ExternCrate) -> Item { Item::ExternCrate(node) } | ||
3058 | } | ||
3059 | impl From<Fn> for Item { | ||
3060 | fn from(node: Fn) -> Item { Item::Fn(node) } | ||
3061 | } | ||
3062 | impl From<Impl> for Item { | ||
3063 | fn from(node: Impl) -> Item { Item::Impl(node) } | ||
3064 | } | ||
3065 | impl From<MacroCall> for Item { | ||
3066 | fn from(node: MacroCall) -> Item { Item::MacroCall(node) } | ||
3067 | } | ||
3068 | impl From<Module> for Item { | ||
3069 | fn from(node: Module) -> Item { Item::Module(node) } | ||
3070 | } | ||
3071 | impl From<Static> for Item { | ||
3072 | fn from(node: Static) -> Item { Item::Static(node) } | ||
3073 | } | ||
3074 | impl From<Struct> for Item { | ||
3075 | fn from(node: Struct) -> Item { Item::Struct(node) } | ||
3076 | } | ||
3077 | impl From<Trait> for Item { | ||
3078 | fn from(node: Trait) -> Item { Item::Trait(node) } | ||
3079 | } | ||
3080 | impl From<TypeAlias> for Item { | ||
3081 | fn from(node: TypeAlias) -> Item { Item::TypeAlias(node) } | ||
3082 | } | ||
3083 | impl From<Union> for Item { | ||
3084 | fn from(node: Union) -> Item { Item::Union(node) } | ||
3085 | } | ||
3086 | impl From<Use> for Item { | ||
3087 | fn from(node: Use) -> Item { Item::Use(node) } | ||
3088 | } | ||
3089 | impl AstNode for Item { | ||
3090 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3091 | match kind { | ||
3092 | CONST | ENUM | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL | MACRO_CALL | MODULE | ||
3093 | | STATIC | STRUCT | TRAIT | TYPE_ALIAS | UNION | USE => true, | ||
3094 | _ => false, | ||
3095 | } | ||
3096 | } | ||
3097 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3098 | let res = match syntax.kind() { | ||
3099 | CONST => Item::Const(Const { syntax }), | ||
3100 | ENUM => Item::Enum(Enum { syntax }), | ||
3101 | EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }), | ||
3102 | EXTERN_CRATE => Item::ExternCrate(ExternCrate { syntax }), | ||
3103 | FN => Item::Fn(Fn { syntax }), | ||
3104 | IMPL => Item::Impl(Impl { syntax }), | ||
3105 | MACRO_CALL => Item::MacroCall(MacroCall { syntax }), | ||
3106 | MODULE => Item::Module(Module { syntax }), | ||
3107 | STATIC => Item::Static(Static { syntax }), | ||
3108 | STRUCT => Item::Struct(Struct { syntax }), | ||
3109 | TRAIT => Item::Trait(Trait { syntax }), | ||
3110 | TYPE_ALIAS => Item::TypeAlias(TypeAlias { syntax }), | ||
3111 | UNION => Item::Union(Union { syntax }), | ||
3112 | USE => Item::Use(Use { syntax }), | ||
3113 | _ => return None, | ||
3114 | }; | ||
3115 | Some(res) | ||
3116 | } | ||
3117 | fn syntax(&self) -> &SyntaxNode { | ||
3118 | match self { | ||
3119 | Item::Const(it) => &it.syntax, | ||
3120 | Item::Enum(it) => &it.syntax, | ||
3121 | Item::ExternBlock(it) => &it.syntax, | ||
3122 | Item::ExternCrate(it) => &it.syntax, | ||
3123 | Item::Fn(it) => &it.syntax, | ||
3124 | Item::Impl(it) => &it.syntax, | ||
3125 | Item::MacroCall(it) => &it.syntax, | ||
3126 | Item::Module(it) => &it.syntax, | ||
3127 | Item::Static(it) => &it.syntax, | ||
3128 | Item::Struct(it) => &it.syntax, | ||
3129 | Item::Trait(it) => &it.syntax, | ||
3130 | Item::TypeAlias(it) => &it.syntax, | ||
3131 | Item::Union(it) => &it.syntax, | ||
3132 | Item::Use(it) => &it.syntax, | ||
3133 | } | ||
3134 | } | ||
3135 | } | ||
3136 | impl From<OrPat> for Pat { | ||
3137 | fn from(node: OrPat) -> Pat { Pat::OrPat(node) } | ||
3138 | } | ||
3139 | impl From<ParenPat> for Pat { | ||
3140 | fn from(node: ParenPat) -> Pat { Pat::ParenPat(node) } | ||
3141 | } | ||
3142 | impl From<RefPat> for Pat { | ||
3143 | fn from(node: RefPat) -> Pat { Pat::RefPat(node) } | ||
3144 | } | ||
3145 | impl From<BoxPat> for Pat { | ||
3146 | fn from(node: BoxPat) -> Pat { Pat::BoxPat(node) } | ||
3147 | } | ||
3148 | impl From<BindPat> for Pat { | ||
3149 | fn from(node: BindPat) -> Pat { Pat::BindPat(node) } | ||
3150 | } | ||
3151 | impl From<PlaceholderPat> for Pat { | ||
3152 | fn from(node: PlaceholderPat) -> Pat { Pat::PlaceholderPat(node) } | ||
3153 | } | ||
3154 | impl From<DotDotPat> for Pat { | ||
3155 | fn from(node: DotDotPat) -> Pat { Pat::DotDotPat(node) } | ||
3156 | } | ||
3157 | impl From<PathPat> for Pat { | ||
3158 | fn from(node: PathPat) -> Pat { Pat::PathPat(node) } | ||
3159 | } | ||
3160 | impl From<RecordPat> for Pat { | ||
3161 | fn from(node: RecordPat) -> Pat { Pat::RecordPat(node) } | ||
3162 | } | ||
3163 | impl From<TupleStructPat> for Pat { | ||
3164 | fn from(node: TupleStructPat) -> Pat { Pat::TupleStructPat(node) } | ||
3165 | } | ||
3166 | impl From<TuplePat> for Pat { | ||
3167 | fn from(node: TuplePat) -> Pat { Pat::TuplePat(node) } | ||
3168 | } | ||
3169 | impl From<SlicePat> for Pat { | ||
3170 | fn from(node: SlicePat) -> Pat { Pat::SlicePat(node) } | ||
3171 | } | ||
3172 | impl From<RangePat> for Pat { | ||
3173 | fn from(node: RangePat) -> Pat { Pat::RangePat(node) } | ||
3174 | } | ||
3175 | impl From<LiteralPat> for Pat { | ||
3176 | fn from(node: LiteralPat) -> Pat { Pat::LiteralPat(node) } | ||
3177 | } | ||
3178 | impl From<MacroPat> for Pat { | ||
3179 | fn from(node: MacroPat) -> Pat { Pat::MacroPat(node) } | ||
3180 | } | ||
3181 | impl AstNode for Pat { | ||
3182 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3183 | match kind { | ||
3184 | OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT | ||
3185 | | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT | ||
3186 | | LITERAL_PAT | MACRO_PAT => true, | ||
3187 | _ => false, | ||
3188 | } | ||
3189 | } | ||
3190 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3191 | let res = match syntax.kind() { | ||
3192 | OR_PAT => Pat::OrPat(OrPat { syntax }), | ||
3193 | PAREN_PAT => Pat::ParenPat(ParenPat { syntax }), | ||
3194 | REF_PAT => Pat::RefPat(RefPat { syntax }), | ||
3195 | BOX_PAT => Pat::BoxPat(BoxPat { syntax }), | ||
3196 | BIND_PAT => Pat::BindPat(BindPat { syntax }), | ||
3197 | PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }), | ||
3198 | DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }), | ||
3199 | PATH_PAT => Pat::PathPat(PathPat { syntax }), | ||
3200 | RECORD_PAT => Pat::RecordPat(RecordPat { syntax }), | ||
3201 | TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }), | ||
3202 | TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }), | ||
3203 | SLICE_PAT => Pat::SlicePat(SlicePat { syntax }), | ||
3204 | RANGE_PAT => Pat::RangePat(RangePat { syntax }), | ||
3205 | LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }), | ||
3206 | MACRO_PAT => Pat::MacroPat(MacroPat { syntax }), | ||
3207 | _ => return None, | ||
3208 | }; | ||
3209 | Some(res) | ||
3210 | } | ||
3211 | fn syntax(&self) -> &SyntaxNode { | ||
3212 | match self { | ||
3213 | Pat::OrPat(it) => &it.syntax, | ||
3214 | Pat::ParenPat(it) => &it.syntax, | ||
3215 | Pat::RefPat(it) => &it.syntax, | ||
3216 | Pat::BoxPat(it) => &it.syntax, | ||
3217 | Pat::BindPat(it) => &it.syntax, | ||
3218 | Pat::PlaceholderPat(it) => &it.syntax, | ||
3219 | Pat::DotDotPat(it) => &it.syntax, | ||
3220 | Pat::PathPat(it) => &it.syntax, | ||
3221 | Pat::RecordPat(it) => &it.syntax, | ||
3222 | Pat::TupleStructPat(it) => &it.syntax, | ||
3223 | Pat::TuplePat(it) => &it.syntax, | ||
3224 | Pat::SlicePat(it) => &it.syntax, | ||
3225 | Pat::RangePat(it) => &it.syntax, | ||
3226 | Pat::LiteralPat(it) => &it.syntax, | ||
3227 | Pat::MacroPat(it) => &it.syntax, | ||
3228 | } | ||
3229 | } | ||
3230 | } | ||
3231 | impl From<RecordFieldList> for FieldList { | ||
3232 | fn from(node: RecordFieldList) -> FieldList { FieldList::RecordFieldList(node) } | ||
3233 | } | ||
3234 | impl From<TupleFieldList> for FieldList { | ||
3235 | fn from(node: TupleFieldList) -> FieldList { FieldList::TupleFieldList(node) } | ||
3236 | } | ||
3237 | impl AstNode for FieldList { | ||
3238 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3239 | match kind { | ||
3240 | RECORD_FIELD_LIST | TUPLE_FIELD_LIST => true, | ||
3241 | _ => false, | ||
3242 | } | ||
3243 | } | ||
3244 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3245 | let res = match syntax.kind() { | ||
3246 | RECORD_FIELD_LIST => FieldList::RecordFieldList(RecordFieldList { syntax }), | ||
3247 | TUPLE_FIELD_LIST => FieldList::TupleFieldList(TupleFieldList { syntax }), | ||
3248 | _ => return None, | ||
3249 | }; | ||
3250 | Some(res) | ||
3251 | } | ||
3252 | fn syntax(&self) -> &SyntaxNode { | ||
3253 | match self { | ||
3254 | FieldList::RecordFieldList(it) => &it.syntax, | ||
3255 | FieldList::TupleFieldList(it) => &it.syntax, | ||
3256 | } | ||
3257 | } | ||
3258 | } | ||
3223 | impl From<Enum> for AdtDef { | 3259 | impl From<Enum> for AdtDef { |
3224 | fn from(node: Enum) -> AdtDef { AdtDef::Enum(node) } | 3260 | fn from(node: Enum) -> AdtDef { AdtDef::Enum(node) } |
3225 | } | 3261 | } |
@@ -3366,7 +3402,7 @@ impl From<Item> for Stmt { | |||
3366 | impl From<LetStmt> for Stmt { | 3402 | impl From<LetStmt> for Stmt { |
3367 | fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) } | 3403 | fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) } |
3368 | } | 3404 | } |
3369 | impl std::fmt::Display for Item { | 3405 | impl std::fmt::Display for GenericArg { |
3370 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3406 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3371 | std::fmt::Display::fmt(self.syntax(), f) | 3407 | std::fmt::Display::fmt(self.syntax(), f) |
3372 | } | 3408 | } |
@@ -3376,17 +3412,22 @@ impl std::fmt::Display for Type { | |||
3376 | std::fmt::Display::fmt(self.syntax(), f) | 3412 | std::fmt::Display::fmt(self.syntax(), f) |
3377 | } | 3413 | } |
3378 | } | 3414 | } |
3379 | impl std::fmt::Display for Pat { | 3415 | impl std::fmt::Display for Expr { |
3380 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3416 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3381 | std::fmt::Display::fmt(self.syntax(), f) | 3417 | std::fmt::Display::fmt(self.syntax(), f) |
3382 | } | 3418 | } |
3383 | } | 3419 | } |
3384 | impl std::fmt::Display for FieldList { | 3420 | impl std::fmt::Display for Item { |
3385 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3421 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3386 | std::fmt::Display::fmt(self.syntax(), f) | 3422 | std::fmt::Display::fmt(self.syntax(), f) |
3387 | } | 3423 | } |
3388 | } | 3424 | } |
3389 | impl std::fmt::Display for Expr { | 3425 | impl std::fmt::Display for Pat { |
3426 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3427 | std::fmt::Display::fmt(self.syntax(), f) | ||
3428 | } | ||
3429 | } | ||
3430 | impl std::fmt::Display for FieldList { | ||
3390 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3431 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3391 | std::fmt::Display::fmt(self.syntax(), f) | 3432 | std::fmt::Display::fmt(self.syntax(), f) |
3392 | } | 3433 | } |
@@ -3416,6 +3457,66 @@ impl std::fmt::Display for Stmt { | |||
3416 | std::fmt::Display::fmt(self.syntax(), f) | 3457 | std::fmt::Display::fmt(self.syntax(), f) |
3417 | } | 3458 | } |
3418 | } | 3459 | } |
3460 | impl std::fmt::Display for Path { | ||
3461 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3462 | std::fmt::Display::fmt(self.syntax(), f) | ||
3463 | } | ||
3464 | } | ||
3465 | impl std::fmt::Display for PathSegment { | ||
3466 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3467 | std::fmt::Display::fmt(self.syntax(), f) | ||
3468 | } | ||
3469 | } | ||
3470 | impl std::fmt::Display for NameRef { | ||
3471 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3472 | std::fmt::Display::fmt(self.syntax(), f) | ||
3473 | } | ||
3474 | } | ||
3475 | impl std::fmt::Display for GenericArgList { | ||
3476 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3477 | std::fmt::Display::fmt(self.syntax(), f) | ||
3478 | } | ||
3479 | } | ||
3480 | impl std::fmt::Display for ParamList { | ||
3481 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3482 | std::fmt::Display::fmt(self.syntax(), f) | ||
3483 | } | ||
3484 | } | ||
3485 | impl std::fmt::Display for RetType { | ||
3486 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3487 | std::fmt::Display::fmt(self.syntax(), f) | ||
3488 | } | ||
3489 | } | ||
3490 | impl std::fmt::Display for PathType { | ||
3491 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3492 | std::fmt::Display::fmt(self.syntax(), f) | ||
3493 | } | ||
3494 | } | ||
3495 | impl std::fmt::Display for TypeArg { | ||
3496 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3497 | std::fmt::Display::fmt(self.syntax(), f) | ||
3498 | } | ||
3499 | } | ||
3500 | impl std::fmt::Display for AssocTypeArg { | ||
3501 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3502 | std::fmt::Display::fmt(self.syntax(), f) | ||
3503 | } | ||
3504 | } | ||
3505 | impl std::fmt::Display for LifetimeArg { | ||
3506 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3507 | std::fmt::Display::fmt(self.syntax(), f) | ||
3508 | } | ||
3509 | } | ||
3510 | impl std::fmt::Display for ConstArg { | ||
3511 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3512 | std::fmt::Display::fmt(self.syntax(), f) | ||
3513 | } | ||
3514 | } | ||
3515 | impl std::fmt::Display for TypeBoundList { | ||
3516 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3517 | std::fmt::Display::fmt(self.syntax(), f) | ||
3518 | } | ||
3519 | } | ||
3419 | impl std::fmt::Display for SourceFile { | 3520 | impl std::fmt::Display for SourceFile { |
3420 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3521 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3421 | std::fmt::Display::fmt(self.syntax(), f) | 3522 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3511,11 +3612,6 @@ impl std::fmt::Display for ItemList { | |||
3511 | std::fmt::Display::fmt(self.syntax(), f) | 3612 | std::fmt::Display::fmt(self.syntax(), f) |
3512 | } | 3613 | } |
3513 | } | 3614 | } |
3514 | impl std::fmt::Display for NameRef { | ||
3515 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3516 | std::fmt::Display::fmt(self.syntax(), f) | ||
3517 | } | ||
3518 | } | ||
3519 | impl std::fmt::Display for Rename { | 3615 | impl std::fmt::Display for Rename { |
3520 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3616 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3521 | std::fmt::Display::fmt(self.syntax(), f) | 3617 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3526,11 +3622,6 @@ impl std::fmt::Display for UseTree { | |||
3526 | std::fmt::Display::fmt(self.syntax(), f) | 3622 | std::fmt::Display::fmt(self.syntax(), f) |
3527 | } | 3623 | } |
3528 | } | 3624 | } |
3529 | impl std::fmt::Display for Path { | ||
3530 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3531 | std::fmt::Display::fmt(self.syntax(), f) | ||
3532 | } | ||
3533 | } | ||
3534 | impl std::fmt::Display for UseTreeList { | 3625 | impl std::fmt::Display for UseTreeList { |
3535 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3626 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3536 | std::fmt::Display::fmt(self.syntax(), f) | 3627 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3546,16 +3637,6 @@ impl std::fmt::Display for GenericParamList { | |||
3546 | std::fmt::Display::fmt(self.syntax(), f) | 3637 | std::fmt::Display::fmt(self.syntax(), f) |
3547 | } | 3638 | } |
3548 | } | 3639 | } |
3549 | impl std::fmt::Display for ParamList { | ||
3550 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3551 | std::fmt::Display::fmt(self.syntax(), f) | ||
3552 | } | ||
3553 | } | ||
3554 | impl std::fmt::Display for RetType { | ||
3555 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3556 | std::fmt::Display::fmt(self.syntax(), f) | ||
3557 | } | ||
3558 | } | ||
3559 | impl std::fmt::Display for WhereClause { | 3640 | impl std::fmt::Display for WhereClause { |
3560 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3641 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3561 | std::fmt::Display::fmt(self.syntax(), f) | 3642 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3576,11 +3657,6 @@ impl std::fmt::Display for Param { | |||
3576 | std::fmt::Display::fmt(self.syntax(), f) | 3657 | std::fmt::Display::fmt(self.syntax(), f) |
3577 | } | 3658 | } |
3578 | } | 3659 | } |
3579 | impl std::fmt::Display for TypeBoundList { | ||
3580 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3581 | std::fmt::Display::fmt(self.syntax(), f) | ||
3582 | } | ||
3583 | } | ||
3584 | impl std::fmt::Display for RecordFieldList { | 3660 | impl std::fmt::Display for RecordFieldList { |
3585 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3661 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3586 | std::fmt::Display::fmt(self.syntax(), f) | 3662 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3696,6 +3772,11 @@ impl std::fmt::Display for CastExpr { | |||
3696 | std::fmt::Display::fmt(self.syntax(), f) | 3772 | std::fmt::Display::fmt(self.syntax(), f) |
3697 | } | 3773 | } |
3698 | } | 3774 | } |
3775 | impl std::fmt::Display for ClosureExpr { | ||
3776 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3777 | std::fmt::Display::fmt(self.syntax(), f) | ||
3778 | } | ||
3779 | } | ||
3699 | impl std::fmt::Display for ContinueExpr { | 3780 | impl std::fmt::Display for ContinueExpr { |
3700 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3781 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3701 | std::fmt::Display::fmt(self.syntax(), f) | 3782 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3726,16 +3807,6 @@ impl std::fmt::Display for IndexExpr { | |||
3726 | std::fmt::Display::fmt(self.syntax(), f) | 3807 | std::fmt::Display::fmt(self.syntax(), f) |
3727 | } | 3808 | } |
3728 | } | 3809 | } |
3729 | impl std::fmt::Display for Label { | ||
3730 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3731 | std::fmt::Display::fmt(self.syntax(), f) | ||
3732 | } | ||
3733 | } | ||
3734 | impl std::fmt::Display for ClosureExpr { | ||
3735 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3736 | std::fmt::Display::fmt(self.syntax(), f) | ||
3737 | } | ||
3738 | } | ||
3739 | impl std::fmt::Display for LoopExpr { | 3810 | impl std::fmt::Display for LoopExpr { |
3740 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3811 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3741 | std::fmt::Display::fmt(self.syntax(), f) | 3812 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3801,22 +3872,22 @@ impl std::fmt::Display for WhileExpr { | |||
3801 | std::fmt::Display::fmt(self.syntax(), f) | 3872 | std::fmt::Display::fmt(self.syntax(), f) |
3802 | } | 3873 | } |
3803 | } | 3874 | } |
3804 | impl std::fmt::Display for RecordExprFieldList { | 3875 | impl std::fmt::Display for Label { |
3805 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3876 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3806 | std::fmt::Display::fmt(self.syntax(), f) | 3877 | std::fmt::Display::fmt(self.syntax(), f) |
3807 | } | 3878 | } |
3808 | } | 3879 | } |
3809 | impl std::fmt::Display for RecordExprField { | 3880 | impl std::fmt::Display for RecordExprFieldList { |
3810 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3881 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3811 | std::fmt::Display::fmt(self.syntax(), f) | 3882 | std::fmt::Display::fmt(self.syntax(), f) |
3812 | } | 3883 | } |
3813 | } | 3884 | } |
3814 | impl std::fmt::Display for ArgList { | 3885 | impl std::fmt::Display for RecordExprField { |
3815 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3886 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3816 | std::fmt::Display::fmt(self.syntax(), f) | 3887 | std::fmt::Display::fmt(self.syntax(), f) |
3817 | } | 3888 | } |
3818 | } | 3889 | } |
3819 | impl std::fmt::Display for TypeArgList { | 3890 | impl std::fmt::Display for ArgList { |
3820 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3891 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3821 | std::fmt::Display::fmt(self.syntax(), f) | 3892 | std::fmt::Display::fmt(self.syntax(), f) |
3822 | } | 3893 | } |
@@ -3881,11 +3952,6 @@ impl std::fmt::Display for ParenType { | |||
3881 | std::fmt::Display::fmt(self.syntax(), f) | 3952 | std::fmt::Display::fmt(self.syntax(), f) |
3882 | } | 3953 | } |
3883 | } | 3954 | } |
3884 | impl std::fmt::Display for PathType { | ||
3885 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3886 | std::fmt::Display::fmt(self.syntax(), f) | ||
3887 | } | ||
3888 | } | ||
3889 | impl std::fmt::Display for PointerType { | 3955 | impl std::fmt::Display for PointerType { |
3890 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3956 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3891 | std::fmt::Display::fmt(self.syntax(), f) | 3957 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -4006,28 +4072,3 @@ impl std::fmt::Display for MacroStmts { | |||
4006 | std::fmt::Display::fmt(self.syntax(), f) | 4072 | std::fmt::Display::fmt(self.syntax(), f) |
4007 | } | 4073 | } |
4008 | } | 4074 | } |
4009 | impl std::fmt::Display for PathSegment { | ||
4010 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
4011 | std::fmt::Display::fmt(self.syntax(), f) | ||
4012 | } | ||
4013 | } | ||
4014 | impl std::fmt::Display for TypeArg { | ||
4015 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
4016 | std::fmt::Display::fmt(self.syntax(), f) | ||
4017 | } | ||
4018 | } | ||
4019 | impl std::fmt::Display for LifetimeArg { | ||
4020 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
4021 | std::fmt::Display::fmt(self.syntax(), f) | ||
4022 | } | ||
4023 | } | ||
4024 | impl std::fmt::Display for AssocTypeArg { | ||
4025 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
4026 | std::fmt::Display::fmt(self.syntax(), f) | ||
4027 | } | ||
4028 | } | ||
4029 | impl std::fmt::Display for ConstArg { | ||
4030 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
4031 | std::fmt::Display::fmt(self.syntax(), f) | ||
4032 | } | ||
4033 | } | ||