diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-31 17:50:43 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-31 17:50:43 +0100 |
commit | 5d9145ce10c7dff6caa397b7a6c561848399e4f9 (patch) | |
tree | 8db83308ee58e07dcfd5071462460a8a50f1ce91 /crates/ra_syntax/src | |
parent | 0392a894b7284b13a88a13171e6b8b29764921be (diff) | |
parent | c1c97b289662501cea93fdc10760e08702ff5950 (diff) |
Merge #5629
5629: Finalize Path grammar r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/ast/edit.rs | 8 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated/nodes.rs | 1129 |
2 files changed, 592 insertions, 545 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 e049548c9..c25fa7d5f 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 | } |
@@ -731,7 +799,7 @@ impl MethodCallExpr { | |||
731 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 799 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
732 | 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![.]) } |
733 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | 801 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } |
734 | 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) } |
735 | } | 803 | } |
736 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 804 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
737 | pub struct ParenExpr { | 805 | pub struct ParenExpr { |
@@ -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 | } |
@@ -1220,74 +1268,12 @@ impl MacroStmts { | |||
1220 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 1268 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
1221 | } | 1269 | } |
1222 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1270 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1223 | pub struct PathSegment { | 1271 | pub enum GenericArg { |
1224 | pub(crate) syntax: SyntaxNode, | 1272 | TypeArg(TypeArg), |
1225 | } | 1273 | AssocTypeArg(AssocTypeArg), |
1226 | impl PathSegment { | 1274 | LifetimeArg(LifetimeArg), |
1227 | pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) } | 1275 | ConstArg(ConstArg), |
1228 | pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) } | ||
1229 | pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) } | ||
1230 | pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) } | ||
1231 | pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) } | ||
1232 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | ||
1233 | pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) } | ||
1234 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } | ||
1235 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } | ||
1236 | pub fn path_type(&self) -> Option<PathType> { support::child(&self.syntax) } | ||
1237 | pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) } | ||
1238 | } | ||
1239 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1240 | pub struct TypeArg { | ||
1241 | pub(crate) syntax: SyntaxNode, | ||
1242 | } | ||
1243 | impl TypeArg { | ||
1244 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } | ||
1245 | } | ||
1246 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1247 | pub struct LifetimeArg { | ||
1248 | pub(crate) syntax: SyntaxNode, | ||
1249 | } | ||
1250 | impl LifetimeArg { | ||
1251 | pub fn lifetime_token(&self) -> Option<SyntaxToken> { | ||
1252 | support::token(&self.syntax, T![lifetime]) | ||
1253 | } | ||
1254 | } | ||
1255 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1256 | pub struct AssocTypeArg { | ||
1257 | pub(crate) syntax: SyntaxNode, | ||
1258 | } | ||
1259 | impl ast::TypeBoundsOwner for AssocTypeArg {} | ||
1260 | impl AssocTypeArg { | ||
1261 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | ||
1262 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | ||
1263 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } | ||
1264 | } | ||
1265 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1266 | pub struct ConstArg { | ||
1267 | pub(crate) syntax: SyntaxNode, | ||
1268 | } | ||
1269 | impl ConstArg { | ||
1270 | pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) } | ||
1271 | pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) } | ||
1272 | } | ||
1273 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1274 | pub enum Item { | ||
1275 | Const(Const), | ||
1276 | Enum(Enum), | ||
1277 | ExternBlock(ExternBlock), | ||
1278 | ExternCrate(ExternCrate), | ||
1279 | Fn(Fn), | ||
1280 | Impl(Impl), | ||
1281 | MacroCall(MacroCall), | ||
1282 | Module(Module), | ||
1283 | Static(Static), | ||
1284 | Struct(Struct), | ||
1285 | Trait(Trait), | ||
1286 | TypeAlias(TypeAlias), | ||
1287 | Union(Union), | ||
1288 | Use(Use), | ||
1289 | } | 1276 | } |
1290 | impl ast::AttrsOwner for Item {} | ||
1291 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1277 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1292 | pub enum Type { | 1278 | pub enum Type { |
1293 | ArrayType(ArrayType), | 1279 | ArrayType(ArrayType), |
@@ -1305,29 +1291,6 @@ pub enum Type { | |||
1305 | TupleType(TupleType), | 1291 | TupleType(TupleType), |
1306 | } | 1292 | } |
1307 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1293 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1308 | pub enum Pat { | ||
1309 | OrPat(OrPat), | ||
1310 | ParenPat(ParenPat), | ||
1311 | RefPat(RefPat), | ||
1312 | BoxPat(BoxPat), | ||
1313 | BindPat(BindPat), | ||
1314 | PlaceholderPat(PlaceholderPat), | ||
1315 | DotDotPat(DotDotPat), | ||
1316 | PathPat(PathPat), | ||
1317 | RecordPat(RecordPat), | ||
1318 | TupleStructPat(TupleStructPat), | ||
1319 | TuplePat(TuplePat), | ||
1320 | SlicePat(SlicePat), | ||
1321 | RangePat(RangePat), | ||
1322 | LiteralPat(LiteralPat), | ||
1323 | MacroPat(MacroPat), | ||
1324 | } | ||
1325 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1326 | pub enum FieldList { | ||
1327 | RecordFieldList(RecordFieldList), | ||
1328 | TupleFieldList(TupleFieldList), | ||
1329 | } | ||
1330 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1331 | pub enum Expr { | 1294 | pub enum Expr { |
1332 | ArrayExpr(ArrayExpr), | 1295 | ArrayExpr(ArrayExpr), |
1333 | AwaitExpr(AwaitExpr), | 1296 | AwaitExpr(AwaitExpr), |
@@ -1361,6 +1324,47 @@ pub enum Expr { | |||
1361 | WhileExpr(WhileExpr), | 1324 | WhileExpr(WhileExpr), |
1362 | } | 1325 | } |
1363 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1326 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1327 | pub enum Item { | ||
1328 | Const(Const), | ||
1329 | Enum(Enum), | ||
1330 | ExternBlock(ExternBlock), | ||
1331 | ExternCrate(ExternCrate), | ||
1332 | Fn(Fn), | ||
1333 | Impl(Impl), | ||
1334 | MacroCall(MacroCall), | ||
1335 | Module(Module), | ||
1336 | Static(Static), | ||
1337 | Struct(Struct), | ||
1338 | Trait(Trait), | ||
1339 | TypeAlias(TypeAlias), | ||
1340 | Union(Union), | ||
1341 | Use(Use), | ||
1342 | } | ||
1343 | impl ast::AttrsOwner for Item {} | ||
1344 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1345 | pub enum Pat { | ||
1346 | OrPat(OrPat), | ||
1347 | ParenPat(ParenPat), | ||
1348 | RefPat(RefPat), | ||
1349 | BoxPat(BoxPat), | ||
1350 | BindPat(BindPat), | ||
1351 | PlaceholderPat(PlaceholderPat), | ||
1352 | DotDotPat(DotDotPat), | ||
1353 | PathPat(PathPat), | ||
1354 | RecordPat(RecordPat), | ||
1355 | TupleStructPat(TupleStructPat), | ||
1356 | TuplePat(TuplePat), | ||
1357 | SlicePat(SlicePat), | ||
1358 | RangePat(RangePat), | ||
1359 | LiteralPat(LiteralPat), | ||
1360 | MacroPat(MacroPat), | ||
1361 | } | ||
1362 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1363 | pub enum FieldList { | ||
1364 | RecordFieldList(RecordFieldList), | ||
1365 | TupleFieldList(TupleFieldList), | ||
1366 | } | ||
1367 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1364 | pub enum AdtDef { | 1368 | pub enum AdtDef { |
1365 | Enum(Enum), | 1369 | Enum(Enum), |
1366 | Struct(Struct), | 1370 | Struct(Struct), |
@@ -1400,6 +1404,138 @@ pub enum Stmt { | |||
1400 | Item(Item), | 1404 | Item(Item), |
1401 | LetStmt(LetStmt), | 1405 | LetStmt(LetStmt), |
1402 | } | 1406 | } |
1407 | impl AstNode for Path { | ||
1408 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH } | ||
1409 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1410 | if Self::can_cast(syntax.kind()) { | ||
1411 | Some(Self { syntax }) | ||
1412 | } else { | ||
1413 | None | ||
1414 | } | ||
1415 | } | ||
1416 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1417 | } | ||
1418 | impl AstNode for PathSegment { | ||
1419 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT } | ||
1420 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1421 | if Self::can_cast(syntax.kind()) { | ||
1422 | Some(Self { syntax }) | ||
1423 | } else { | ||
1424 | None | ||
1425 | } | ||
1426 | } | ||
1427 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1428 | } | ||
1429 | impl AstNode for NameRef { | ||
1430 | fn can_cast(kind: SyntaxKind) -> bool { kind == NAME_REF } | ||
1431 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1432 | if Self::can_cast(syntax.kind()) { | ||
1433 | Some(Self { syntax }) | ||
1434 | } else { | ||
1435 | None | ||
1436 | } | ||
1437 | } | ||
1438 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1439 | } | ||
1440 | impl AstNode for GenericArgList { | ||
1441 | fn can_cast(kind: SyntaxKind) -> bool { kind == GENERIC_ARG_LIST } | ||
1442 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1443 | if Self::can_cast(syntax.kind()) { | ||
1444 | Some(Self { syntax }) | ||
1445 | } else { | ||
1446 | None | ||
1447 | } | ||
1448 | } | ||
1449 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1450 | } | ||
1451 | impl AstNode for ParamList { | ||
1452 | fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM_LIST } | ||
1453 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1454 | if Self::can_cast(syntax.kind()) { | ||
1455 | Some(Self { syntax }) | ||
1456 | } else { | ||
1457 | None | ||
1458 | } | ||
1459 | } | ||
1460 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1461 | } | ||
1462 | impl AstNode for RetType { | ||
1463 | fn can_cast(kind: SyntaxKind) -> bool { kind == RET_TYPE } | ||
1464 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1465 | if Self::can_cast(syntax.kind()) { | ||
1466 | Some(Self { syntax }) | ||
1467 | } else { | ||
1468 | None | ||
1469 | } | ||
1470 | } | ||
1471 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1472 | } | ||
1473 | impl AstNode for PathType { | ||
1474 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_TYPE } | ||
1475 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1476 | if Self::can_cast(syntax.kind()) { | ||
1477 | Some(Self { syntax }) | ||
1478 | } else { | ||
1479 | None | ||
1480 | } | ||
1481 | } | ||
1482 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1483 | } | ||
1484 | impl AstNode for TypeArg { | ||
1485 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG } | ||
1486 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1487 | if Self::can_cast(syntax.kind()) { | ||
1488 | Some(Self { syntax }) | ||
1489 | } else { | ||
1490 | None | ||
1491 | } | ||
1492 | } | ||
1493 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1494 | } | ||
1495 | impl AstNode for AssocTypeArg { | ||
1496 | fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_TYPE_ARG } | ||
1497 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1498 | if Self::can_cast(syntax.kind()) { | ||
1499 | Some(Self { syntax }) | ||
1500 | } else { | ||
1501 | None | ||
1502 | } | ||
1503 | } | ||
1504 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1505 | } | ||
1506 | impl AstNode for LifetimeArg { | ||
1507 | fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_ARG } | ||
1508 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1509 | if Self::can_cast(syntax.kind()) { | ||
1510 | Some(Self { syntax }) | ||
1511 | } else { | ||
1512 | None | ||
1513 | } | ||
1514 | } | ||
1515 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1516 | } | ||
1517 | impl AstNode for ConstArg { | ||
1518 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_ARG } | ||
1519 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1520 | if Self::can_cast(syntax.kind()) { | ||
1521 | Some(Self { syntax }) | ||
1522 | } else { | ||
1523 | None | ||
1524 | } | ||
1525 | } | ||
1526 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1527 | } | ||
1528 | impl AstNode for TypeBoundList { | ||
1529 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST } | ||
1530 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1531 | if Self::can_cast(syntax.kind()) { | ||
1532 | Some(Self { syntax }) | ||
1533 | } else { | ||
1534 | None | ||
1535 | } | ||
1536 | } | ||
1537 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1538 | } | ||
1403 | impl AstNode for SourceFile { | 1539 | impl AstNode for SourceFile { |
1404 | fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE } | 1540 | fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE } |
1405 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1541 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -1609,17 +1745,6 @@ impl AstNode for ItemList { | |||
1609 | } | 1745 | } |
1610 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1746 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1611 | } | 1747 | } |
1612 | impl AstNode for NameRef { | ||
1613 | fn can_cast(kind: SyntaxKind) -> bool { kind == NAME_REF } | ||
1614 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1615 | if Self::can_cast(syntax.kind()) { | ||
1616 | Some(Self { syntax }) | ||
1617 | } else { | ||
1618 | None | ||
1619 | } | ||
1620 | } | ||
1621 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1622 | } | ||
1623 | impl AstNode for Rename { | 1748 | impl AstNode for Rename { |
1624 | fn can_cast(kind: SyntaxKind) -> bool { kind == RENAME } | 1749 | fn can_cast(kind: SyntaxKind) -> bool { kind == RENAME } |
1625 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1750 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -1642,17 +1767,6 @@ impl AstNode for UseTree { | |||
1642 | } | 1767 | } |
1643 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1768 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1644 | } | 1769 | } |
1645 | impl AstNode for Path { | ||
1646 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH } | ||
1647 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1648 | if Self::can_cast(syntax.kind()) { | ||
1649 | Some(Self { syntax }) | ||
1650 | } else { | ||
1651 | None | ||
1652 | } | ||
1653 | } | ||
1654 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1655 | } | ||
1656 | impl AstNode for UseTreeList { | 1770 | impl AstNode for UseTreeList { |
1657 | fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE_LIST } | 1771 | fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE_LIST } |
1658 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1772 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -1686,28 +1800,6 @@ impl AstNode for GenericParamList { | |||
1686 | } | 1800 | } |
1687 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1801 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1688 | } | 1802 | } |
1689 | impl AstNode for ParamList { | ||
1690 | fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM_LIST } | ||
1691 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1692 | if Self::can_cast(syntax.kind()) { | ||
1693 | Some(Self { syntax }) | ||
1694 | } else { | ||
1695 | None | ||
1696 | } | ||
1697 | } | ||
1698 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1699 | } | ||
1700 | impl AstNode for RetType { | ||
1701 | fn can_cast(kind: SyntaxKind) -> bool { kind == RET_TYPE } | ||
1702 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1703 | if Self::can_cast(syntax.kind()) { | ||
1704 | Some(Self { syntax }) | ||
1705 | } else { | ||
1706 | None | ||
1707 | } | ||
1708 | } | ||
1709 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1710 | } | ||
1711 | impl AstNode for WhereClause { | 1803 | impl AstNode for WhereClause { |
1712 | fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_CLAUSE } | 1804 | fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_CLAUSE } |
1713 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1805 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -1752,17 +1844,6 @@ impl AstNode for Param { | |||
1752 | } | 1844 | } |
1753 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1845 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1754 | } | 1846 | } |
1755 | impl AstNode for TypeBoundList { | ||
1756 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST } | ||
1757 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1758 | if Self::can_cast(syntax.kind()) { | ||
1759 | Some(Self { syntax }) | ||
1760 | } else { | ||
1761 | None | ||
1762 | } | ||
1763 | } | ||
1764 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1765 | } | ||
1766 | impl AstNode for RecordFieldList { | 1847 | impl AstNode for RecordFieldList { |
1767 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_LIST } | 1848 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_LIST } |
1768 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1849 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2280,17 +2361,6 @@ impl AstNode for ArgList { | |||
2280 | } | 2361 | } |
2281 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2362 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2282 | } | 2363 | } |
2283 | impl AstNode for TypeArgList { | ||
2284 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG_LIST } | ||
2285 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2286 | if Self::can_cast(syntax.kind()) { | ||
2287 | Some(Self { syntax }) | ||
2288 | } else { | ||
2289 | None | ||
2290 | } | ||
2291 | } | ||
2292 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2293 | } | ||
2294 | impl AstNode for Condition { | 2364 | impl AstNode for Condition { |
2295 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONDITION } | 2365 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONDITION } |
2296 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2366 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2423,17 +2493,6 @@ impl AstNode for ParenType { | |||
2423 | } | 2493 | } |
2424 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2494 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2425 | } | 2495 | } |
2426 | impl AstNode for PathType { | ||
2427 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_TYPE } | ||
2428 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2429 | if Self::can_cast(syntax.kind()) { | ||
2430 | Some(Self { syntax }) | ||
2431 | } else { | ||
2432 | None | ||
2433 | } | ||
2434 | } | ||
2435 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2436 | } | ||
2437 | impl AstNode for PointerType { | 2496 | impl AstNode for PointerType { |
2438 | fn can_cast(kind: SyntaxKind) -> bool { kind == POINTER_TYPE } | 2497 | fn can_cast(kind: SyntaxKind) -> bool { kind == POINTER_TYPE } |
2439 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2498 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2709,147 +2768,41 @@ impl AstNode for MacroStmts { | |||
2709 | } | 2768 | } |
2710 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2769 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2711 | } | 2770 | } |
2712 | impl AstNode for PathSegment { | 2771 | impl From<TypeArg> for GenericArg { |
2713 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT } | 2772 | fn from(node: TypeArg) -> GenericArg { GenericArg::TypeArg(node) } |
2714 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2715 | if Self::can_cast(syntax.kind()) { | ||
2716 | Some(Self { syntax }) | ||
2717 | } else { | ||
2718 | None | ||
2719 | } | ||
2720 | } | ||
2721 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2722 | } | ||
2723 | impl AstNode for TypeArg { | ||
2724 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG } | ||
2725 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2726 | if Self::can_cast(syntax.kind()) { | ||
2727 | Some(Self { syntax }) | ||
2728 | } else { | ||
2729 | None | ||
2730 | } | ||
2731 | } | ||
2732 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2733 | } | ||
2734 | impl AstNode for LifetimeArg { | ||
2735 | fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_ARG } | ||
2736 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2737 | if Self::can_cast(syntax.kind()) { | ||
2738 | Some(Self { syntax }) | ||
2739 | } else { | ||
2740 | None | ||
2741 | } | ||
2742 | } | ||
2743 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2744 | } | ||
2745 | impl AstNode for AssocTypeArg { | ||
2746 | fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_TYPE_ARG } | ||
2747 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2748 | if Self::can_cast(syntax.kind()) { | ||
2749 | Some(Self { syntax }) | ||
2750 | } else { | ||
2751 | None | ||
2752 | } | ||
2753 | } | ||
2754 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2755 | } | ||
2756 | impl AstNode for ConstArg { | ||
2757 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_ARG } | ||
2758 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2759 | if Self::can_cast(syntax.kind()) { | ||
2760 | Some(Self { syntax }) | ||
2761 | } else { | ||
2762 | None | ||
2763 | } | ||
2764 | } | ||
2765 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2766 | } | ||
2767 | impl From<Const> for Item { | ||
2768 | fn from(node: Const) -> Item { Item::Const(node) } | ||
2769 | } | ||
2770 | impl From<Enum> for Item { | ||
2771 | fn from(node: Enum) -> Item { Item::Enum(node) } | ||
2772 | } | ||
2773 | impl From<ExternBlock> for Item { | ||
2774 | fn from(node: ExternBlock) -> Item { Item::ExternBlock(node) } | ||
2775 | } | ||
2776 | impl From<ExternCrate> for Item { | ||
2777 | fn from(node: ExternCrate) -> Item { Item::ExternCrate(node) } | ||
2778 | } | ||
2779 | impl From<Fn> for Item { | ||
2780 | fn from(node: Fn) -> Item { Item::Fn(node) } | ||
2781 | } | ||
2782 | impl From<Impl> for Item { | ||
2783 | fn from(node: Impl) -> Item { Item::Impl(node) } | ||
2784 | } | ||
2785 | impl From<MacroCall> for Item { | ||
2786 | fn from(node: MacroCall) -> Item { Item::MacroCall(node) } | ||
2787 | } | ||
2788 | impl From<Module> for Item { | ||
2789 | fn from(node: Module) -> Item { Item::Module(node) } | ||
2790 | } | ||
2791 | impl From<Static> for Item { | ||
2792 | fn from(node: Static) -> Item { Item::Static(node) } | ||
2793 | } | ||
2794 | impl From<Struct> for Item { | ||
2795 | fn from(node: Struct) -> Item { Item::Struct(node) } | ||
2796 | } | 2773 | } |
2797 | impl From<Trait> for Item { | 2774 | impl From<AssocTypeArg> for GenericArg { |
2798 | fn from(node: Trait) -> Item { Item::Trait(node) } | 2775 | fn from(node: AssocTypeArg) -> GenericArg { GenericArg::AssocTypeArg(node) } |
2799 | } | 2776 | } |
2800 | impl From<TypeAlias> for Item { | 2777 | impl From<LifetimeArg> for GenericArg { |
2801 | fn from(node: TypeAlias) -> Item { Item::TypeAlias(node) } | 2778 | fn from(node: LifetimeArg) -> GenericArg { GenericArg::LifetimeArg(node) } |
2802 | } | 2779 | } |
2803 | impl From<Union> for Item { | 2780 | impl From<ConstArg> for GenericArg { |
2804 | fn from(node: Union) -> Item { Item::Union(node) } | 2781 | fn from(node: ConstArg) -> GenericArg { GenericArg::ConstArg(node) } |
2805 | } | ||
2806 | impl From<Use> for Item { | ||
2807 | fn from(node: Use) -> Item { Item::Use(node) } | ||
2808 | } | 2782 | } |
2809 | impl AstNode for Item { | 2783 | impl AstNode for GenericArg { |
2810 | fn can_cast(kind: SyntaxKind) -> bool { | 2784 | fn can_cast(kind: SyntaxKind) -> bool { |
2811 | match kind { | 2785 | match kind { |
2812 | CONST | ENUM | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL | MACRO_CALL | MODULE | 2786 | TYPE_ARG | ASSOC_TYPE_ARG | LIFETIME_ARG | CONST_ARG => true, |
2813 | | STATIC | STRUCT | TRAIT | TYPE_ALIAS | UNION | USE => true, | ||
2814 | _ => false, | 2787 | _ => false, |
2815 | } | 2788 | } |
2816 | } | 2789 | } |
2817 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2790 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
2818 | let res = match syntax.kind() { | 2791 | let res = match syntax.kind() { |
2819 | CONST => Item::Const(Const { syntax }), | 2792 | TYPE_ARG => GenericArg::TypeArg(TypeArg { syntax }), |
2820 | ENUM => Item::Enum(Enum { syntax }), | 2793 | ASSOC_TYPE_ARG => GenericArg::AssocTypeArg(AssocTypeArg { syntax }), |
2821 | EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }), | 2794 | LIFETIME_ARG => GenericArg::LifetimeArg(LifetimeArg { syntax }), |
2822 | EXTERN_CRATE => Item::ExternCrate(ExternCrate { syntax }), | 2795 | CONST_ARG => GenericArg::ConstArg(ConstArg { syntax }), |
2823 | FN => Item::Fn(Fn { syntax }), | ||
2824 | IMPL => Item::Impl(Impl { syntax }), | ||
2825 | MACRO_CALL => Item::MacroCall(MacroCall { syntax }), | ||
2826 | MODULE => Item::Module(Module { syntax }), | ||
2827 | STATIC => Item::Static(Static { syntax }), | ||
2828 | STRUCT => Item::Struct(Struct { syntax }), | ||
2829 | TRAIT => Item::Trait(Trait { syntax }), | ||
2830 | TYPE_ALIAS => Item::TypeAlias(TypeAlias { syntax }), | ||
2831 | UNION => Item::Union(Union { syntax }), | ||
2832 | USE => Item::Use(Use { syntax }), | ||
2833 | _ => return None, | 2796 | _ => return None, |
2834 | }; | 2797 | }; |
2835 | Some(res) | 2798 | Some(res) |
2836 | } | 2799 | } |
2837 | fn syntax(&self) -> &SyntaxNode { | 2800 | fn syntax(&self) -> &SyntaxNode { |
2838 | match self { | 2801 | match self { |
2839 | Item::Const(it) => &it.syntax, | 2802 | GenericArg::TypeArg(it) => &it.syntax, |
2840 | Item::Enum(it) => &it.syntax, | 2803 | GenericArg::AssocTypeArg(it) => &it.syntax, |
2841 | Item::ExternBlock(it) => &it.syntax, | 2804 | GenericArg::LifetimeArg(it) => &it.syntax, |
2842 | Item::ExternCrate(it) => &it.syntax, | 2805 | GenericArg::ConstArg(it) => &it.syntax, |
2843 | Item::Fn(it) => &it.syntax, | ||
2844 | Item::Impl(it) => &it.syntax, | ||
2845 | Item::MacroCall(it) => &it.syntax, | ||
2846 | Item::Module(it) => &it.syntax, | ||
2847 | Item::Static(it) => &it.syntax, | ||
2848 | Item::Struct(it) => &it.syntax, | ||
2849 | Item::Trait(it) => &it.syntax, | ||
2850 | Item::TypeAlias(it) => &it.syntax, | ||
2851 | Item::Union(it) => &it.syntax, | ||
2852 | Item::Use(it) => &it.syntax, | ||
2853 | } | 2806 | } |
2854 | } | 2807 | } |
2855 | } | 2808 | } |
@@ -2938,129 +2891,6 @@ impl AstNode for Type { | |||
2938 | } | 2891 | } |
2939 | } | 2892 | } |
2940 | } | 2893 | } |
2941 | impl From<OrPat> for Pat { | ||
2942 | fn from(node: OrPat) -> Pat { Pat::OrPat(node) } | ||
2943 | } | ||
2944 | impl From<ParenPat> for Pat { | ||
2945 | fn from(node: ParenPat) -> Pat { Pat::ParenPat(node) } | ||
2946 | } | ||
2947 | impl From<RefPat> for Pat { | ||
2948 | fn from(node: RefPat) -> Pat { Pat::RefPat(node) } | ||
2949 | } | ||
2950 | impl From<BoxPat> for Pat { | ||
2951 | fn from(node: BoxPat) -> Pat { Pat::BoxPat(node) } | ||
2952 | } | ||
2953 | impl From<BindPat> for Pat { | ||
2954 | fn from(node: BindPat) -> Pat { Pat::BindPat(node) } | ||
2955 | } | ||
2956 | impl From<PlaceholderPat> for Pat { | ||
2957 | fn from(node: PlaceholderPat) -> Pat { Pat::PlaceholderPat(node) } | ||
2958 | } | ||
2959 | impl From<DotDotPat> for Pat { | ||
2960 | fn from(node: DotDotPat) -> Pat { Pat::DotDotPat(node) } | ||
2961 | } | ||
2962 | impl From<PathPat> for Pat { | ||
2963 | fn from(node: PathPat) -> Pat { Pat::PathPat(node) } | ||
2964 | } | ||
2965 | impl From<RecordPat> for Pat { | ||
2966 | fn from(node: RecordPat) -> Pat { Pat::RecordPat(node) } | ||
2967 | } | ||
2968 | impl From<TupleStructPat> for Pat { | ||
2969 | fn from(node: TupleStructPat) -> Pat { Pat::TupleStructPat(node) } | ||
2970 | } | ||
2971 | impl From<TuplePat> for Pat { | ||
2972 | fn from(node: TuplePat) -> Pat { Pat::TuplePat(node) } | ||
2973 | } | ||
2974 | impl From<SlicePat> for Pat { | ||
2975 | fn from(node: SlicePat) -> Pat { Pat::SlicePat(node) } | ||
2976 | } | ||
2977 | impl From<RangePat> for Pat { | ||
2978 | fn from(node: RangePat) -> Pat { Pat::RangePat(node) } | ||
2979 | } | ||
2980 | impl From<LiteralPat> for Pat { | ||
2981 | fn from(node: LiteralPat) -> Pat { Pat::LiteralPat(node) } | ||
2982 | } | ||
2983 | impl From<MacroPat> for Pat { | ||
2984 | fn from(node: MacroPat) -> Pat { Pat::MacroPat(node) } | ||
2985 | } | ||
2986 | impl AstNode for Pat { | ||
2987 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2988 | match kind { | ||
2989 | OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT | ||
2990 | | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT | ||
2991 | | LITERAL_PAT | MACRO_PAT => true, | ||
2992 | _ => false, | ||
2993 | } | ||
2994 | } | ||
2995 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2996 | let res = match syntax.kind() { | ||
2997 | OR_PAT => Pat::OrPat(OrPat { syntax }), | ||
2998 | PAREN_PAT => Pat::ParenPat(ParenPat { syntax }), | ||
2999 | REF_PAT => Pat::RefPat(RefPat { syntax }), | ||
3000 | BOX_PAT => Pat::BoxPat(BoxPat { syntax }), | ||
3001 | BIND_PAT => Pat::BindPat(BindPat { syntax }), | ||
3002 | PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }), | ||
3003 | DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }), | ||
3004 | PATH_PAT => Pat::PathPat(PathPat { syntax }), | ||
3005 | RECORD_PAT => Pat::RecordPat(RecordPat { syntax }), | ||
3006 | TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }), | ||
3007 | TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }), | ||
3008 | SLICE_PAT => Pat::SlicePat(SlicePat { syntax }), | ||
3009 | RANGE_PAT => Pat::RangePat(RangePat { syntax }), | ||
3010 | LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }), | ||
3011 | MACRO_PAT => Pat::MacroPat(MacroPat { syntax }), | ||
3012 | _ => return None, | ||
3013 | }; | ||
3014 | Some(res) | ||
3015 | } | ||
3016 | fn syntax(&self) -> &SyntaxNode { | ||
3017 | match self { | ||
3018 | Pat::OrPat(it) => &it.syntax, | ||
3019 | Pat::ParenPat(it) => &it.syntax, | ||
3020 | Pat::RefPat(it) => &it.syntax, | ||
3021 | Pat::BoxPat(it) => &it.syntax, | ||
3022 | Pat::BindPat(it) => &it.syntax, | ||
3023 | Pat::PlaceholderPat(it) => &it.syntax, | ||
3024 | Pat::DotDotPat(it) => &it.syntax, | ||
3025 | Pat::PathPat(it) => &it.syntax, | ||
3026 | Pat::RecordPat(it) => &it.syntax, | ||
3027 | Pat::TupleStructPat(it) => &it.syntax, | ||
3028 | Pat::TuplePat(it) => &it.syntax, | ||
3029 | Pat::SlicePat(it) => &it.syntax, | ||
3030 | Pat::RangePat(it) => &it.syntax, | ||
3031 | Pat::LiteralPat(it) => &it.syntax, | ||
3032 | Pat::MacroPat(it) => &it.syntax, | ||
3033 | } | ||
3034 | } | ||
3035 | } | ||
3036 | impl From<RecordFieldList> for FieldList { | ||
3037 | fn from(node: RecordFieldList) -> FieldList { FieldList::RecordFieldList(node) } | ||
3038 | } | ||
3039 | impl From<TupleFieldList> for FieldList { | ||
3040 | fn from(node: TupleFieldList) -> FieldList { FieldList::TupleFieldList(node) } | ||
3041 | } | ||
3042 | impl AstNode for FieldList { | ||
3043 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3044 | match kind { | ||
3045 | RECORD_FIELD_LIST | TUPLE_FIELD_LIST => true, | ||
3046 | _ => false, | ||
3047 | } | ||
3048 | } | ||
3049 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3050 | let res = match syntax.kind() { | ||
3051 | RECORD_FIELD_LIST => FieldList::RecordFieldList(RecordFieldList { syntax }), | ||
3052 | TUPLE_FIELD_LIST => FieldList::TupleFieldList(TupleFieldList { syntax }), | ||
3053 | _ => return None, | ||
3054 | }; | ||
3055 | Some(res) | ||
3056 | } | ||
3057 | fn syntax(&self) -> &SyntaxNode { | ||
3058 | match self { | ||
3059 | FieldList::RecordFieldList(it) => &it.syntax, | ||
3060 | FieldList::TupleFieldList(it) => &it.syntax, | ||
3061 | } | ||
3062 | } | ||
3063 | } | ||
3064 | impl From<ArrayExpr> for Expr { | 2894 | impl From<ArrayExpr> for Expr { |
3065 | fn from(node: ArrayExpr) -> Expr { Expr::ArrayExpr(node) } | 2895 | fn from(node: ArrayExpr) -> Expr { Expr::ArrayExpr(node) } |
3066 | } | 2896 | } |
@@ -3233,6 +3063,218 @@ impl AstNode for Expr { | |||
3233 | } | 3063 | } |
3234 | } | 3064 | } |
3235 | } | 3065 | } |
3066 | impl From<Const> for Item { | ||
3067 | fn from(node: Const) -> Item { Item::Const(node) } | ||
3068 | } | ||
3069 | impl From<Enum> for Item { | ||
3070 | fn from(node: Enum) -> Item { Item::Enum(node) } | ||
3071 | } | ||
3072 | impl From<ExternBlock> for Item { | ||
3073 | fn from(node: ExternBlock) -> Item { Item::ExternBlock(node) } | ||
3074 | } | ||
3075 | impl From<ExternCrate> for Item { | ||
3076 | fn from(node: ExternCrate) -> Item { Item::ExternCrate(node) } | ||
3077 | } | ||
3078 | impl From<Fn> for Item { | ||
3079 | fn from(node: Fn) -> Item { Item::Fn(node) } | ||
3080 | } | ||
3081 | impl From<Impl> for Item { | ||
3082 | fn from(node: Impl) -> Item { Item::Impl(node) } | ||
3083 | } | ||
3084 | impl From<MacroCall> for Item { | ||
3085 | fn from(node: MacroCall) -> Item { Item::MacroCall(node) } | ||
3086 | } | ||
3087 | impl From<Module> for Item { | ||
3088 | fn from(node: Module) -> Item { Item::Module(node) } | ||
3089 | } | ||
3090 | impl From<Static> for Item { | ||
3091 | fn from(node: Static) -> Item { Item::Static(node) } | ||
3092 | } | ||
3093 | impl From<Struct> for Item { | ||
3094 | fn from(node: Struct) -> Item { Item::Struct(node) } | ||
3095 | } | ||
3096 | impl From<Trait> for Item { | ||
3097 | fn from(node: Trait) -> Item { Item::Trait(node) } | ||
3098 | } | ||
3099 | impl From<TypeAlias> for Item { | ||
3100 | fn from(node: TypeAlias) -> Item { Item::TypeAlias(node) } | ||
3101 | } | ||
3102 | impl From<Union> for Item { | ||
3103 | fn from(node: Union) -> Item { Item::Union(node) } | ||
3104 | } | ||
3105 | impl From<Use> for Item { | ||
3106 | fn from(node: Use) -> Item { Item::Use(node) } | ||
3107 | } | ||
3108 | impl AstNode for Item { | ||
3109 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3110 | match kind { | ||
3111 | CONST | ENUM | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL | MACRO_CALL | MODULE | ||
3112 | | STATIC | STRUCT | TRAIT | TYPE_ALIAS | UNION | USE => true, | ||
3113 | _ => false, | ||
3114 | } | ||
3115 | } | ||
3116 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3117 | let res = match syntax.kind() { | ||
3118 | CONST => Item::Const(Const { syntax }), | ||
3119 | ENUM => Item::Enum(Enum { syntax }), | ||
3120 | EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }), | ||
3121 | EXTERN_CRATE => Item::ExternCrate(ExternCrate { syntax }), | ||
3122 | FN => Item::Fn(Fn { syntax }), | ||
3123 | IMPL => Item::Impl(Impl { syntax }), | ||
3124 | MACRO_CALL => Item::MacroCall(MacroCall { syntax }), | ||
3125 | MODULE => Item::Module(Module { syntax }), | ||
3126 | STATIC => Item::Static(Static { syntax }), | ||
3127 | STRUCT => Item::Struct(Struct { syntax }), | ||
3128 | TRAIT => Item::Trait(Trait { syntax }), | ||
3129 | TYPE_ALIAS => Item::TypeAlias(TypeAlias { syntax }), | ||
3130 | UNION => Item::Union(Union { syntax }), | ||
3131 | USE => Item::Use(Use { syntax }), | ||
3132 | _ => return None, | ||
3133 | }; | ||
3134 | Some(res) | ||
3135 | } | ||
3136 | fn syntax(&self) -> &SyntaxNode { | ||
3137 | match self { | ||
3138 | Item::Const(it) => &it.syntax, | ||
3139 | Item::Enum(it) => &it.syntax, | ||
3140 | Item::ExternBlock(it) => &it.syntax, | ||
3141 | Item::ExternCrate(it) => &it.syntax, | ||
3142 | Item::Fn(it) => &it.syntax, | ||
3143 | Item::Impl(it) => &it.syntax, | ||
3144 | Item::MacroCall(it) => &it.syntax, | ||
3145 | Item::Module(it) => &it.syntax, | ||
3146 | Item::Static(it) => &it.syntax, | ||
3147 | Item::Struct(it) => &it.syntax, | ||
3148 | Item::Trait(it) => &it.syntax, | ||
3149 | Item::TypeAlias(it) => &it.syntax, | ||
3150 | Item::Union(it) => &it.syntax, | ||
3151 | Item::Use(it) => &it.syntax, | ||
3152 | } | ||
3153 | } | ||
3154 | } | ||
3155 | impl From<OrPat> for Pat { | ||
3156 | fn from(node: OrPat) -> Pat { Pat::OrPat(node) } | ||
3157 | } | ||
3158 | impl From<ParenPat> for Pat { | ||
3159 | fn from(node: ParenPat) -> Pat { Pat::ParenPat(node) } | ||
3160 | } | ||
3161 | impl From<RefPat> for Pat { | ||
3162 | fn from(node: RefPat) -> Pat { Pat::RefPat(node) } | ||
3163 | } | ||
3164 | impl From<BoxPat> for Pat { | ||
3165 | fn from(node: BoxPat) -> Pat { Pat::BoxPat(node) } | ||
3166 | } | ||
3167 | impl From<BindPat> for Pat { | ||
3168 | fn from(node: BindPat) -> Pat { Pat::BindPat(node) } | ||
3169 | } | ||
3170 | impl From<PlaceholderPat> for Pat { | ||
3171 | fn from(node: PlaceholderPat) -> Pat { Pat::PlaceholderPat(node) } | ||
3172 | } | ||
3173 | impl From<DotDotPat> for Pat { | ||
3174 | fn from(node: DotDotPat) -> Pat { Pat::DotDotPat(node) } | ||
3175 | } | ||
3176 | impl From<PathPat> for Pat { | ||
3177 | fn from(node: PathPat) -> Pat { Pat::PathPat(node) } | ||
3178 | } | ||
3179 | impl From<RecordPat> for Pat { | ||
3180 | fn from(node: RecordPat) -> Pat { Pat::RecordPat(node) } | ||
3181 | } | ||
3182 | impl From<TupleStructPat> for Pat { | ||
3183 | fn from(node: TupleStructPat) -> Pat { Pat::TupleStructPat(node) } | ||
3184 | } | ||
3185 | impl From<TuplePat> for Pat { | ||
3186 | fn from(node: TuplePat) -> Pat { Pat::TuplePat(node) } | ||
3187 | } | ||
3188 | impl From<SlicePat> for Pat { | ||
3189 | fn from(node: SlicePat) -> Pat { Pat::SlicePat(node) } | ||
3190 | } | ||
3191 | impl From<RangePat> for Pat { | ||
3192 | fn from(node: RangePat) -> Pat { Pat::RangePat(node) } | ||
3193 | } | ||
3194 | impl From<LiteralPat> for Pat { | ||
3195 | fn from(node: LiteralPat) -> Pat { Pat::LiteralPat(node) } | ||
3196 | } | ||
3197 | impl From<MacroPat> for Pat { | ||
3198 | fn from(node: MacroPat) -> Pat { Pat::MacroPat(node) } | ||
3199 | } | ||
3200 | impl AstNode for Pat { | ||
3201 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3202 | match kind { | ||
3203 | OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT | ||
3204 | | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT | ||
3205 | | LITERAL_PAT | MACRO_PAT => true, | ||
3206 | _ => false, | ||
3207 | } | ||
3208 | } | ||
3209 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3210 | let res = match syntax.kind() { | ||
3211 | OR_PAT => Pat::OrPat(OrPat { syntax }), | ||
3212 | PAREN_PAT => Pat::ParenPat(ParenPat { syntax }), | ||
3213 | REF_PAT => Pat::RefPat(RefPat { syntax }), | ||
3214 | BOX_PAT => Pat::BoxPat(BoxPat { syntax }), | ||
3215 | BIND_PAT => Pat::BindPat(BindPat { syntax }), | ||
3216 | PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }), | ||
3217 | DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }), | ||
3218 | PATH_PAT => Pat::PathPat(PathPat { syntax }), | ||
3219 | RECORD_PAT => Pat::RecordPat(RecordPat { syntax }), | ||
3220 | TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }), | ||
3221 | TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }), | ||
3222 | SLICE_PAT => Pat::SlicePat(SlicePat { syntax }), | ||
3223 | RANGE_PAT => Pat::RangePat(RangePat { syntax }), | ||
3224 | LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }), | ||
3225 | MACRO_PAT => Pat::MacroPat(MacroPat { syntax }), | ||
3226 | _ => return None, | ||
3227 | }; | ||
3228 | Some(res) | ||
3229 | } | ||
3230 | fn syntax(&self) -> &SyntaxNode { | ||
3231 | match self { | ||
3232 | Pat::OrPat(it) => &it.syntax, | ||
3233 | Pat::ParenPat(it) => &it.syntax, | ||
3234 | Pat::RefPat(it) => &it.syntax, | ||
3235 | Pat::BoxPat(it) => &it.syntax, | ||
3236 | Pat::BindPat(it) => &it.syntax, | ||
3237 | Pat::PlaceholderPat(it) => &it.syntax, | ||
3238 | Pat::DotDotPat(it) => &it.syntax, | ||
3239 | Pat::PathPat(it) => &it.syntax, | ||
3240 | Pat::RecordPat(it) => &it.syntax, | ||
3241 | Pat::TupleStructPat(it) => &it.syntax, | ||
3242 | Pat::TuplePat(it) => &it.syntax, | ||
3243 | Pat::SlicePat(it) => &it.syntax, | ||
3244 | Pat::RangePat(it) => &it.syntax, | ||
3245 | Pat::LiteralPat(it) => &it.syntax, | ||
3246 | Pat::MacroPat(it) => &it.syntax, | ||
3247 | } | ||
3248 | } | ||
3249 | } | ||
3250 | impl From<RecordFieldList> for FieldList { | ||
3251 | fn from(node: RecordFieldList) -> FieldList { FieldList::RecordFieldList(node) } | ||
3252 | } | ||
3253 | impl From<TupleFieldList> for FieldList { | ||
3254 | fn from(node: TupleFieldList) -> FieldList { FieldList::TupleFieldList(node) } | ||
3255 | } | ||
3256 | impl AstNode for FieldList { | ||
3257 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3258 | match kind { | ||
3259 | RECORD_FIELD_LIST | TUPLE_FIELD_LIST => true, | ||
3260 | _ => false, | ||
3261 | } | ||
3262 | } | ||
3263 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3264 | let res = match syntax.kind() { | ||
3265 | RECORD_FIELD_LIST => FieldList::RecordFieldList(RecordFieldList { syntax }), | ||
3266 | TUPLE_FIELD_LIST => FieldList::TupleFieldList(TupleFieldList { syntax }), | ||
3267 | _ => return None, | ||
3268 | }; | ||
3269 | Some(res) | ||
3270 | } | ||
3271 | fn syntax(&self) -> &SyntaxNode { | ||
3272 | match self { | ||
3273 | FieldList::RecordFieldList(it) => &it.syntax, | ||
3274 | FieldList::TupleFieldList(it) => &it.syntax, | ||
3275 | } | ||
3276 | } | ||
3277 | } | ||
3236 | impl From<Enum> for AdtDef { | 3278 | impl From<Enum> for AdtDef { |
3237 | fn from(node: Enum) -> AdtDef { AdtDef::Enum(node) } | 3279 | fn from(node: Enum) -> AdtDef { AdtDef::Enum(node) } |
3238 | } | 3280 | } |
@@ -3379,7 +3421,7 @@ impl From<Item> for Stmt { | |||
3379 | impl From<LetStmt> for Stmt { | 3421 | impl From<LetStmt> for Stmt { |
3380 | fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) } | 3422 | fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) } |
3381 | } | 3423 | } |
3382 | impl std::fmt::Display for Item { | 3424 | impl std::fmt::Display for GenericArg { |
3383 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3425 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3384 | std::fmt::Display::fmt(self.syntax(), f) | 3426 | std::fmt::Display::fmt(self.syntax(), f) |
3385 | } | 3427 | } |
@@ -3389,17 +3431,22 @@ impl std::fmt::Display for Type { | |||
3389 | std::fmt::Display::fmt(self.syntax(), f) | 3431 | std::fmt::Display::fmt(self.syntax(), f) |
3390 | } | 3432 | } |
3391 | } | 3433 | } |
3392 | impl std::fmt::Display for Pat { | 3434 | impl std::fmt::Display for Expr { |
3393 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3435 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3394 | std::fmt::Display::fmt(self.syntax(), f) | 3436 | std::fmt::Display::fmt(self.syntax(), f) |
3395 | } | 3437 | } |
3396 | } | 3438 | } |
3397 | impl std::fmt::Display for FieldList { | 3439 | impl std::fmt::Display for Item { |
3398 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3440 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3399 | std::fmt::Display::fmt(self.syntax(), f) | 3441 | std::fmt::Display::fmt(self.syntax(), f) |
3400 | } | 3442 | } |
3401 | } | 3443 | } |
3402 | impl std::fmt::Display for Expr { | 3444 | impl std::fmt::Display for Pat { |
3445 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3446 | std::fmt::Display::fmt(self.syntax(), f) | ||
3447 | } | ||
3448 | } | ||
3449 | impl std::fmt::Display for FieldList { | ||
3403 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3450 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3404 | std::fmt::Display::fmt(self.syntax(), f) | 3451 | std::fmt::Display::fmt(self.syntax(), f) |
3405 | } | 3452 | } |
@@ -3429,6 +3476,66 @@ impl std::fmt::Display for Stmt { | |||
3429 | std::fmt::Display::fmt(self.syntax(), f) | 3476 | std::fmt::Display::fmt(self.syntax(), f) |
3430 | } | 3477 | } |
3431 | } | 3478 | } |
3479 | impl std::fmt::Display for Path { | ||
3480 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3481 | std::fmt::Display::fmt(self.syntax(), f) | ||
3482 | } | ||
3483 | } | ||
3484 | impl std::fmt::Display for PathSegment { | ||
3485 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3486 | std::fmt::Display::fmt(self.syntax(), f) | ||
3487 | } | ||
3488 | } | ||
3489 | impl std::fmt::Display for NameRef { | ||
3490 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3491 | std::fmt::Display::fmt(self.syntax(), f) | ||
3492 | } | ||
3493 | } | ||
3494 | impl std::fmt::Display for GenericArgList { | ||
3495 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3496 | std::fmt::Display::fmt(self.syntax(), f) | ||
3497 | } | ||
3498 | } | ||
3499 | impl std::fmt::Display for ParamList { | ||
3500 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3501 | std::fmt::Display::fmt(self.syntax(), f) | ||
3502 | } | ||
3503 | } | ||
3504 | impl std::fmt::Display for RetType { | ||
3505 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3506 | std::fmt::Display::fmt(self.syntax(), f) | ||
3507 | } | ||
3508 | } | ||
3509 | impl std::fmt::Display for PathType { | ||
3510 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3511 | std::fmt::Display::fmt(self.syntax(), f) | ||
3512 | } | ||
3513 | } | ||
3514 | impl std::fmt::Display for TypeArg { | ||
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 AssocTypeArg { | ||
3520 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3521 | std::fmt::Display::fmt(self.syntax(), f) | ||
3522 | } | ||
3523 | } | ||
3524 | impl std::fmt::Display for LifetimeArg { | ||
3525 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3526 | std::fmt::Display::fmt(self.syntax(), f) | ||
3527 | } | ||
3528 | } | ||
3529 | impl std::fmt::Display for ConstArg { | ||
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 TypeBoundList { | ||
3535 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3536 | std::fmt::Display::fmt(self.syntax(), f) | ||
3537 | } | ||
3538 | } | ||
3432 | impl std::fmt::Display for SourceFile { | 3539 | impl std::fmt::Display for SourceFile { |
3433 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3540 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3434 | std::fmt::Display::fmt(self.syntax(), f) | 3541 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3524,11 +3631,6 @@ impl std::fmt::Display for ItemList { | |||
3524 | std::fmt::Display::fmt(self.syntax(), f) | 3631 | std::fmt::Display::fmt(self.syntax(), f) |
3525 | } | 3632 | } |
3526 | } | 3633 | } |
3527 | impl std::fmt::Display for NameRef { | ||
3528 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3529 | std::fmt::Display::fmt(self.syntax(), f) | ||
3530 | } | ||
3531 | } | ||
3532 | impl std::fmt::Display for Rename { | 3634 | impl std::fmt::Display for Rename { |
3533 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3635 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3534 | std::fmt::Display::fmt(self.syntax(), f) | 3636 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3539,11 +3641,6 @@ impl std::fmt::Display for UseTree { | |||
3539 | std::fmt::Display::fmt(self.syntax(), f) | 3641 | std::fmt::Display::fmt(self.syntax(), f) |
3540 | } | 3642 | } |
3541 | } | 3643 | } |
3542 | impl std::fmt::Display for Path { | ||
3543 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3544 | std::fmt::Display::fmt(self.syntax(), f) | ||
3545 | } | ||
3546 | } | ||
3547 | impl std::fmt::Display for UseTreeList { | 3644 | impl std::fmt::Display for UseTreeList { |
3548 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3645 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3549 | std::fmt::Display::fmt(self.syntax(), f) | 3646 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3559,16 +3656,6 @@ impl std::fmt::Display for GenericParamList { | |||
3559 | std::fmt::Display::fmt(self.syntax(), f) | 3656 | std::fmt::Display::fmt(self.syntax(), f) |
3560 | } | 3657 | } |
3561 | } | 3658 | } |
3562 | impl std::fmt::Display for ParamList { | ||
3563 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3564 | std::fmt::Display::fmt(self.syntax(), f) | ||
3565 | } | ||
3566 | } | ||
3567 | impl std::fmt::Display for RetType { | ||
3568 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3569 | std::fmt::Display::fmt(self.syntax(), f) | ||
3570 | } | ||
3571 | } | ||
3572 | impl std::fmt::Display for WhereClause { | 3659 | impl std::fmt::Display for WhereClause { |
3573 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3660 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3574 | std::fmt::Display::fmt(self.syntax(), f) | 3661 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3589,11 +3676,6 @@ impl std::fmt::Display for Param { | |||
3589 | std::fmt::Display::fmt(self.syntax(), f) | 3676 | std::fmt::Display::fmt(self.syntax(), f) |
3590 | } | 3677 | } |
3591 | } | 3678 | } |
3592 | impl std::fmt::Display for TypeBoundList { | ||
3593 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3594 | std::fmt::Display::fmt(self.syntax(), f) | ||
3595 | } | ||
3596 | } | ||
3597 | impl std::fmt::Display for RecordFieldList { | 3679 | impl std::fmt::Display for RecordFieldList { |
3598 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3680 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3599 | std::fmt::Display::fmt(self.syntax(), f) | 3681 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3829,11 +3911,6 @@ impl std::fmt::Display for ArgList { | |||
3829 | std::fmt::Display::fmt(self.syntax(), f) | 3911 | std::fmt::Display::fmt(self.syntax(), f) |
3830 | } | 3912 | } |
3831 | } | 3913 | } |
3832 | impl std::fmt::Display for TypeArgList { | ||
3833 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3834 | std::fmt::Display::fmt(self.syntax(), f) | ||
3835 | } | ||
3836 | } | ||
3837 | impl std::fmt::Display for Condition { | 3914 | impl std::fmt::Display for Condition { |
3838 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3915 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3839 | std::fmt::Display::fmt(self.syntax(), f) | 3916 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3894,11 +3971,6 @@ impl std::fmt::Display for ParenType { | |||
3894 | std::fmt::Display::fmt(self.syntax(), f) | 3971 | std::fmt::Display::fmt(self.syntax(), f) |
3895 | } | 3972 | } |
3896 | } | 3973 | } |
3897 | impl std::fmt::Display for PathType { | ||
3898 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3899 | std::fmt::Display::fmt(self.syntax(), f) | ||
3900 | } | ||
3901 | } | ||
3902 | impl std::fmt::Display for PointerType { | 3974 | impl std::fmt::Display for PointerType { |
3903 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3975 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3904 | std::fmt::Display::fmt(self.syntax(), f) | 3976 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -4024,28 +4096,3 @@ impl std::fmt::Display for MacroStmts { | |||
4024 | std::fmt::Display::fmt(self.syntax(), f) | 4096 | std::fmt::Display::fmt(self.syntax(), f) |
4025 | } | 4097 | } |
4026 | } | 4098 | } |
4027 | impl std::fmt::Display for PathSegment { | ||
4028 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
4029 | std::fmt::Display::fmt(self.syntax(), f) | ||
4030 | } | ||
4031 | } | ||
4032 | impl std::fmt::Display for TypeArg { | ||
4033 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
4034 | std::fmt::Display::fmt(self.syntax(), f) | ||
4035 | } | ||
4036 | } | ||
4037 | impl std::fmt::Display for LifetimeArg { | ||
4038 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
4039 | std::fmt::Display::fmt(self.syntax(), f) | ||
4040 | } | ||
4041 | } | ||
4042 | impl std::fmt::Display for AssocTypeArg { | ||
4043 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
4044 | std::fmt::Display::fmt(self.syntax(), f) | ||
4045 | } | ||
4046 | } | ||
4047 | impl std::fmt::Display for ConstArg { | ||
4048 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
4049 | std::fmt::Display::fmt(self.syntax(), f) | ||
4050 | } | ||
4051 | } | ||