aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r--crates/ra_syntax/src/ast/generated.rs398
-rw-r--r--crates/ra_syntax/src/ast/generated.rs.tera9
2 files changed, 407 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index 47107a58b..aa88b1e28 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -834,6 +834,142 @@ pub enum ExprKind<'a> {
834 BinExpr(&'a BinExpr), 834 BinExpr(&'a BinExpr),
835 Literal(&'a Literal), 835 Literal(&'a Literal),
836} 836}
837impl<'a> From<&'a TupleExpr> for &'a Expr {
838 fn from(n: &'a TupleExpr) -> &'a Expr {
839 Expr::cast(&n.syntax).unwrap()
840 }
841}
842impl<'a> From<&'a ArrayExpr> for &'a Expr {
843 fn from(n: &'a ArrayExpr) -> &'a Expr {
844 Expr::cast(&n.syntax).unwrap()
845 }
846}
847impl<'a> From<&'a ParenExpr> for &'a Expr {
848 fn from(n: &'a ParenExpr) -> &'a Expr {
849 Expr::cast(&n.syntax).unwrap()
850 }
851}
852impl<'a> From<&'a PathExpr> for &'a Expr {
853 fn from(n: &'a PathExpr) -> &'a Expr {
854 Expr::cast(&n.syntax).unwrap()
855 }
856}
857impl<'a> From<&'a LambdaExpr> for &'a Expr {
858 fn from(n: &'a LambdaExpr) -> &'a Expr {
859 Expr::cast(&n.syntax).unwrap()
860 }
861}
862impl<'a> From<&'a IfExpr> for &'a Expr {
863 fn from(n: &'a IfExpr) -> &'a Expr {
864 Expr::cast(&n.syntax).unwrap()
865 }
866}
867impl<'a> From<&'a LoopExpr> for &'a Expr {
868 fn from(n: &'a LoopExpr) -> &'a Expr {
869 Expr::cast(&n.syntax).unwrap()
870 }
871}
872impl<'a> From<&'a ForExpr> for &'a Expr {
873 fn from(n: &'a ForExpr) -> &'a Expr {
874 Expr::cast(&n.syntax).unwrap()
875 }
876}
877impl<'a> From<&'a WhileExpr> for &'a Expr {
878 fn from(n: &'a WhileExpr) -> &'a Expr {
879 Expr::cast(&n.syntax).unwrap()
880 }
881}
882impl<'a> From<&'a ContinueExpr> for &'a Expr {
883 fn from(n: &'a ContinueExpr) -> &'a Expr {
884 Expr::cast(&n.syntax).unwrap()
885 }
886}
887impl<'a> From<&'a BreakExpr> for &'a Expr {
888 fn from(n: &'a BreakExpr) -> &'a Expr {
889 Expr::cast(&n.syntax).unwrap()
890 }
891}
892impl<'a> From<&'a Label> for &'a Expr {
893 fn from(n: &'a Label) -> &'a Expr {
894 Expr::cast(&n.syntax).unwrap()
895 }
896}
897impl<'a> From<&'a BlockExpr> for &'a Expr {
898 fn from(n: &'a BlockExpr) -> &'a Expr {
899 Expr::cast(&n.syntax).unwrap()
900 }
901}
902impl<'a> From<&'a ReturnExpr> for &'a Expr {
903 fn from(n: &'a ReturnExpr) -> &'a Expr {
904 Expr::cast(&n.syntax).unwrap()
905 }
906}
907impl<'a> From<&'a MatchExpr> for &'a Expr {
908 fn from(n: &'a MatchExpr) -> &'a Expr {
909 Expr::cast(&n.syntax).unwrap()
910 }
911}
912impl<'a> From<&'a StructLit> for &'a Expr {
913 fn from(n: &'a StructLit) -> &'a Expr {
914 Expr::cast(&n.syntax).unwrap()
915 }
916}
917impl<'a> From<&'a CallExpr> for &'a Expr {
918 fn from(n: &'a CallExpr) -> &'a Expr {
919 Expr::cast(&n.syntax).unwrap()
920 }
921}
922impl<'a> From<&'a IndexExpr> for &'a Expr {
923 fn from(n: &'a IndexExpr) -> &'a Expr {
924 Expr::cast(&n.syntax).unwrap()
925 }
926}
927impl<'a> From<&'a MethodCallExpr> for &'a Expr {
928 fn from(n: &'a MethodCallExpr) -> &'a Expr {
929 Expr::cast(&n.syntax).unwrap()
930 }
931}
932impl<'a> From<&'a FieldExpr> for &'a Expr {
933 fn from(n: &'a FieldExpr) -> &'a Expr {
934 Expr::cast(&n.syntax).unwrap()
935 }
936}
937impl<'a> From<&'a TryExpr> for &'a Expr {
938 fn from(n: &'a TryExpr) -> &'a Expr {
939 Expr::cast(&n.syntax).unwrap()
940 }
941}
942impl<'a> From<&'a CastExpr> for &'a Expr {
943 fn from(n: &'a CastExpr) -> &'a Expr {
944 Expr::cast(&n.syntax).unwrap()
945 }
946}
947impl<'a> From<&'a RefExpr> for &'a Expr {
948 fn from(n: &'a RefExpr) -> &'a Expr {
949 Expr::cast(&n.syntax).unwrap()
950 }
951}
952impl<'a> From<&'a PrefixExpr> for &'a Expr {
953 fn from(n: &'a PrefixExpr) -> &'a Expr {
954 Expr::cast(&n.syntax).unwrap()
955 }
956}
957impl<'a> From<&'a RangeExpr> for &'a Expr {
958 fn from(n: &'a RangeExpr) -> &'a Expr {
959 Expr::cast(&n.syntax).unwrap()
960 }
961}
962impl<'a> From<&'a BinExpr> for &'a Expr {
963 fn from(n: &'a BinExpr) -> &'a Expr {
964 Expr::cast(&n.syntax).unwrap()
965 }
966}
967impl<'a> From<&'a Literal> for &'a Expr {
968 fn from(n: &'a Literal) -> &'a Expr {
969 Expr::cast(&n.syntax).unwrap()
970 }
971}
972
837 973
838impl AstNode for Expr { 974impl AstNode for Expr {
839 fn cast(syntax: &SyntaxNode) -> Option<&Self> { 975 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
@@ -1375,6 +1511,22 @@ pub enum ImplItemKind<'a> {
1375 TypeDef(&'a TypeDef), 1511 TypeDef(&'a TypeDef),
1376 ConstDef(&'a ConstDef), 1512 ConstDef(&'a ConstDef),
1377} 1513}
1514impl<'a> From<&'a FnDef> for &'a ImplItem {
1515 fn from(n: &'a FnDef) -> &'a ImplItem {
1516 ImplItem::cast(&n.syntax).unwrap()
1517 }
1518}
1519impl<'a> From<&'a TypeDef> for &'a ImplItem {
1520 fn from(n: &'a TypeDef) -> &'a ImplItem {
1521 ImplItem::cast(&n.syntax).unwrap()
1522 }
1523}
1524impl<'a> From<&'a ConstDef> for &'a ImplItem {
1525 fn from(n: &'a ConstDef) -> &'a ImplItem {
1526 ImplItem::cast(&n.syntax).unwrap()
1527 }
1528}
1529
1378 1530
1379impl AstNode for ImplItem { 1531impl AstNode for ImplItem {
1380 fn cast(syntax: &SyntaxNode) -> Option<&Self> { 1532 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
@@ -1778,6 +1930,57 @@ pub enum LiteralExprKind<'a> {
1778 TrueKw(&'a TrueKw), 1930 TrueKw(&'a TrueKw),
1779 FalseKw(&'a FalseKw), 1931 FalseKw(&'a FalseKw),
1780} 1932}
1933impl<'a> From<&'a String> for &'a LiteralExpr {
1934 fn from(n: &'a String) -> &'a LiteralExpr {
1935 LiteralExpr::cast(&n.syntax).unwrap()
1936 }
1937}
1938impl<'a> From<&'a ByteString> for &'a LiteralExpr {
1939 fn from(n: &'a ByteString) -> &'a LiteralExpr {
1940 LiteralExpr::cast(&n.syntax).unwrap()
1941 }
1942}
1943impl<'a> From<&'a RawString> for &'a LiteralExpr {
1944 fn from(n: &'a RawString) -> &'a LiteralExpr {
1945 LiteralExpr::cast(&n.syntax).unwrap()
1946 }
1947}
1948impl<'a> From<&'a RawByteString> for &'a LiteralExpr {
1949 fn from(n: &'a RawByteString) -> &'a LiteralExpr {
1950 LiteralExpr::cast(&n.syntax).unwrap()
1951 }
1952}
1953impl<'a> From<&'a Char> for &'a LiteralExpr {
1954 fn from(n: &'a Char) -> &'a LiteralExpr {
1955 LiteralExpr::cast(&n.syntax).unwrap()
1956 }
1957}
1958impl<'a> From<&'a Byte> for &'a LiteralExpr {
1959 fn from(n: &'a Byte) -> &'a LiteralExpr {
1960 LiteralExpr::cast(&n.syntax).unwrap()
1961 }
1962}
1963impl<'a> From<&'a IntNumber> for &'a LiteralExpr {
1964 fn from(n: &'a IntNumber) -> &'a LiteralExpr {
1965 LiteralExpr::cast(&n.syntax).unwrap()
1966 }
1967}
1968impl<'a> From<&'a FloatNumber> for &'a LiteralExpr {
1969 fn from(n: &'a FloatNumber) -> &'a LiteralExpr {
1970 LiteralExpr::cast(&n.syntax).unwrap()
1971 }
1972}
1973impl<'a> From<&'a TrueKw> for &'a LiteralExpr {
1974 fn from(n: &'a TrueKw) -> &'a LiteralExpr {
1975 LiteralExpr::cast(&n.syntax).unwrap()
1976 }
1977}
1978impl<'a> From<&'a FalseKw> for &'a LiteralExpr {
1979 fn from(n: &'a FalseKw) -> &'a LiteralExpr {
1980 LiteralExpr::cast(&n.syntax).unwrap()
1981 }
1982}
1983
1781 1984
1782impl AstNode for LiteralExpr { 1985impl AstNode for LiteralExpr {
1783 fn cast(syntax: &SyntaxNode) -> Option<&Self> { 1986 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
@@ -2164,6 +2367,62 @@ pub enum ModuleItemKind<'a> {
2164 StaticDef(&'a StaticDef), 2367 StaticDef(&'a StaticDef),
2165 Module(&'a Module), 2368 Module(&'a Module),
2166} 2369}
2370impl<'a> From<&'a StructDef> for &'a ModuleItem {
2371 fn from(n: &'a StructDef) -> &'a ModuleItem {
2372 ModuleItem::cast(&n.syntax).unwrap()
2373 }
2374}
2375impl<'a> From<&'a EnumDef> for &'a ModuleItem {
2376 fn from(n: &'a EnumDef) -> &'a ModuleItem {
2377 ModuleItem::cast(&n.syntax).unwrap()
2378 }
2379}
2380impl<'a> From<&'a FnDef> for &'a ModuleItem {
2381 fn from(n: &'a FnDef) -> &'a ModuleItem {
2382 ModuleItem::cast(&n.syntax).unwrap()
2383 }
2384}
2385impl<'a> From<&'a TraitDef> for &'a ModuleItem {
2386 fn from(n: &'a TraitDef) -> &'a ModuleItem {
2387 ModuleItem::cast(&n.syntax).unwrap()
2388 }
2389}
2390impl<'a> From<&'a TypeDef> for &'a ModuleItem {
2391 fn from(n: &'a TypeDef) -> &'a ModuleItem {
2392 ModuleItem::cast(&n.syntax).unwrap()
2393 }
2394}
2395impl<'a> From<&'a ImplBlock> for &'a ModuleItem {
2396 fn from(n: &'a ImplBlock) -> &'a ModuleItem {
2397 ModuleItem::cast(&n.syntax).unwrap()
2398 }
2399}
2400impl<'a> From<&'a UseItem> for &'a ModuleItem {
2401 fn from(n: &'a UseItem) -> &'a ModuleItem {
2402 ModuleItem::cast(&n.syntax).unwrap()
2403 }
2404}
2405impl<'a> From<&'a ExternCrateItem> for &'a ModuleItem {
2406 fn from(n: &'a ExternCrateItem) -> &'a ModuleItem {
2407 ModuleItem::cast(&n.syntax).unwrap()
2408 }
2409}
2410impl<'a> From<&'a ConstDef> for &'a ModuleItem {
2411 fn from(n: &'a ConstDef) -> &'a ModuleItem {
2412 ModuleItem::cast(&n.syntax).unwrap()
2413 }
2414}
2415impl<'a> From<&'a StaticDef> for &'a ModuleItem {
2416 fn from(n: &'a StaticDef) -> &'a ModuleItem {
2417 ModuleItem::cast(&n.syntax).unwrap()
2418 }
2419}
2420impl<'a> From<&'a Module> for &'a ModuleItem {
2421 fn from(n: &'a Module) -> &'a ModuleItem {
2422 ModuleItem::cast(&n.syntax).unwrap()
2423 }
2424}
2425
2167 2426
2168impl AstNode for ModuleItem { 2427impl AstNode for ModuleItem {
2169 fn cast(syntax: &SyntaxNode) -> Option<&Self> { 2428 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
@@ -2446,6 +2705,17 @@ pub enum NominalDefKind<'a> {
2446 StructDef(&'a StructDef), 2705 StructDef(&'a StructDef),
2447 EnumDef(&'a EnumDef), 2706 EnumDef(&'a EnumDef),
2448} 2707}
2708impl<'a> From<&'a StructDef> for &'a NominalDef {
2709 fn from(n: &'a StructDef) -> &'a NominalDef {
2710 NominalDef::cast(&n.syntax).unwrap()
2711 }
2712}
2713impl<'a> From<&'a EnumDef> for &'a NominalDef {
2714 fn from(n: &'a EnumDef) -> &'a NominalDef {
2715 NominalDef::cast(&n.syntax).unwrap()
2716 }
2717}
2718
2449 2719
2450impl AstNode for NominalDef { 2720impl AstNode for NominalDef {
2451 fn cast(syntax: &SyntaxNode) -> Option<&Self> { 2721 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
@@ -2637,6 +2907,57 @@ pub enum PatKind<'a> {
2637 RangePat(&'a RangePat), 2907 RangePat(&'a RangePat),
2638 LiteralPat(&'a LiteralPat), 2908 LiteralPat(&'a LiteralPat),
2639} 2909}
2910impl<'a> From<&'a RefPat> for &'a Pat {
2911 fn from(n: &'a RefPat) -> &'a Pat {
2912 Pat::cast(&n.syntax).unwrap()
2913 }
2914}
2915impl<'a> From<&'a BindPat> for &'a Pat {
2916 fn from(n: &'a BindPat) -> &'a Pat {
2917 Pat::cast(&n.syntax).unwrap()
2918 }
2919}
2920impl<'a> From<&'a PlaceholderPat> for &'a Pat {
2921 fn from(n: &'a PlaceholderPat) -> &'a Pat {
2922 Pat::cast(&n.syntax).unwrap()
2923 }
2924}
2925impl<'a> From<&'a PathPat> for &'a Pat {
2926 fn from(n: &'a PathPat) -> &'a Pat {
2927 Pat::cast(&n.syntax).unwrap()
2928 }
2929}
2930impl<'a> From<&'a StructPat> for &'a Pat {
2931 fn from(n: &'a StructPat) -> &'a Pat {
2932 Pat::cast(&n.syntax).unwrap()
2933 }
2934}
2935impl<'a> From<&'a TupleStructPat> for &'a Pat {
2936 fn from(n: &'a TupleStructPat) -> &'a Pat {
2937 Pat::cast(&n.syntax).unwrap()
2938 }
2939}
2940impl<'a> From<&'a TuplePat> for &'a Pat {
2941 fn from(n: &'a TuplePat) -> &'a Pat {
2942 Pat::cast(&n.syntax).unwrap()
2943 }
2944}
2945impl<'a> From<&'a SlicePat> for &'a Pat {
2946 fn from(n: &'a SlicePat) -> &'a Pat {
2947 Pat::cast(&n.syntax).unwrap()
2948 }
2949}
2950impl<'a> From<&'a RangePat> for &'a Pat {
2951 fn from(n: &'a RangePat) -> &'a Pat {
2952 Pat::cast(&n.syntax).unwrap()
2953 }
2954}
2955impl<'a> From<&'a LiteralPat> for &'a Pat {
2956 fn from(n: &'a LiteralPat) -> &'a Pat {
2957 Pat::cast(&n.syntax).unwrap()
2958 }
2959}
2960
2640 2961
2641impl AstNode for Pat { 2962impl AstNode for Pat {
2642 fn cast(syntax: &SyntaxNode) -> Option<&Self> { 2963 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
@@ -3520,6 +3841,17 @@ pub enum StmtKind<'a> {
3520 ExprStmt(&'a ExprStmt), 3841 ExprStmt(&'a ExprStmt),
3521 LetStmt(&'a LetStmt), 3842 LetStmt(&'a LetStmt),
3522} 3843}
3844impl<'a> From<&'a ExprStmt> for &'a Stmt {
3845 fn from(n: &'a ExprStmt) -> &'a Stmt {
3846 Stmt::cast(&n.syntax).unwrap()
3847 }
3848}
3849impl<'a> From<&'a LetStmt> for &'a Stmt {
3850 fn from(n: &'a LetStmt) -> &'a Stmt {
3851 Stmt::cast(&n.syntax).unwrap()
3852 }
3853}
3854
3523 3855
3524impl AstNode for Stmt { 3856impl AstNode for Stmt {
3525 fn cast(syntax: &SyntaxNode) -> Option<&Self> { 3857 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
@@ -4142,6 +4474,72 @@ pub enum TypeRefKind<'a> {
4142 ImplTraitType(&'a ImplTraitType), 4474 ImplTraitType(&'a ImplTraitType),
4143 DynTraitType(&'a DynTraitType), 4475 DynTraitType(&'a DynTraitType),
4144} 4476}
4477impl<'a> From<&'a ParenType> for &'a TypeRef {
4478 fn from(n: &'a ParenType) -> &'a TypeRef {
4479 TypeRef::cast(&n.syntax).unwrap()
4480 }
4481}
4482impl<'a> From<&'a TupleType> for &'a TypeRef {
4483 fn from(n: &'a TupleType) -> &'a TypeRef {
4484 TypeRef::cast(&n.syntax).unwrap()
4485 }
4486}
4487impl<'a> From<&'a NeverType> for &'a TypeRef {
4488 fn from(n: &'a NeverType) -> &'a TypeRef {
4489 TypeRef::cast(&n.syntax).unwrap()
4490 }
4491}
4492impl<'a> From<&'a PathType> for &'a TypeRef {
4493 fn from(n: &'a PathType) -> &'a TypeRef {
4494 TypeRef::cast(&n.syntax).unwrap()
4495 }
4496}
4497impl<'a> From<&'a PointerType> for &'a TypeRef {
4498 fn from(n: &'a PointerType) -> &'a TypeRef {
4499 TypeRef::cast(&n.syntax).unwrap()
4500 }
4501}
4502impl<'a> From<&'a ArrayType> for &'a TypeRef {
4503 fn from(n: &'a ArrayType) -> &'a TypeRef {
4504 TypeRef::cast(&n.syntax).unwrap()
4505 }
4506}
4507impl<'a> From<&'a SliceType> for &'a TypeRef {
4508 fn from(n: &'a SliceType) -> &'a TypeRef {
4509 TypeRef::cast(&n.syntax).unwrap()
4510 }
4511}
4512impl<'a> From<&'a ReferenceType> for &'a TypeRef {
4513 fn from(n: &'a ReferenceType) -> &'a TypeRef {
4514 TypeRef::cast(&n.syntax).unwrap()
4515 }
4516}
4517impl<'a> From<&'a PlaceholderType> for &'a TypeRef {
4518 fn from(n: &'a PlaceholderType) -> &'a TypeRef {
4519 TypeRef::cast(&n.syntax).unwrap()
4520 }
4521}
4522impl<'a> From<&'a FnPointerType> for &'a TypeRef {
4523 fn from(n: &'a FnPointerType) -> &'a TypeRef {
4524 TypeRef::cast(&n.syntax).unwrap()
4525 }
4526}
4527impl<'a> From<&'a ForType> for &'a TypeRef {
4528 fn from(n: &'a ForType) -> &'a TypeRef {
4529 TypeRef::cast(&n.syntax).unwrap()
4530 }
4531}
4532impl<'a> From<&'a ImplTraitType> for &'a TypeRef {
4533 fn from(n: &'a ImplTraitType) -> &'a TypeRef {
4534 TypeRef::cast(&n.syntax).unwrap()
4535 }
4536}
4537impl<'a> From<&'a DynTraitType> for &'a TypeRef {
4538 fn from(n: &'a DynTraitType) -> &'a TypeRef {
4539 TypeRef::cast(&n.syntax).unwrap()
4540 }
4541}
4542
4145 4543
4146impl AstNode for TypeRef { 4544impl AstNode for TypeRef {
4147 fn cast(syntax: &SyntaxNode) -> Option<&Self> { 4545 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
diff --git a/crates/ra_syntax/src/ast/generated.rs.tera b/crates/ra_syntax/src/ast/generated.rs.tera
index ca7a28581..e2d4856cf 100644
--- a/crates/ra_syntax/src/ast/generated.rs.tera
+++ b/crates/ra_syntax/src/ast/generated.rs.tera
@@ -38,6 +38,15 @@ pub enum {{ node }}Kind<'a> {
38{%- endfor %} 38{%- endfor %}
39} 39}
40 40
41{%- for kind in methods.enum %}
42impl<'a> From<&'a {{ kind }}> for &'a {{ node }} {
43 fn from(n: &'a {{ kind }}) -> &'a {{ node }} {
44 {{ node }}::cast(&n.syntax).unwrap()
45 }
46}
47{%- endfor %}
48
49
41impl AstNode for {{ node }} { 50impl AstNode for {{ node }} {
42 fn cast(syntax: &SyntaxNode) -> Option<&Self> { 51 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
43 match syntax.kind() { 52 match syntax.kind() {