diff options
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/ast/generated/nodes.rs | 893 |
1 files changed, 447 insertions, 446 deletions
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index e049548c9..1a707ad67 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs | |||
@@ -6,6 +6,137 @@ 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 coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) } | ||
23 | pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) } | ||
24 | pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) } | ||
25 | pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) } | ||
26 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | ||
27 | pub fn type_arg_list(&self) -> Option<TypeArgList> { 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 TypeArgList { | ||
44 | pub(crate) syntax: SyntaxNode, | ||
45 | } | ||
46 | impl TypeArgList { | ||
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 type_args(&self) -> AstChildren<TypeArg> { support::children(&self.syntax) } | ||
50 | pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> { support::children(&self.syntax) } | ||
51 | pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> { support::children(&self.syntax) } | ||
52 | pub fn const_args(&self) -> AstChildren<ConstArg> { support::children(&self.syntax) } | ||
53 | pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) } | ||
54 | } | ||
55 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
56 | pub struct ParamList { | ||
57 | pub(crate) syntax: SyntaxNode, | ||
58 | } | ||
59 | impl ParamList { | ||
60 | pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } | ||
61 | pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) } | ||
62 | pub fn comma_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![,]) } | ||
63 | pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) } | ||
64 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | ||
65 | } | ||
66 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
67 | pub struct RetType { | ||
68 | pub(crate) syntax: SyntaxNode, | ||
69 | } | ||
70 | impl RetType { | ||
71 | pub fn thin_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![->]) } | ||
72 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } | ||
73 | } | ||
74 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
75 | pub struct PathType { | ||
76 | pub(crate) syntax: SyntaxNode, | ||
77 | } | ||
78 | impl PathType { | ||
79 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } | ||
80 | } | ||
81 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
82 | pub struct TypeArg { | ||
83 | pub(crate) syntax: SyntaxNode, | ||
84 | } | ||
85 | impl TypeArg { | ||
86 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } | ||
87 | } | ||
88 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
89 | pub struct LifetimeArg { | ||
90 | pub(crate) syntax: SyntaxNode, | ||
91 | } | ||
92 | impl LifetimeArg { | ||
93 | pub fn lifetime_token(&self) -> Option<SyntaxToken> { | ||
94 | support::token(&self.syntax, T![lifetime]) | ||
95 | } | ||
96 | } | ||
97 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
98 | pub struct AssocTypeArg { | ||
99 | pub(crate) syntax: SyntaxNode, | ||
100 | } | ||
101 | impl ast::TypeBoundsOwner for AssocTypeArg {} | ||
102 | impl AssocTypeArg { | ||
103 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | ||
104 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | ||
105 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } | ||
106 | } | ||
107 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
108 | pub struct ConstArg { | ||
109 | pub(crate) syntax: SyntaxNode, | ||
110 | } | ||
111 | impl ConstArg { | ||
112 | pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) } | ||
113 | pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) } | ||
114 | } | ||
115 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
116 | pub struct TypeBoundList { | ||
117 | pub(crate) syntax: SyntaxNode, | ||
118 | } | ||
119 | impl TypeBoundList { | ||
120 | pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) } | ||
121 | } | ||
122 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
123 | pub struct Literal { | ||
124 | pub(crate) syntax: SyntaxNode, | ||
125 | } | ||
126 | impl ast::AttrsOwner for Literal {} | ||
127 | impl Literal {} | ||
128 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
129 | pub struct BlockExpr { | ||
130 | pub(crate) syntax: SyntaxNode, | ||
131 | } | ||
132 | impl ast::AttrsOwner for BlockExpr {} | ||
133 | impl BlockExpr { | ||
134 | pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } | ||
135 | pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) } | ||
136 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
137 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | ||
138 | } | ||
139 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
9 | pub struct SourceFile { | 140 | pub struct SourceFile { |
10 | pub(crate) syntax: SyntaxNode, | 141 | pub(crate) syntax: SyntaxNode, |
11 | } | 142 | } |
@@ -256,13 +387,6 @@ impl ItemList { | |||
256 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | 387 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } |
257 | } | 388 | } |
258 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 389 | #[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 { | 390 | pub struct Rename { |
267 | pub(crate) syntax: SyntaxNode, | 391 | pub(crate) syntax: SyntaxNode, |
268 | } | 392 | } |
@@ -283,15 +407,6 @@ impl UseTree { | |||
283 | pub fn rename(&self) -> Option<Rename> { support::child(&self.syntax) } | 407 | pub fn rename(&self) -> Option<Rename> { support::child(&self.syntax) } |
284 | } | 408 | } |
285 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 409 | #[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 { | 410 | pub struct UseTreeList { |
296 | pub(crate) syntax: SyntaxNode, | 411 | pub(crate) syntax: SyntaxNode, |
297 | } | 412 | } |
@@ -317,25 +432,6 @@ impl GenericParamList { | |||
317 | pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) } | 432 | pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) } |
318 | } | 433 | } |
319 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 434 | #[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 { | 435 | pub struct WhereClause { |
340 | pub(crate) syntax: SyntaxNode, | 436 | pub(crate) syntax: SyntaxNode, |
341 | } | 437 | } |
@@ -344,17 +440,6 @@ impl WhereClause { | |||
344 | pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) } | 440 | pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) } |
345 | } | 441 | } |
346 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 442 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
347 | pub struct BlockExpr { | ||
348 | pub(crate) syntax: SyntaxNode, | ||
349 | } | ||
350 | impl ast::AttrsOwner for BlockExpr {} | ||
351 | impl BlockExpr { | ||
352 | pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } | ||
353 | pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) } | ||
354 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
355 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | ||
356 | } | ||
357 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
358 | pub struct SelfParam { | 443 | pub struct SelfParam { |
359 | pub(crate) syntax: SyntaxNode, | 444 | pub(crate) syntax: SyntaxNode, |
360 | } | 445 | } |
@@ -381,13 +466,6 @@ impl Param { | |||
381 | pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) } | 466 | pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) } |
382 | } | 467 | } |
383 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 468 | #[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 { | 469 | pub struct RecordFieldList { |
392 | pub(crate) syntax: SyntaxNode, | 470 | pub(crate) syntax: SyntaxNode, |
393 | } | 471 | } |
@@ -515,12 +593,6 @@ impl WherePred { | |||
515 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } | 593 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } |
516 | } | 594 | } |
517 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 595 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
518 | pub struct Literal { | ||
519 | pub(crate) syntax: SyntaxNode, | ||
520 | } | ||
521 | impl ast::AttrsOwner for Literal {} | ||
522 | impl Literal {} | ||
523 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
524 | pub struct TokenTree { | 596 | pub struct TokenTree { |
525 | pub(crate) syntax: SyntaxNode, | 597 | pub(crate) syntax: SyntaxNode, |
526 | } | 598 | } |
@@ -866,19 +938,6 @@ impl ArgList { | |||
866 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | 938 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } |
867 | } | 939 | } |
868 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 940 | #[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 { | 941 | pub struct Condition { |
883 | pub(crate) syntax: SyntaxNode, | 942 | pub(crate) syntax: SyntaxNode, |
884 | } | 943 | } |
@@ -991,13 +1050,6 @@ impl ParenType { | |||
991 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | 1050 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } |
992 | } | 1051 | } |
993 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1052 | #[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 { | 1053 | pub struct PointerType { |
1002 | pub(crate) syntax: SyntaxNode, | 1054 | pub(crate) syntax: SyntaxNode, |
1003 | } | 1055 | } |
@@ -1220,55 +1272,20 @@ impl MacroStmts { | |||
1220 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 1272 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
1221 | } | 1273 | } |
1222 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1274 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1223 | pub struct PathSegment { | 1275 | pub enum Type { |
1224 | pub(crate) syntax: SyntaxNode, | 1276 | ArrayType(ArrayType), |
1225 | } | 1277 | DynTraitType(DynTraitType), |
1226 | impl PathSegment { | 1278 | FnPointerType(FnPointerType), |
1227 | pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) } | 1279 | ForType(ForType), |
1228 | pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) } | 1280 | ImplTraitType(ImplTraitType), |
1229 | pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) } | 1281 | InferType(InferType), |
1230 | pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) } | 1282 | NeverType(NeverType), |
1231 | pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) } | 1283 | ParenType(ParenType), |
1232 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | 1284 | PathType(PathType), |
1233 | pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) } | 1285 | PointerType(PointerType), |
1234 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } | 1286 | ReferenceType(ReferenceType), |
1235 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } | 1287 | SliceType(SliceType), |
1236 | pub fn path_type(&self) -> Option<PathType> { support::child(&self.syntax) } | 1288 | TupleType(TupleType), |
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 | } | 1289 | } |
1273 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1290 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1274 | pub enum Item { | 1291 | pub enum Item { |
@@ -1289,22 +1306,6 @@ pub enum Item { | |||
1289 | } | 1306 | } |
1290 | impl ast::AttrsOwner for Item {} | 1307 | impl ast::AttrsOwner for Item {} |
1291 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1308 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1292 | pub enum Type { | ||
1293 | ArrayType(ArrayType), | ||
1294 | DynTraitType(DynTraitType), | ||
1295 | FnPointerType(FnPointerType), | ||
1296 | ForType(ForType), | ||
1297 | ImplTraitType(ImplTraitType), | ||
1298 | InferType(InferType), | ||
1299 | NeverType(NeverType), | ||
1300 | ParenType(ParenType), | ||
1301 | PathType(PathType), | ||
1302 | PointerType(PointerType), | ||
1303 | ReferenceType(ReferenceType), | ||
1304 | SliceType(SliceType), | ||
1305 | TupleType(TupleType), | ||
1306 | } | ||
1307 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1308 | pub enum Pat { | 1309 | pub enum Pat { |
1309 | OrPat(OrPat), | 1310 | OrPat(OrPat), |
1310 | ParenPat(ParenPat), | 1311 | ParenPat(ParenPat), |
@@ -1400,8 +1401,8 @@ pub enum Stmt { | |||
1400 | Item(Item), | 1401 | Item(Item), |
1401 | LetStmt(LetStmt), | 1402 | LetStmt(LetStmt), |
1402 | } | 1403 | } |
1403 | impl AstNode for SourceFile { | 1404 | impl AstNode for Path { |
1404 | fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE } | 1405 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH } |
1405 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1406 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1406 | if Self::can_cast(syntax.kind()) { | 1407 | if Self::can_cast(syntax.kind()) { |
1407 | Some(Self { syntax }) | 1408 | Some(Self { syntax }) |
@@ -1411,8 +1412,8 @@ impl AstNode for SourceFile { | |||
1411 | } | 1412 | } |
1412 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1413 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1413 | } | 1414 | } |
1414 | impl AstNode for Attr { | 1415 | impl AstNode for PathSegment { |
1415 | fn can_cast(kind: SyntaxKind) -> bool { kind == ATTR } | 1416 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT } |
1416 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1417 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1417 | if Self::can_cast(syntax.kind()) { | 1418 | if Self::can_cast(syntax.kind()) { |
1418 | Some(Self { syntax }) | 1419 | Some(Self { syntax }) |
@@ -1422,8 +1423,8 @@ impl AstNode for Attr { | |||
1422 | } | 1423 | } |
1423 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1424 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1424 | } | 1425 | } |
1425 | impl AstNode for Const { | 1426 | impl AstNode for NameRef { |
1426 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONST } | 1427 | fn can_cast(kind: SyntaxKind) -> bool { kind == NAME_REF } |
1427 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1428 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1428 | if Self::can_cast(syntax.kind()) { | 1429 | if Self::can_cast(syntax.kind()) { |
1429 | Some(Self { syntax }) | 1430 | Some(Self { syntax }) |
@@ -1433,8 +1434,8 @@ impl AstNode for Const { | |||
1433 | } | 1434 | } |
1434 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1435 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1435 | } | 1436 | } |
1436 | impl AstNode for Enum { | 1437 | impl AstNode for TypeArgList { |
1437 | fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM } | 1438 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG_LIST } |
1438 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1439 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1439 | if Self::can_cast(syntax.kind()) { | 1440 | if Self::can_cast(syntax.kind()) { |
1440 | Some(Self { syntax }) | 1441 | Some(Self { syntax }) |
@@ -1444,8 +1445,8 @@ impl AstNode for Enum { | |||
1444 | } | 1445 | } |
1445 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1446 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1446 | } | 1447 | } |
1447 | impl AstNode for ExternBlock { | 1448 | impl AstNode for ParamList { |
1448 | fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_BLOCK } | 1449 | fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM_LIST } |
1449 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1450 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1450 | if Self::can_cast(syntax.kind()) { | 1451 | if Self::can_cast(syntax.kind()) { |
1451 | Some(Self { syntax }) | 1452 | Some(Self { syntax }) |
@@ -1455,8 +1456,8 @@ impl AstNode for ExternBlock { | |||
1455 | } | 1456 | } |
1456 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1457 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1457 | } | 1458 | } |
1458 | impl AstNode for ExternCrate { | 1459 | impl AstNode for RetType { |
1459 | fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_CRATE } | 1460 | fn can_cast(kind: SyntaxKind) -> bool { kind == RET_TYPE } |
1460 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1461 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1461 | if Self::can_cast(syntax.kind()) { | 1462 | if Self::can_cast(syntax.kind()) { |
1462 | Some(Self { syntax }) | 1463 | Some(Self { syntax }) |
@@ -1466,8 +1467,8 @@ impl AstNode for ExternCrate { | |||
1466 | } | 1467 | } |
1467 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1468 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1468 | } | 1469 | } |
1469 | impl AstNode for Fn { | 1470 | impl AstNode for PathType { |
1470 | fn can_cast(kind: SyntaxKind) -> bool { kind == FN } | 1471 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_TYPE } |
1471 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1472 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1472 | if Self::can_cast(syntax.kind()) { | 1473 | if Self::can_cast(syntax.kind()) { |
1473 | Some(Self { syntax }) | 1474 | Some(Self { syntax }) |
@@ -1477,8 +1478,8 @@ impl AstNode for Fn { | |||
1477 | } | 1478 | } |
1478 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1479 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1479 | } | 1480 | } |
1480 | impl AstNode for Impl { | 1481 | impl AstNode for TypeArg { |
1481 | fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL } | 1482 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG } |
1482 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1483 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1483 | if Self::can_cast(syntax.kind()) { | 1484 | if Self::can_cast(syntax.kind()) { |
1484 | Some(Self { syntax }) | 1485 | Some(Self { syntax }) |
@@ -1488,8 +1489,8 @@ impl AstNode for Impl { | |||
1488 | } | 1489 | } |
1489 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1490 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1490 | } | 1491 | } |
1491 | impl AstNode for MacroCall { | 1492 | impl AstNode for LifetimeArg { |
1492 | fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_CALL } | 1493 | fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_ARG } |
1493 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1494 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1494 | if Self::can_cast(syntax.kind()) { | 1495 | if Self::can_cast(syntax.kind()) { |
1495 | Some(Self { syntax }) | 1496 | Some(Self { syntax }) |
@@ -1499,8 +1500,8 @@ impl AstNode for MacroCall { | |||
1499 | } | 1500 | } |
1500 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1501 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1501 | } | 1502 | } |
1502 | impl AstNode for Module { | 1503 | impl AstNode for AssocTypeArg { |
1503 | fn can_cast(kind: SyntaxKind) -> bool { kind == MODULE } | 1504 | fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_TYPE_ARG } |
1504 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1505 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1505 | if Self::can_cast(syntax.kind()) { | 1506 | if Self::can_cast(syntax.kind()) { |
1506 | Some(Self { syntax }) | 1507 | Some(Self { syntax }) |
@@ -1510,8 +1511,8 @@ impl AstNode for Module { | |||
1510 | } | 1511 | } |
1511 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1512 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1512 | } | 1513 | } |
1513 | impl AstNode for Static { | 1514 | impl AstNode for ConstArg { |
1514 | fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC } | 1515 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_ARG } |
1515 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1516 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1516 | if Self::can_cast(syntax.kind()) { | 1517 | if Self::can_cast(syntax.kind()) { |
1517 | Some(Self { syntax }) | 1518 | Some(Self { syntax }) |
@@ -1521,8 +1522,8 @@ impl AstNode for Static { | |||
1521 | } | 1522 | } |
1522 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1523 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1523 | } | 1524 | } |
1524 | impl AstNode for Struct { | 1525 | impl AstNode for TypeBoundList { |
1525 | fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT } | 1526 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST } |
1526 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1527 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1527 | if Self::can_cast(syntax.kind()) { | 1528 | if Self::can_cast(syntax.kind()) { |
1528 | Some(Self { syntax }) | 1529 | Some(Self { syntax }) |
@@ -1532,8 +1533,8 @@ impl AstNode for Struct { | |||
1532 | } | 1533 | } |
1533 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1534 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1534 | } | 1535 | } |
1535 | impl AstNode for Trait { | 1536 | impl AstNode for Literal { |
1536 | fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT } | 1537 | fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL } |
1537 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1538 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1538 | if Self::can_cast(syntax.kind()) { | 1539 | if Self::can_cast(syntax.kind()) { |
1539 | Some(Self { syntax }) | 1540 | Some(Self { syntax }) |
@@ -1543,8 +1544,8 @@ impl AstNode for Trait { | |||
1543 | } | 1544 | } |
1544 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1545 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1545 | } | 1546 | } |
1546 | impl AstNode for TypeAlias { | 1547 | impl AstNode for BlockExpr { |
1547 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS } | 1548 | fn can_cast(kind: SyntaxKind) -> bool { kind == BLOCK_EXPR } |
1548 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1549 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1549 | if Self::can_cast(syntax.kind()) { | 1550 | if Self::can_cast(syntax.kind()) { |
1550 | Some(Self { syntax }) | 1551 | Some(Self { syntax }) |
@@ -1554,8 +1555,8 @@ impl AstNode for TypeAlias { | |||
1554 | } | 1555 | } |
1555 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1556 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1556 | } | 1557 | } |
1557 | impl AstNode for Union { | 1558 | impl AstNode for SourceFile { |
1558 | fn can_cast(kind: SyntaxKind) -> bool { kind == UNION } | 1559 | fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE } |
1559 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1560 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1560 | if Self::can_cast(syntax.kind()) { | 1561 | if Self::can_cast(syntax.kind()) { |
1561 | Some(Self { syntax }) | 1562 | Some(Self { syntax }) |
@@ -1565,8 +1566,8 @@ impl AstNode for Union { | |||
1565 | } | 1566 | } |
1566 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1567 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1567 | } | 1568 | } |
1568 | impl AstNode for Use { | 1569 | impl AstNode for Attr { |
1569 | fn can_cast(kind: SyntaxKind) -> bool { kind == USE } | 1570 | fn can_cast(kind: SyntaxKind) -> bool { kind == ATTR } |
1570 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1571 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1571 | if Self::can_cast(syntax.kind()) { | 1572 | if Self::can_cast(syntax.kind()) { |
1572 | Some(Self { syntax }) | 1573 | Some(Self { syntax }) |
@@ -1576,8 +1577,8 @@ impl AstNode for Use { | |||
1576 | } | 1577 | } |
1577 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1578 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1578 | } | 1579 | } |
1579 | impl AstNode for Visibility { | 1580 | impl AstNode for Const { |
1580 | fn can_cast(kind: SyntaxKind) -> bool { kind == VISIBILITY } | 1581 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONST } |
1581 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1582 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1582 | if Self::can_cast(syntax.kind()) { | 1583 | if Self::can_cast(syntax.kind()) { |
1583 | Some(Self { syntax }) | 1584 | Some(Self { syntax }) |
@@ -1587,8 +1588,8 @@ impl AstNode for Visibility { | |||
1587 | } | 1588 | } |
1588 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1589 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1589 | } | 1590 | } |
1590 | impl AstNode for Name { | 1591 | impl AstNode for Enum { |
1591 | fn can_cast(kind: SyntaxKind) -> bool { kind == NAME } | 1592 | fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM } |
1592 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1593 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1593 | if Self::can_cast(syntax.kind()) { | 1594 | if Self::can_cast(syntax.kind()) { |
1594 | Some(Self { syntax }) | 1595 | Some(Self { syntax }) |
@@ -1598,8 +1599,8 @@ impl AstNode for Name { | |||
1598 | } | 1599 | } |
1599 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1600 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1600 | } | 1601 | } |
1601 | impl AstNode for ItemList { | 1602 | impl AstNode for ExternBlock { |
1602 | fn can_cast(kind: SyntaxKind) -> bool { kind == ITEM_LIST } | 1603 | fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_BLOCK } |
1603 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1604 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1604 | if Self::can_cast(syntax.kind()) { | 1605 | if Self::can_cast(syntax.kind()) { |
1605 | Some(Self { syntax }) | 1606 | Some(Self { syntax }) |
@@ -1609,8 +1610,8 @@ impl AstNode for ItemList { | |||
1609 | } | 1610 | } |
1610 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1611 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1611 | } | 1612 | } |
1612 | impl AstNode for NameRef { | 1613 | impl AstNode for ExternCrate { |
1613 | fn can_cast(kind: SyntaxKind) -> bool { kind == NAME_REF } | 1614 | fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_CRATE } |
1614 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1615 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1615 | if Self::can_cast(syntax.kind()) { | 1616 | if Self::can_cast(syntax.kind()) { |
1616 | Some(Self { syntax }) | 1617 | Some(Self { syntax }) |
@@ -1620,8 +1621,8 @@ impl AstNode for NameRef { | |||
1620 | } | 1621 | } |
1621 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1622 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1622 | } | 1623 | } |
1623 | impl AstNode for Rename { | 1624 | impl AstNode for Fn { |
1624 | fn can_cast(kind: SyntaxKind) -> bool { kind == RENAME } | 1625 | fn can_cast(kind: SyntaxKind) -> bool { kind == FN } |
1625 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1626 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1626 | if Self::can_cast(syntax.kind()) { | 1627 | if Self::can_cast(syntax.kind()) { |
1627 | Some(Self { syntax }) | 1628 | Some(Self { syntax }) |
@@ -1631,8 +1632,8 @@ impl AstNode for Rename { | |||
1631 | } | 1632 | } |
1632 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1633 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1633 | } | 1634 | } |
1634 | impl AstNode for UseTree { | 1635 | impl AstNode for Impl { |
1635 | fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE } | 1636 | fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL } |
1636 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1637 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1637 | if Self::can_cast(syntax.kind()) { | 1638 | if Self::can_cast(syntax.kind()) { |
1638 | Some(Self { syntax }) | 1639 | Some(Self { syntax }) |
@@ -1642,8 +1643,8 @@ impl AstNode for UseTree { | |||
1642 | } | 1643 | } |
1643 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1644 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1644 | } | 1645 | } |
1645 | impl AstNode for Path { | 1646 | impl AstNode for MacroCall { |
1646 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH } | 1647 | fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_CALL } |
1647 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1648 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1648 | if Self::can_cast(syntax.kind()) { | 1649 | if Self::can_cast(syntax.kind()) { |
1649 | Some(Self { syntax }) | 1650 | Some(Self { syntax }) |
@@ -1653,8 +1654,8 @@ impl AstNode for Path { | |||
1653 | } | 1654 | } |
1654 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1655 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1655 | } | 1656 | } |
1656 | impl AstNode for UseTreeList { | 1657 | impl AstNode for Module { |
1657 | fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE_LIST } | 1658 | fn can_cast(kind: SyntaxKind) -> bool { kind == MODULE } |
1658 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1659 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1659 | if Self::can_cast(syntax.kind()) { | 1660 | if Self::can_cast(syntax.kind()) { |
1660 | Some(Self { syntax }) | 1661 | Some(Self { syntax }) |
@@ -1664,8 +1665,8 @@ impl AstNode for UseTreeList { | |||
1664 | } | 1665 | } |
1665 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1666 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1666 | } | 1667 | } |
1667 | impl AstNode for Abi { | 1668 | impl AstNode for Static { |
1668 | fn can_cast(kind: SyntaxKind) -> bool { kind == ABI } | 1669 | fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC } |
1669 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1670 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1670 | if Self::can_cast(syntax.kind()) { | 1671 | if Self::can_cast(syntax.kind()) { |
1671 | Some(Self { syntax }) | 1672 | Some(Self { syntax }) |
@@ -1675,8 +1676,8 @@ impl AstNode for Abi { | |||
1675 | } | 1676 | } |
1676 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1677 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1677 | } | 1678 | } |
1678 | impl AstNode for GenericParamList { | 1679 | impl AstNode for Struct { |
1679 | fn can_cast(kind: SyntaxKind) -> bool { kind == GENERIC_PARAM_LIST } | 1680 | fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT } |
1680 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1681 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1681 | if Self::can_cast(syntax.kind()) { | 1682 | if Self::can_cast(syntax.kind()) { |
1682 | Some(Self { syntax }) | 1683 | Some(Self { syntax }) |
@@ -1686,8 +1687,8 @@ impl AstNode for GenericParamList { | |||
1686 | } | 1687 | } |
1687 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1688 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1688 | } | 1689 | } |
1689 | impl AstNode for ParamList { | 1690 | impl AstNode for Trait { |
1690 | fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM_LIST } | 1691 | fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT } |
1691 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1692 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1692 | if Self::can_cast(syntax.kind()) { | 1693 | if Self::can_cast(syntax.kind()) { |
1693 | Some(Self { syntax }) | 1694 | Some(Self { syntax }) |
@@ -1697,8 +1698,8 @@ impl AstNode for ParamList { | |||
1697 | } | 1698 | } |
1698 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1699 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1699 | } | 1700 | } |
1700 | impl AstNode for RetType { | 1701 | impl AstNode for TypeAlias { |
1701 | fn can_cast(kind: SyntaxKind) -> bool { kind == RET_TYPE } | 1702 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS } |
1702 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1703 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1703 | if Self::can_cast(syntax.kind()) { | 1704 | if Self::can_cast(syntax.kind()) { |
1704 | Some(Self { syntax }) | 1705 | Some(Self { syntax }) |
@@ -1708,8 +1709,8 @@ impl AstNode for RetType { | |||
1708 | } | 1709 | } |
1709 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1710 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1710 | } | 1711 | } |
1711 | impl AstNode for WhereClause { | 1712 | impl AstNode for Union { |
1712 | fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_CLAUSE } | 1713 | fn can_cast(kind: SyntaxKind) -> bool { kind == UNION } |
1713 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1714 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1714 | if Self::can_cast(syntax.kind()) { | 1715 | if Self::can_cast(syntax.kind()) { |
1715 | Some(Self { syntax }) | 1716 | Some(Self { syntax }) |
@@ -1719,8 +1720,8 @@ impl AstNode for WhereClause { | |||
1719 | } | 1720 | } |
1720 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1721 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1721 | } | 1722 | } |
1722 | impl AstNode for BlockExpr { | 1723 | impl AstNode for Use { |
1723 | fn can_cast(kind: SyntaxKind) -> bool { kind == BLOCK_EXPR } | 1724 | fn can_cast(kind: SyntaxKind) -> bool { kind == USE } |
1724 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1725 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1725 | if Self::can_cast(syntax.kind()) { | 1726 | if Self::can_cast(syntax.kind()) { |
1726 | Some(Self { syntax }) | 1727 | Some(Self { syntax }) |
@@ -1730,8 +1731,8 @@ impl AstNode for BlockExpr { | |||
1730 | } | 1731 | } |
1731 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1732 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1732 | } | 1733 | } |
1733 | impl AstNode for SelfParam { | 1734 | impl AstNode for Visibility { |
1734 | fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM } | 1735 | fn can_cast(kind: SyntaxKind) -> bool { kind == VISIBILITY } |
1735 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1736 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1736 | if Self::can_cast(syntax.kind()) { | 1737 | if Self::can_cast(syntax.kind()) { |
1737 | Some(Self { syntax }) | 1738 | Some(Self { syntax }) |
@@ -1741,8 +1742,8 @@ impl AstNode for SelfParam { | |||
1741 | } | 1742 | } |
1742 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1743 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1743 | } | 1744 | } |
1744 | impl AstNode for Param { | 1745 | impl AstNode for Name { |
1745 | fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM } | 1746 | fn can_cast(kind: SyntaxKind) -> bool { kind == NAME } |
1746 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1747 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1747 | if Self::can_cast(syntax.kind()) { | 1748 | if Self::can_cast(syntax.kind()) { |
1748 | Some(Self { syntax }) | 1749 | Some(Self { syntax }) |
@@ -1752,8 +1753,96 @@ impl AstNode for Param { | |||
1752 | } | 1753 | } |
1753 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1754 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1754 | } | 1755 | } |
1755 | impl AstNode for TypeBoundList { | 1756 | impl AstNode for ItemList { |
1756 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST } | 1757 | fn can_cast(kind: SyntaxKind) -> bool { kind == ITEM_LIST } |
1758 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1759 | if Self::can_cast(syntax.kind()) { | ||
1760 | Some(Self { syntax }) | ||
1761 | } else { | ||
1762 | None | ||
1763 | } | ||
1764 | } | ||
1765 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1766 | } | ||
1767 | impl AstNode for Rename { | ||
1768 | fn can_cast(kind: SyntaxKind) -> bool { kind == RENAME } | ||
1769 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1770 | if Self::can_cast(syntax.kind()) { | ||
1771 | Some(Self { syntax }) | ||
1772 | } else { | ||
1773 | None | ||
1774 | } | ||
1775 | } | ||
1776 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1777 | } | ||
1778 | impl AstNode for UseTree { | ||
1779 | fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE } | ||
1780 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1781 | if Self::can_cast(syntax.kind()) { | ||
1782 | Some(Self { syntax }) | ||
1783 | } else { | ||
1784 | None | ||
1785 | } | ||
1786 | } | ||
1787 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1788 | } | ||
1789 | impl AstNode for UseTreeList { | ||
1790 | fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE_LIST } | ||
1791 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1792 | if Self::can_cast(syntax.kind()) { | ||
1793 | Some(Self { syntax }) | ||
1794 | } else { | ||
1795 | None | ||
1796 | } | ||
1797 | } | ||
1798 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1799 | } | ||
1800 | impl AstNode for Abi { | ||
1801 | fn can_cast(kind: SyntaxKind) -> bool { kind == ABI } | ||
1802 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1803 | if Self::can_cast(syntax.kind()) { | ||
1804 | Some(Self { syntax }) | ||
1805 | } else { | ||
1806 | None | ||
1807 | } | ||
1808 | } | ||
1809 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1810 | } | ||
1811 | impl AstNode for GenericParamList { | ||
1812 | fn can_cast(kind: SyntaxKind) -> bool { kind == GENERIC_PARAM_LIST } | ||
1813 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1814 | if Self::can_cast(syntax.kind()) { | ||
1815 | Some(Self { syntax }) | ||
1816 | } else { | ||
1817 | None | ||
1818 | } | ||
1819 | } | ||
1820 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1821 | } | ||
1822 | impl AstNode for WhereClause { | ||
1823 | fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_CLAUSE } | ||
1824 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1825 | if Self::can_cast(syntax.kind()) { | ||
1826 | Some(Self { syntax }) | ||
1827 | } else { | ||
1828 | None | ||
1829 | } | ||
1830 | } | ||
1831 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1832 | } | ||
1833 | impl AstNode for SelfParam { | ||
1834 | fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM } | ||
1835 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1836 | if Self::can_cast(syntax.kind()) { | ||
1837 | Some(Self { syntax }) | ||
1838 | } else { | ||
1839 | None | ||
1840 | } | ||
1841 | } | ||
1842 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1843 | } | ||
1844 | impl AstNode for Param { | ||
1845 | fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM } | ||
1757 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1846 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1758 | if Self::can_cast(syntax.kind()) { | 1847 | if Self::can_cast(syntax.kind()) { |
1759 | Some(Self { syntax }) | 1848 | Some(Self { syntax }) |
@@ -1895,17 +1984,6 @@ impl AstNode for WherePred { | |||
1895 | } | 1984 | } |
1896 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1985 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1897 | } | 1986 | } |
1898 | impl AstNode for Literal { | ||
1899 | fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL } | ||
1900 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1901 | if Self::can_cast(syntax.kind()) { | ||
1902 | Some(Self { syntax }) | ||
1903 | } else { | ||
1904 | None | ||
1905 | } | ||
1906 | } | ||
1907 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1908 | } | ||
1909 | impl AstNode for TokenTree { | 1987 | impl AstNode for TokenTree { |
1910 | fn can_cast(kind: SyntaxKind) -> bool { kind == TOKEN_TREE } | 1988 | fn can_cast(kind: SyntaxKind) -> bool { kind == TOKEN_TREE } |
1911 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1989 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2280,17 +2358,6 @@ impl AstNode for ArgList { | |||
2280 | } | 2358 | } |
2281 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2359 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2282 | } | 2360 | } |
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 { | 2361 | impl AstNode for Condition { |
2295 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONDITION } | 2362 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONDITION } |
2296 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2363 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2423,17 +2490,6 @@ impl AstNode for ParenType { | |||
2423 | } | 2490 | } |
2424 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2491 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2425 | } | 2492 | } |
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 { | 2493 | impl AstNode for PointerType { |
2438 | fn can_cast(kind: SyntaxKind) -> bool { kind == POINTER_TYPE } | 2494 | fn can_cast(kind: SyntaxKind) -> bool { kind == POINTER_TYPE } |
2439 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2495 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2709,60 +2765,90 @@ impl AstNode for MacroStmts { | |||
2709 | } | 2765 | } |
2710 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2766 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2711 | } | 2767 | } |
2712 | impl AstNode for PathSegment { | 2768 | impl From<ArrayType> for Type { |
2713 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT } | 2769 | fn from(node: ArrayType) -> Type { Type::ArrayType(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 | } | 2770 | } |
2723 | impl AstNode for TypeArg { | 2771 | impl From<DynTraitType> for Type { |
2724 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG } | 2772 | fn from(node: DynTraitType) -> Type { Type::DynTraitType(node) } |
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 | } | 2773 | } |
2734 | impl AstNode for LifetimeArg { | 2774 | impl From<FnPointerType> for Type { |
2735 | fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_ARG } | 2775 | fn from(node: FnPointerType) -> Type { Type::FnPointerType(node) } |
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 | } | 2776 | } |
2745 | impl AstNode for AssocTypeArg { | 2777 | impl From<ForType> for Type { |
2746 | fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_TYPE_ARG } | 2778 | fn from(node: ForType) -> Type { Type::ForType(node) } |
2747 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2779 | } |
2748 | if Self::can_cast(syntax.kind()) { | 2780 | impl From<ImplTraitType> for Type { |
2749 | Some(Self { syntax }) | 2781 | fn from(node: ImplTraitType) -> Type { Type::ImplTraitType(node) } |
2750 | } else { | 2782 | } |
2751 | None | 2783 | impl From<InferType> for Type { |
2784 | fn from(node: InferType) -> Type { Type::InferType(node) } | ||
2785 | } | ||
2786 | impl From<NeverType> for Type { | ||
2787 | fn from(node: NeverType) -> Type { Type::NeverType(node) } | ||
2788 | } | ||
2789 | impl From<ParenType> for Type { | ||
2790 | fn from(node: ParenType) -> Type { Type::ParenType(node) } | ||
2791 | } | ||
2792 | impl From<PathType> for Type { | ||
2793 | fn from(node: PathType) -> Type { Type::PathType(node) } | ||
2794 | } | ||
2795 | impl From<PointerType> for Type { | ||
2796 | fn from(node: PointerType) -> Type { Type::PointerType(node) } | ||
2797 | } | ||
2798 | impl From<ReferenceType> for Type { | ||
2799 | fn from(node: ReferenceType) -> Type { Type::ReferenceType(node) } | ||
2800 | } | ||
2801 | impl From<SliceType> for Type { | ||
2802 | fn from(node: SliceType) -> Type { Type::SliceType(node) } | ||
2803 | } | ||
2804 | impl From<TupleType> for Type { | ||
2805 | fn from(node: TupleType) -> Type { Type::TupleType(node) } | ||
2806 | } | ||
2807 | impl AstNode for Type { | ||
2808 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2809 | match kind { | ||
2810 | ARRAY_TYPE | DYN_TRAIT_TYPE | FN_POINTER_TYPE | FOR_TYPE | IMPL_TRAIT_TYPE | ||
2811 | | INFER_TYPE | NEVER_TYPE | PAREN_TYPE | PATH_TYPE | POINTER_TYPE | REFERENCE_TYPE | ||
2812 | | SLICE_TYPE | TUPLE_TYPE => true, | ||
2813 | _ => false, | ||
2752 | } | 2814 | } |
2753 | } | 2815 | } |
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> { | 2816 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
2759 | if Self::can_cast(syntax.kind()) { | 2817 | let res = match syntax.kind() { |
2760 | Some(Self { syntax }) | 2818 | ARRAY_TYPE => Type::ArrayType(ArrayType { syntax }), |
2761 | } else { | 2819 | DYN_TRAIT_TYPE => Type::DynTraitType(DynTraitType { syntax }), |
2762 | None | 2820 | FN_POINTER_TYPE => Type::FnPointerType(FnPointerType { syntax }), |
2821 | FOR_TYPE => Type::ForType(ForType { syntax }), | ||
2822 | IMPL_TRAIT_TYPE => Type::ImplTraitType(ImplTraitType { syntax }), | ||
2823 | INFER_TYPE => Type::InferType(InferType { syntax }), | ||
2824 | NEVER_TYPE => Type::NeverType(NeverType { syntax }), | ||
2825 | PAREN_TYPE => Type::ParenType(ParenType { syntax }), | ||
2826 | PATH_TYPE => Type::PathType(PathType { syntax }), | ||
2827 | POINTER_TYPE => Type::PointerType(PointerType { syntax }), | ||
2828 | REFERENCE_TYPE => Type::ReferenceType(ReferenceType { syntax }), | ||
2829 | SLICE_TYPE => Type::SliceType(SliceType { syntax }), | ||
2830 | TUPLE_TYPE => Type::TupleType(TupleType { syntax }), | ||
2831 | _ => return None, | ||
2832 | }; | ||
2833 | Some(res) | ||
2834 | } | ||
2835 | fn syntax(&self) -> &SyntaxNode { | ||
2836 | match self { | ||
2837 | Type::ArrayType(it) => &it.syntax, | ||
2838 | Type::DynTraitType(it) => &it.syntax, | ||
2839 | Type::FnPointerType(it) => &it.syntax, | ||
2840 | Type::ForType(it) => &it.syntax, | ||
2841 | Type::ImplTraitType(it) => &it.syntax, | ||
2842 | Type::InferType(it) => &it.syntax, | ||
2843 | Type::NeverType(it) => &it.syntax, | ||
2844 | Type::ParenType(it) => &it.syntax, | ||
2845 | Type::PathType(it) => &it.syntax, | ||
2846 | Type::PointerType(it) => &it.syntax, | ||
2847 | Type::ReferenceType(it) => &it.syntax, | ||
2848 | Type::SliceType(it) => &it.syntax, | ||
2849 | Type::TupleType(it) => &it.syntax, | ||
2763 | } | 2850 | } |
2764 | } | 2851 | } |
2765 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2766 | } | 2852 | } |
2767 | impl From<Const> for Item { | 2853 | impl From<Const> for Item { |
2768 | fn from(node: Const) -> Item { Item::Const(node) } | 2854 | fn from(node: Const) -> Item { Item::Const(node) } |
@@ -2853,91 +2939,6 @@ impl AstNode for Item { | |||
2853 | } | 2939 | } |
2854 | } | 2940 | } |
2855 | } | 2941 | } |
2856 | impl From<ArrayType> for Type { | ||
2857 | fn from(node: ArrayType) -> Type { Type::ArrayType(node) } | ||
2858 | } | ||
2859 | impl From<DynTraitType> for Type { | ||
2860 | fn from(node: DynTraitType) -> Type { Type::DynTraitType(node) } | ||
2861 | } | ||
2862 | impl From<FnPointerType> for Type { | ||
2863 | fn from(node: FnPointerType) -> Type { Type::FnPointerType(node) } | ||
2864 | } | ||
2865 | impl From<ForType> for Type { | ||
2866 | fn from(node: ForType) -> Type { Type::ForType(node) } | ||
2867 | } | ||
2868 | impl From<ImplTraitType> for Type { | ||
2869 | fn from(node: ImplTraitType) -> Type { Type::ImplTraitType(node) } | ||
2870 | } | ||
2871 | impl From<InferType> for Type { | ||
2872 | fn from(node: InferType) -> Type { Type::InferType(node) } | ||
2873 | } | ||
2874 | impl From<NeverType> for Type { | ||
2875 | fn from(node: NeverType) -> Type { Type::NeverType(node) } | ||
2876 | } | ||
2877 | impl From<ParenType> for Type { | ||
2878 | fn from(node: ParenType) -> Type { Type::ParenType(node) } | ||
2879 | } | ||
2880 | impl From<PathType> for Type { | ||
2881 | fn from(node: PathType) -> Type { Type::PathType(node) } | ||
2882 | } | ||
2883 | impl From<PointerType> for Type { | ||
2884 | fn from(node: PointerType) -> Type { Type::PointerType(node) } | ||
2885 | } | ||
2886 | impl From<ReferenceType> for Type { | ||
2887 | fn from(node: ReferenceType) -> Type { Type::ReferenceType(node) } | ||
2888 | } | ||
2889 | impl From<SliceType> for Type { | ||
2890 | fn from(node: SliceType) -> Type { Type::SliceType(node) } | ||
2891 | } | ||
2892 | impl From<TupleType> for Type { | ||
2893 | fn from(node: TupleType) -> Type { Type::TupleType(node) } | ||
2894 | } | ||
2895 | impl AstNode for Type { | ||
2896 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2897 | match kind { | ||
2898 | ARRAY_TYPE | DYN_TRAIT_TYPE | FN_POINTER_TYPE | FOR_TYPE | IMPL_TRAIT_TYPE | ||
2899 | | INFER_TYPE | NEVER_TYPE | PAREN_TYPE | PATH_TYPE | POINTER_TYPE | REFERENCE_TYPE | ||
2900 | | SLICE_TYPE | TUPLE_TYPE => true, | ||
2901 | _ => false, | ||
2902 | } | ||
2903 | } | ||
2904 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2905 | let res = match syntax.kind() { | ||
2906 | ARRAY_TYPE => Type::ArrayType(ArrayType { syntax }), | ||
2907 | DYN_TRAIT_TYPE => Type::DynTraitType(DynTraitType { syntax }), | ||
2908 | FN_POINTER_TYPE => Type::FnPointerType(FnPointerType { syntax }), | ||
2909 | FOR_TYPE => Type::ForType(ForType { syntax }), | ||
2910 | IMPL_TRAIT_TYPE => Type::ImplTraitType(ImplTraitType { syntax }), | ||
2911 | INFER_TYPE => Type::InferType(InferType { syntax }), | ||
2912 | NEVER_TYPE => Type::NeverType(NeverType { syntax }), | ||
2913 | PAREN_TYPE => Type::ParenType(ParenType { syntax }), | ||
2914 | PATH_TYPE => Type::PathType(PathType { syntax }), | ||
2915 | POINTER_TYPE => Type::PointerType(PointerType { syntax }), | ||
2916 | REFERENCE_TYPE => Type::ReferenceType(ReferenceType { syntax }), | ||
2917 | SLICE_TYPE => Type::SliceType(SliceType { syntax }), | ||
2918 | TUPLE_TYPE => Type::TupleType(TupleType { syntax }), | ||
2919 | _ => return None, | ||
2920 | }; | ||
2921 | Some(res) | ||
2922 | } | ||
2923 | fn syntax(&self) -> &SyntaxNode { | ||
2924 | match self { | ||
2925 | Type::ArrayType(it) => &it.syntax, | ||
2926 | Type::DynTraitType(it) => &it.syntax, | ||
2927 | Type::FnPointerType(it) => &it.syntax, | ||
2928 | Type::ForType(it) => &it.syntax, | ||
2929 | Type::ImplTraitType(it) => &it.syntax, | ||
2930 | Type::InferType(it) => &it.syntax, | ||
2931 | Type::NeverType(it) => &it.syntax, | ||
2932 | Type::ParenType(it) => &it.syntax, | ||
2933 | Type::PathType(it) => &it.syntax, | ||
2934 | Type::PointerType(it) => &it.syntax, | ||
2935 | Type::ReferenceType(it) => &it.syntax, | ||
2936 | Type::SliceType(it) => &it.syntax, | ||
2937 | Type::TupleType(it) => &it.syntax, | ||
2938 | } | ||
2939 | } | ||
2940 | } | ||
2941 | impl From<OrPat> for Pat { | 2942 | impl From<OrPat> for Pat { |
2942 | fn from(node: OrPat) -> Pat { Pat::OrPat(node) } | 2943 | fn from(node: OrPat) -> Pat { Pat::OrPat(node) } |
2943 | } | 2944 | } |
@@ -3379,12 +3380,12 @@ impl From<Item> for Stmt { | |||
3379 | impl From<LetStmt> for Stmt { | 3380 | impl From<LetStmt> for Stmt { |
3380 | fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) } | 3381 | fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) } |
3381 | } | 3382 | } |
3382 | impl std::fmt::Display for Item { | 3383 | impl std::fmt::Display for Type { |
3383 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3384 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3384 | std::fmt::Display::fmt(self.syntax(), f) | 3385 | std::fmt::Display::fmt(self.syntax(), f) |
3385 | } | 3386 | } |
3386 | } | 3387 | } |
3387 | impl std::fmt::Display for Type { | 3388 | impl std::fmt::Display for Item { |
3388 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3389 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3389 | std::fmt::Display::fmt(self.syntax(), f) | 3390 | std::fmt::Display::fmt(self.syntax(), f) |
3390 | } | 3391 | } |
@@ -3429,6 +3430,76 @@ impl std::fmt::Display for Stmt { | |||
3429 | std::fmt::Display::fmt(self.syntax(), f) | 3430 | std::fmt::Display::fmt(self.syntax(), f) |
3430 | } | 3431 | } |
3431 | } | 3432 | } |
3433 | impl std::fmt::Display for Path { | ||
3434 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3435 | std::fmt::Display::fmt(self.syntax(), f) | ||
3436 | } | ||
3437 | } | ||
3438 | impl std::fmt::Display for PathSegment { | ||
3439 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3440 | std::fmt::Display::fmt(self.syntax(), f) | ||
3441 | } | ||
3442 | } | ||
3443 | impl std::fmt::Display for NameRef { | ||
3444 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3445 | std::fmt::Display::fmt(self.syntax(), f) | ||
3446 | } | ||
3447 | } | ||
3448 | impl std::fmt::Display for TypeArgList { | ||
3449 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3450 | std::fmt::Display::fmt(self.syntax(), f) | ||
3451 | } | ||
3452 | } | ||
3453 | impl std::fmt::Display for ParamList { | ||
3454 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3455 | std::fmt::Display::fmt(self.syntax(), f) | ||
3456 | } | ||
3457 | } | ||
3458 | impl std::fmt::Display for RetType { | ||
3459 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3460 | std::fmt::Display::fmt(self.syntax(), f) | ||
3461 | } | ||
3462 | } | ||
3463 | impl std::fmt::Display for PathType { | ||
3464 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3465 | std::fmt::Display::fmt(self.syntax(), f) | ||
3466 | } | ||
3467 | } | ||
3468 | impl std::fmt::Display for TypeArg { | ||
3469 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3470 | std::fmt::Display::fmt(self.syntax(), f) | ||
3471 | } | ||
3472 | } | ||
3473 | impl std::fmt::Display for LifetimeArg { | ||
3474 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3475 | std::fmt::Display::fmt(self.syntax(), f) | ||
3476 | } | ||
3477 | } | ||
3478 | impl std::fmt::Display for AssocTypeArg { | ||
3479 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3480 | std::fmt::Display::fmt(self.syntax(), f) | ||
3481 | } | ||
3482 | } | ||
3483 | impl std::fmt::Display for ConstArg { | ||
3484 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3485 | std::fmt::Display::fmt(self.syntax(), f) | ||
3486 | } | ||
3487 | } | ||
3488 | impl std::fmt::Display for TypeBoundList { | ||
3489 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3490 | std::fmt::Display::fmt(self.syntax(), f) | ||
3491 | } | ||
3492 | } | ||
3493 | impl std::fmt::Display for Literal { | ||
3494 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3495 | std::fmt::Display::fmt(self.syntax(), f) | ||
3496 | } | ||
3497 | } | ||
3498 | impl std::fmt::Display for BlockExpr { | ||
3499 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3500 | std::fmt::Display::fmt(self.syntax(), f) | ||
3501 | } | ||
3502 | } | ||
3432 | impl std::fmt::Display for SourceFile { | 3503 | impl std::fmt::Display for SourceFile { |
3433 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3504 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3434 | std::fmt::Display::fmt(self.syntax(), f) | 3505 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3524,11 +3595,6 @@ impl std::fmt::Display for ItemList { | |||
3524 | std::fmt::Display::fmt(self.syntax(), f) | 3595 | std::fmt::Display::fmt(self.syntax(), f) |
3525 | } | 3596 | } |
3526 | } | 3597 | } |
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 { | 3598 | impl std::fmt::Display for Rename { |
3533 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3599 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3534 | std::fmt::Display::fmt(self.syntax(), f) | 3600 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3539,11 +3605,6 @@ impl std::fmt::Display for UseTree { | |||
3539 | std::fmt::Display::fmt(self.syntax(), f) | 3605 | std::fmt::Display::fmt(self.syntax(), f) |
3540 | } | 3606 | } |
3541 | } | 3607 | } |
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 { | 3608 | impl std::fmt::Display for UseTreeList { |
3548 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3609 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3549 | std::fmt::Display::fmt(self.syntax(), f) | 3610 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3559,26 +3620,11 @@ impl std::fmt::Display for GenericParamList { | |||
3559 | std::fmt::Display::fmt(self.syntax(), f) | 3620 | std::fmt::Display::fmt(self.syntax(), f) |
3560 | } | 3621 | } |
3561 | } | 3622 | } |
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 { | 3623 | impl std::fmt::Display for WhereClause { |
3573 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3624 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3574 | std::fmt::Display::fmt(self.syntax(), f) | 3625 | std::fmt::Display::fmt(self.syntax(), f) |
3575 | } | 3626 | } |
3576 | } | 3627 | } |
3577 | impl std::fmt::Display for BlockExpr { | ||
3578 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3579 | std::fmt::Display::fmt(self.syntax(), f) | ||
3580 | } | ||
3581 | } | ||
3582 | impl std::fmt::Display for SelfParam { | 3628 | impl std::fmt::Display for SelfParam { |
3583 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3629 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3584 | std::fmt::Display::fmt(self.syntax(), f) | 3630 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3589,11 +3635,6 @@ impl std::fmt::Display for Param { | |||
3589 | std::fmt::Display::fmt(self.syntax(), f) | 3635 | std::fmt::Display::fmt(self.syntax(), f) |
3590 | } | 3636 | } |
3591 | } | 3637 | } |
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 { | 3638 | impl std::fmt::Display for RecordFieldList { |
3598 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3639 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3599 | std::fmt::Display::fmt(self.syntax(), f) | 3640 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3654,11 +3695,6 @@ impl std::fmt::Display for WherePred { | |||
3654 | std::fmt::Display::fmt(self.syntax(), f) | 3695 | std::fmt::Display::fmt(self.syntax(), f) |
3655 | } | 3696 | } |
3656 | } | 3697 | } |
3657 | impl std::fmt::Display for Literal { | ||
3658 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3659 | std::fmt::Display::fmt(self.syntax(), f) | ||
3660 | } | ||
3661 | } | ||
3662 | impl std::fmt::Display for TokenTree { | 3698 | impl std::fmt::Display for TokenTree { |
3663 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3699 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3664 | std::fmt::Display::fmt(self.syntax(), f) | 3700 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3829,11 +3865,6 @@ impl std::fmt::Display for ArgList { | |||
3829 | std::fmt::Display::fmt(self.syntax(), f) | 3865 | std::fmt::Display::fmt(self.syntax(), f) |
3830 | } | 3866 | } |
3831 | } | 3867 | } |
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 { | 3868 | impl std::fmt::Display for Condition { |
3838 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3869 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3839 | std::fmt::Display::fmt(self.syntax(), f) | 3870 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3894,11 +3925,6 @@ impl std::fmt::Display for ParenType { | |||
3894 | std::fmt::Display::fmt(self.syntax(), f) | 3925 | std::fmt::Display::fmt(self.syntax(), f) |
3895 | } | 3926 | } |
3896 | } | 3927 | } |
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 { | 3928 | impl std::fmt::Display for PointerType { |
3903 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3929 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3904 | std::fmt::Display::fmt(self.syntax(), f) | 3930 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -4024,28 +4050,3 @@ impl std::fmt::Display for MacroStmts { | |||
4024 | std::fmt::Display::fmt(self.syntax(), f) | 4050 | std::fmt::Display::fmt(self.syntax(), f) |
4025 | } | 4051 | } |
4026 | } | 4052 | } |
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 | } | ||