aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/ast
diff options
context:
space:
mode:
Diffstat (limited to 'crates/libsyntax2/src/ast')
-rw-r--r--crates/libsyntax2/src/ast/generated.rs308
1 files changed, 306 insertions, 2 deletions
diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs
index 7d746a85b..6926c0535 100644
--- a/crates/libsyntax2/src/ast/generated.rs
+++ b/crates/libsyntax2/src/ast/generated.rs
@@ -80,6 +80,25 @@ impl<'a> AstNode<'a> for BinExpr<'a> {
80 80
81impl<'a> BinExpr<'a> {} 81impl<'a> BinExpr<'a> {}
82 82
83// BindPat
84#[derive(Debug, Clone, Copy)]
85pub struct BindPat<'a> {
86 syntax: SyntaxNodeRef<'a>,
87}
88
89impl<'a> AstNode<'a> for BindPat<'a> {
90 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
91 match syntax.kind() {
92 BIND_PAT => Some(BindPat { syntax }),
93 _ => None,
94 }
95 }
96 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
97}
98
99impl<'a> ast::NameOwner<'a> for BindPat<'a> {}
100impl<'a> BindPat<'a> {}
101
83// Block 102// Block
84#[derive(Debug, Clone, Copy)] 103#[derive(Debug, Clone, Copy)]
85pub struct Block<'a> { 104pub struct Block<'a> {
@@ -96,7 +115,11 @@ impl<'a> AstNode<'a> for Block<'a> {
96 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 115 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
97} 116}
98 117
99impl<'a> Block<'a> {} 118impl<'a> Block<'a> {
119 pub fn let_stmts(self) -> impl Iterator<Item = LetStmt<'a>> + 'a {
120 super::children(self)
121 }
122}
100 123
101// BlockExpr 124// BlockExpr
102#[derive(Debug, Clone, Copy)] 125#[derive(Debug, Clone, Copy)]
@@ -378,6 +401,24 @@ impl<'a> AstNode<'a> for FieldExpr<'a> {
378 401
379impl<'a> FieldExpr<'a> {} 402impl<'a> FieldExpr<'a> {}
380 403
404// FieldPatList
405#[derive(Debug, Clone, Copy)]
406pub struct FieldPatList<'a> {
407 syntax: SyntaxNodeRef<'a>,
408}
409
410impl<'a> AstNode<'a> for FieldPatList<'a> {
411 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
412 match syntax.kind() {
413 FIELD_PAT_LIST => Some(FieldPatList { syntax }),
414 _ => None,
415 }
416 }
417 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
418}
419
420impl<'a> FieldPatList<'a> {}
421
381// FnDef 422// FnDef
382#[derive(Debug, Clone, Copy)] 423#[derive(Debug, Clone, Copy)]
383pub struct FnDef<'a> { 424pub struct FnDef<'a> {
@@ -397,7 +438,11 @@ impl<'a> AstNode<'a> for FnDef<'a> {
397impl<'a> ast::NameOwner<'a> for FnDef<'a> {} 438impl<'a> ast::NameOwner<'a> for FnDef<'a> {}
398impl<'a> ast::TypeParamsOwner<'a> for FnDef<'a> {} 439impl<'a> ast::TypeParamsOwner<'a> for FnDef<'a> {}
399impl<'a> ast::AttrsOwner<'a> for FnDef<'a> {} 440impl<'a> ast::AttrsOwner<'a> for FnDef<'a> {}
400impl<'a> FnDef<'a> {} 441impl<'a> FnDef<'a> {
442 pub fn param_list(self) -> Option<ParamList<'a>> {
443 super::child_opt(self)
444 }
445}
401 446
402// FnPointerType 447// FnPointerType
403#[derive(Debug, Clone, Copy)] 448#[derive(Debug, Clone, Copy)]
@@ -561,6 +606,28 @@ impl<'a> AstNode<'a> for LambdaExpr<'a> {
561 606
562impl<'a> LambdaExpr<'a> {} 607impl<'a> LambdaExpr<'a> {}
563 608
609// LetStmt
610#[derive(Debug, Clone, Copy)]
611pub struct LetStmt<'a> {
612 syntax: SyntaxNodeRef<'a>,
613}
614
615impl<'a> AstNode<'a> for LetStmt<'a> {
616 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
617 match syntax.kind() {
618 LET_STMT => Some(LetStmt { syntax }),
619 _ => None,
620 }
621 }
622 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
623}
624
625impl<'a> LetStmt<'a> {
626 pub fn pat(self) -> Option<Pat<'a>> {
627 super::child_opt(self)
628 }
629}
630
564// LoopExpr 631// LoopExpr
565#[derive(Debug, Clone, Copy)] 632#[derive(Debug, Clone, Copy)]
566pub struct LoopExpr<'a> { 633pub struct LoopExpr<'a> {
@@ -831,6 +898,50 @@ impl<'a> ast::TypeParamsOwner<'a> for NominalDef<'a> {}
831impl<'a> ast::AttrsOwner<'a> for NominalDef<'a> {} 898impl<'a> ast::AttrsOwner<'a> for NominalDef<'a> {}
832impl<'a> NominalDef<'a> {} 899impl<'a> NominalDef<'a> {}
833 900
901// Param
902#[derive(Debug, Clone, Copy)]
903pub struct Param<'a> {
904 syntax: SyntaxNodeRef<'a>,
905}
906
907impl<'a> AstNode<'a> for Param<'a> {
908 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
909 match syntax.kind() {
910 PARAM => Some(Param { syntax }),
911 _ => None,
912 }
913 }
914 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
915}
916
917impl<'a> Param<'a> {
918 pub fn pat(self) -> Option<Pat<'a>> {
919 super::child_opt(self)
920 }
921}
922
923// ParamList
924#[derive(Debug, Clone, Copy)]
925pub struct ParamList<'a> {
926 syntax: SyntaxNodeRef<'a>,
927}
928
929impl<'a> AstNode<'a> for ParamList<'a> {
930 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
931 match syntax.kind() {
932 PARAM_LIST => Some(ParamList { syntax }),
933 _ => None,
934 }
935 }
936 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
937}
938
939impl<'a> ParamList<'a> {
940 pub fn params(self) -> impl Iterator<Item = Param<'a>> + 'a {
941 super::children(self)
942 }
943}
944
834// ParenExpr 945// ParenExpr
835#[derive(Debug, Clone, Copy)] 946#[derive(Debug, Clone, Copy)]
836pub struct ParenExpr<'a> { 947pub struct ParenExpr<'a> {
@@ -867,6 +978,55 @@ impl<'a> AstNode<'a> for ParenType<'a> {
867 978
868impl<'a> ParenType<'a> {} 979impl<'a> ParenType<'a> {}
869 980
981// Pat
982#[derive(Debug, Clone, Copy)]
983pub enum Pat<'a> {
984 RefPat(RefPat<'a>),
985 BindPat(BindPat<'a>),
986 PlaceholderPat(PlaceholderPat<'a>),
987 PathPat(PathPat<'a>),
988 StructPat(StructPat<'a>),
989 FieldPatList(FieldPatList<'a>),
990 TupleStructPat(TupleStructPat<'a>),
991 TuplePat(TuplePat<'a>),
992 SlicePat(SlicePat<'a>),
993 RangePat(RangePat<'a>),
994}
995
996impl<'a> AstNode<'a> for Pat<'a> {
997 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
998 match syntax.kind() {
999 REF_PAT => Some(Pat::RefPat(RefPat { syntax })),
1000 BIND_PAT => Some(Pat::BindPat(BindPat { syntax })),
1001 PLACEHOLDER_PAT => Some(Pat::PlaceholderPat(PlaceholderPat { syntax })),
1002 PATH_PAT => Some(Pat::PathPat(PathPat { syntax })),
1003 STRUCT_PAT => Some(Pat::StructPat(StructPat { syntax })),
1004 FIELD_PAT_LIST => Some(Pat::FieldPatList(FieldPatList { syntax })),
1005 TUPLE_STRUCT_PAT => Some(Pat::TupleStructPat(TupleStructPat { syntax })),
1006 TUPLE_PAT => Some(Pat::TuplePat(TuplePat { syntax })),
1007 SLICE_PAT => Some(Pat::SlicePat(SlicePat { syntax })),
1008 RANGE_PAT => Some(Pat::RangePat(RangePat { syntax })),
1009 _ => None,
1010 }
1011 }
1012 fn syntax(self) -> SyntaxNodeRef<'a> {
1013 match self {
1014 Pat::RefPat(inner) => inner.syntax(),
1015 Pat::BindPat(inner) => inner.syntax(),
1016 Pat::PlaceholderPat(inner) => inner.syntax(),
1017 Pat::PathPat(inner) => inner.syntax(),
1018 Pat::StructPat(inner) => inner.syntax(),
1019 Pat::FieldPatList(inner) => inner.syntax(),
1020 Pat::TupleStructPat(inner) => inner.syntax(),
1021 Pat::TuplePat(inner) => inner.syntax(),
1022 Pat::SlicePat(inner) => inner.syntax(),
1023 Pat::RangePat(inner) => inner.syntax(),
1024 }
1025 }
1026}
1027
1028impl<'a> Pat<'a> {}
1029
870// PathExpr 1030// PathExpr
871#[derive(Debug, Clone, Copy)] 1031#[derive(Debug, Clone, Copy)]
872pub struct PathExpr<'a> { 1032pub struct PathExpr<'a> {
@@ -885,6 +1045,24 @@ impl<'a> AstNode<'a> for PathExpr<'a> {
885 1045
886impl<'a> PathExpr<'a> {} 1046impl<'a> PathExpr<'a> {}
887 1047
1048// PathPat
1049#[derive(Debug, Clone, Copy)]
1050pub struct PathPat<'a> {
1051 syntax: SyntaxNodeRef<'a>,
1052}
1053
1054impl<'a> AstNode<'a> for PathPat<'a> {
1055 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
1056 match syntax.kind() {
1057 PATH_PAT => Some(PathPat { syntax }),
1058 _ => None,
1059 }
1060 }
1061 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1062}
1063
1064impl<'a> PathPat<'a> {}
1065
888// PathType 1066// PathType
889#[derive(Debug, Clone, Copy)] 1067#[derive(Debug, Clone, Copy)]
890pub struct PathType<'a> { 1068pub struct PathType<'a> {
@@ -903,6 +1081,24 @@ impl<'a> AstNode<'a> for PathType<'a> {
903 1081
904impl<'a> PathType<'a> {} 1082impl<'a> PathType<'a> {}
905 1083
1084// PlaceholderPat
1085#[derive(Debug, Clone, Copy)]
1086pub struct PlaceholderPat<'a> {
1087 syntax: SyntaxNodeRef<'a>,
1088}
1089
1090impl<'a> AstNode<'a> for PlaceholderPat<'a> {
1091 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
1092 match syntax.kind() {
1093 PLACEHOLDER_PAT => Some(PlaceholderPat { syntax }),
1094 _ => None,
1095 }
1096 }
1097 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1098}
1099
1100impl<'a> PlaceholderPat<'a> {}
1101
906// PlaceholderType 1102// PlaceholderType
907#[derive(Debug, Clone, Copy)] 1103#[derive(Debug, Clone, Copy)]
908pub struct PlaceholderType<'a> { 1104pub struct PlaceholderType<'a> {
@@ -975,6 +1171,24 @@ impl<'a> AstNode<'a> for RangeExpr<'a> {
975 1171
976impl<'a> RangeExpr<'a> {} 1172impl<'a> RangeExpr<'a> {}
977 1173
1174// RangePat
1175#[derive(Debug, Clone, Copy)]
1176pub struct RangePat<'a> {
1177 syntax: SyntaxNodeRef<'a>,
1178}
1179
1180impl<'a> AstNode<'a> for RangePat<'a> {
1181 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
1182 match syntax.kind() {
1183 RANGE_PAT => Some(RangePat { syntax }),
1184 _ => None,
1185 }
1186 }
1187 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1188}
1189
1190impl<'a> RangePat<'a> {}
1191
978// RefExpr 1192// RefExpr
979#[derive(Debug, Clone, Copy)] 1193#[derive(Debug, Clone, Copy)]
980pub struct RefExpr<'a> { 1194pub struct RefExpr<'a> {
@@ -993,6 +1207,24 @@ impl<'a> AstNode<'a> for RefExpr<'a> {
993 1207
994impl<'a> RefExpr<'a> {} 1208impl<'a> RefExpr<'a> {}
995 1209
1210// RefPat
1211#[derive(Debug, Clone, Copy)]
1212pub struct RefPat<'a> {
1213 syntax: SyntaxNodeRef<'a>,
1214}
1215
1216impl<'a> AstNode<'a> for RefPat<'a> {
1217 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
1218 match syntax.kind() {
1219 REF_PAT => Some(RefPat { syntax }),
1220 _ => None,
1221 }
1222 }
1223 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1224}
1225
1226impl<'a> RefPat<'a> {}
1227
996// ReferenceType 1228// ReferenceType
997#[derive(Debug, Clone, Copy)] 1229#[derive(Debug, Clone, Copy)]
998pub struct ReferenceType<'a> { 1230pub struct ReferenceType<'a> {
@@ -1055,6 +1287,24 @@ impl<'a> Root<'a> {
1055 } 1287 }
1056} 1288}
1057 1289
1290// SlicePat
1291#[derive(Debug, Clone, Copy)]
1292pub struct SlicePat<'a> {
1293 syntax: SyntaxNodeRef<'a>,
1294}
1295
1296impl<'a> AstNode<'a> for SlicePat<'a> {
1297 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
1298 match syntax.kind() {
1299 SLICE_PAT => Some(SlicePat { syntax }),
1300 _ => None,
1301 }
1302 }
1303 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1304}
1305
1306impl<'a> SlicePat<'a> {}
1307
1058// SliceType 1308// SliceType
1059#[derive(Debug, Clone, Copy)] 1309#[derive(Debug, Clone, Copy)]
1060pub struct SliceType<'a> { 1310pub struct SliceType<'a> {
@@ -1137,6 +1387,24 @@ impl<'a> AstNode<'a> for StructLit<'a> {
1137 1387
1138impl<'a> StructLit<'a> {} 1388impl<'a> StructLit<'a> {}
1139 1389
1390// StructPat
1391#[derive(Debug, Clone, Copy)]
1392pub struct StructPat<'a> {
1393 syntax: SyntaxNodeRef<'a>,
1394}
1395
1396impl<'a> AstNode<'a> for StructPat<'a> {
1397 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
1398 match syntax.kind() {
1399 STRUCT_PAT => Some(StructPat { syntax }),
1400 _ => None,
1401 }
1402 }
1403 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1404}
1405
1406impl<'a> StructPat<'a> {}
1407
1140// TokenTree 1408// TokenTree
1141#[derive(Debug, Clone, Copy)] 1409#[derive(Debug, Clone, Copy)]
1142pub struct TokenTree<'a> { 1410pub struct TokenTree<'a> {
@@ -1211,6 +1479,42 @@ impl<'a> AstNode<'a> for TupleExpr<'a> {
1211 1479
1212impl<'a> TupleExpr<'a> {} 1480impl<'a> TupleExpr<'a> {}
1213 1481
1482// TuplePat
1483#[derive(Debug, Clone, Copy)]
1484pub struct TuplePat<'a> {
1485 syntax: SyntaxNodeRef<'a>,
1486}
1487
1488impl<'a> AstNode<'a> for TuplePat<'a> {
1489 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
1490 match syntax.kind() {
1491 TUPLE_PAT => Some(TuplePat { syntax }),
1492 _ => None,
1493 }
1494 }
1495 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1496}
1497
1498impl<'a> TuplePat<'a> {}
1499
1500// TupleStructPat
1501#[derive(Debug, Clone, Copy)]
1502pub struct TupleStructPat<'a> {
1503 syntax: SyntaxNodeRef<'a>,
1504}
1505
1506impl<'a> AstNode<'a> for TupleStructPat<'a> {
1507 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
1508 match syntax.kind() {
1509 TUPLE_STRUCT_PAT => Some(TupleStructPat { syntax }),
1510 _ => None,
1511 }
1512 }
1513 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
1514}
1515
1516impl<'a> TupleStructPat<'a> {}
1517
1214// TupleType 1518// TupleType
1215#[derive(Debug, Clone, Copy)] 1519#[derive(Debug, Clone, Copy)]
1216pub struct TupleType<'a> { 1520pub struct TupleType<'a> {