diff options
Diffstat (limited to 'crates/ra_syntax/src/ast/generated.rs')
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs | 662 |
1 files changed, 122 insertions, 540 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 47a37e4d1..0376c91c8 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs | |||
@@ -376,64 +376,6 @@ impl BreakExpr { | |||
376 | } | 376 | } |
377 | } | 377 | } |
378 | 378 | ||
379 | // Byte | ||
380 | #[derive(Debug, PartialEq, Eq, Hash)] | ||
381 | #[repr(transparent)] | ||
382 | pub struct Byte { | ||
383 | pub(crate) syntax: SyntaxNode, | ||
384 | } | ||
385 | unsafe impl TransparentNewType for Byte { | ||
386 | type Repr = rowan::SyntaxNode<RaTypes>; | ||
387 | } | ||
388 | |||
389 | impl AstNode for Byte { | ||
390 | fn cast(syntax: &SyntaxNode) -> Option<&Self> { | ||
391 | match syntax.kind() { | ||
392 | BYTE => Some(Byte::from_repr(syntax.into_repr())), | ||
393 | _ => None, | ||
394 | } | ||
395 | } | ||
396 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
397 | } | ||
398 | |||
399 | impl ToOwned for Byte { | ||
400 | type Owned = TreeArc<Byte>; | ||
401 | fn to_owned(&self) -> TreeArc<Byte> { TreeArc::cast(self.syntax.to_owned()) } | ||
402 | } | ||
403 | |||
404 | |||
405 | impl ast::AstToken for Byte {} | ||
406 | impl Byte {} | ||
407 | |||
408 | // ByteString | ||
409 | #[derive(Debug, PartialEq, Eq, Hash)] | ||
410 | #[repr(transparent)] | ||
411 | pub struct ByteString { | ||
412 | pub(crate) syntax: SyntaxNode, | ||
413 | } | ||
414 | unsafe impl TransparentNewType for ByteString { | ||
415 | type Repr = rowan::SyntaxNode<RaTypes>; | ||
416 | } | ||
417 | |||
418 | impl AstNode for ByteString { | ||
419 | fn cast(syntax: &SyntaxNode) -> Option<&Self> { | ||
420 | match syntax.kind() { | ||
421 | BYTE_STRING => Some(ByteString::from_repr(syntax.into_repr())), | ||
422 | _ => None, | ||
423 | } | ||
424 | } | ||
425 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
426 | } | ||
427 | |||
428 | impl ToOwned for ByteString { | ||
429 | type Owned = TreeArc<ByteString>; | ||
430 | fn to_owned(&self) -> TreeArc<ByteString> { TreeArc::cast(self.syntax.to_owned()) } | ||
431 | } | ||
432 | |||
433 | |||
434 | impl ast::AstToken for ByteString {} | ||
435 | impl ByteString {} | ||
436 | |||
437 | // CallExpr | 379 | // CallExpr |
438 | #[derive(Debug, PartialEq, Eq, Hash)] | 380 | #[derive(Debug, PartialEq, Eq, Hash)] |
439 | #[repr(transparent)] | 381 | #[repr(transparent)] |
@@ -503,64 +445,6 @@ impl CastExpr { | |||
503 | } | 445 | } |
504 | } | 446 | } |
505 | 447 | ||
506 | // Char | ||
507 | #[derive(Debug, PartialEq, Eq, Hash)] | ||
508 | #[repr(transparent)] | ||
509 | pub struct Char { | ||
510 | pub(crate) syntax: SyntaxNode, | ||
511 | } | ||
512 | unsafe impl TransparentNewType for Char { | ||
513 | type Repr = rowan::SyntaxNode<RaTypes>; | ||
514 | } | ||
515 | |||
516 | impl AstNode for Char { | ||
517 | fn cast(syntax: &SyntaxNode) -> Option<&Self> { | ||
518 | match syntax.kind() { | ||
519 | CHAR => Some(Char::from_repr(syntax.into_repr())), | ||
520 | _ => None, | ||
521 | } | ||
522 | } | ||
523 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
524 | } | ||
525 | |||
526 | impl ToOwned for Char { | ||
527 | type Owned = TreeArc<Char>; | ||
528 | fn to_owned(&self) -> TreeArc<Char> { TreeArc::cast(self.syntax.to_owned()) } | ||
529 | } | ||
530 | |||
531 | |||
532 | impl ast::AstToken for Char {} | ||
533 | impl Char {} | ||
534 | |||
535 | // Comment | ||
536 | #[derive(Debug, PartialEq, Eq, Hash)] | ||
537 | #[repr(transparent)] | ||
538 | pub struct Comment { | ||
539 | pub(crate) syntax: SyntaxNode, | ||
540 | } | ||
541 | unsafe impl TransparentNewType for Comment { | ||
542 | type Repr = rowan::SyntaxNode<RaTypes>; | ||
543 | } | ||
544 | |||
545 | impl AstNode for Comment { | ||
546 | fn cast(syntax: &SyntaxNode) -> Option<&Self> { | ||
547 | match syntax.kind() { | ||
548 | COMMENT => Some(Comment::from_repr(syntax.into_repr())), | ||
549 | _ => None, | ||
550 | } | ||
551 | } | ||
552 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
553 | } | ||
554 | |||
555 | impl ToOwned for Comment { | ||
556 | type Owned = TreeArc<Comment>; | ||
557 | fn to_owned(&self) -> TreeArc<Comment> { TreeArc::cast(self.syntax.to_owned()) } | ||
558 | } | ||
559 | |||
560 | |||
561 | impl ast::AstToken for Comment {} | ||
562 | impl Comment {} | ||
563 | |||
564 | // Condition | 448 | // Condition |
565 | #[derive(Debug, PartialEq, Eq, Hash)] | 449 | #[derive(Debug, PartialEq, Eq, Hash)] |
566 | #[repr(transparent)] | 450 | #[repr(transparent)] |
@@ -629,7 +513,11 @@ impl ast::TypeParamsOwner for ConstDef {} | |||
629 | impl ast::AttrsOwner for ConstDef {} | 513 | impl ast::AttrsOwner for ConstDef {} |
630 | impl ast::DocCommentsOwner for ConstDef {} | 514 | impl ast::DocCommentsOwner for ConstDef {} |
631 | impl ast::TypeAscriptionOwner for ConstDef {} | 515 | impl ast::TypeAscriptionOwner for ConstDef {} |
632 | impl ConstDef {} | 516 | impl ConstDef { |
517 | pub fn body(&self) -> Option<&Expr> { | ||
518 | super::child_opt(self) | ||
519 | } | ||
520 | } | ||
633 | 521 | ||
634 | // ContinueExpr | 522 | // ContinueExpr |
635 | #[derive(Debug, PartialEq, Eq, Hash)] | 523 | #[derive(Debug, PartialEq, Eq, Hash)] |
@@ -685,6 +573,7 @@ impl ToOwned for DynTraitType { | |||
685 | } | 573 | } |
686 | 574 | ||
687 | 575 | ||
576 | impl ast::TypeBoundsOwner for DynTraitType {} | ||
688 | impl DynTraitType {} | 577 | impl DynTraitType {} |
689 | 578 | ||
690 | // EnumDef | 579 | // EnumDef |
@@ -830,6 +719,7 @@ pub enum ExprKind<'a> { | |||
830 | RangeExpr(&'a RangeExpr), | 719 | RangeExpr(&'a RangeExpr), |
831 | BinExpr(&'a BinExpr), | 720 | BinExpr(&'a BinExpr), |
832 | Literal(&'a Literal), | 721 | Literal(&'a Literal), |
722 | MacroCall(&'a MacroCall), | ||
833 | } | 723 | } |
834 | impl<'a> From<&'a TupleExpr> for &'a Expr { | 724 | impl<'a> From<&'a TupleExpr> for &'a Expr { |
835 | fn from(n: &'a TupleExpr) -> &'a Expr { | 725 | fn from(n: &'a TupleExpr) -> &'a Expr { |
@@ -966,6 +856,11 @@ impl<'a> From<&'a Literal> for &'a Expr { | |||
966 | Expr::cast(&n.syntax).unwrap() | 856 | Expr::cast(&n.syntax).unwrap() |
967 | } | 857 | } |
968 | } | 858 | } |
859 | impl<'a> From<&'a MacroCall> for &'a Expr { | ||
860 | fn from(n: &'a MacroCall) -> &'a Expr { | ||
861 | Expr::cast(&n.syntax).unwrap() | ||
862 | } | ||
863 | } | ||
969 | 864 | ||
970 | 865 | ||
971 | impl AstNode for Expr { | 866 | impl AstNode for Expr { |
@@ -997,7 +892,8 @@ impl AstNode for Expr { | |||
997 | | PREFIX_EXPR | 892 | | PREFIX_EXPR |
998 | | RANGE_EXPR | 893 | | RANGE_EXPR |
999 | | BIN_EXPR | 894 | | BIN_EXPR |
1000 | | LITERAL => Some(Expr::from_repr(syntax.into_repr())), | 895 | | LITERAL |
896 | | MACRO_CALL => Some(Expr::from_repr(syntax.into_repr())), | ||
1001 | _ => None, | 897 | _ => None, |
1002 | } | 898 | } |
1003 | } | 899 | } |
@@ -1039,6 +935,7 @@ impl Expr { | |||
1039 | RANGE_EXPR => ExprKind::RangeExpr(RangeExpr::cast(&self.syntax).unwrap()), | 935 | RANGE_EXPR => ExprKind::RangeExpr(RangeExpr::cast(&self.syntax).unwrap()), |
1040 | BIN_EXPR => ExprKind::BinExpr(BinExpr::cast(&self.syntax).unwrap()), | 936 | BIN_EXPR => ExprKind::BinExpr(BinExpr::cast(&self.syntax).unwrap()), |
1041 | LITERAL => ExprKind::Literal(Literal::cast(&self.syntax).unwrap()), | 937 | LITERAL => ExprKind::Literal(Literal::cast(&self.syntax).unwrap()), |
938 | MACRO_CALL => ExprKind::MacroCall(MacroCall::cast(&self.syntax).unwrap()), | ||
1042 | _ => unreachable!(), | 939 | _ => unreachable!(), |
1043 | } | 940 | } |
1044 | } | 941 | } |
@@ -1114,35 +1011,6 @@ impl ExternCrateItem { | |||
1114 | } | 1011 | } |
1115 | } | 1012 | } |
1116 | 1013 | ||
1117 | // FalseKw | ||
1118 | #[derive(Debug, PartialEq, Eq, Hash)] | ||
1119 | #[repr(transparent)] | ||
1120 | pub struct FalseKw { | ||
1121 | pub(crate) syntax: SyntaxNode, | ||
1122 | } | ||
1123 | unsafe impl TransparentNewType for FalseKw { | ||
1124 | type Repr = rowan::SyntaxNode<RaTypes>; | ||
1125 | } | ||
1126 | |||
1127 | impl AstNode for FalseKw { | ||
1128 | fn cast(syntax: &SyntaxNode) -> Option<&Self> { | ||
1129 | match syntax.kind() { | ||
1130 | FALSE_KW => Some(FalseKw::from_repr(syntax.into_repr())), | ||
1131 | _ => None, | ||
1132 | } | ||
1133 | } | ||
1134 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1135 | } | ||
1136 | |||
1137 | impl ToOwned for FalseKw { | ||
1138 | type Owned = TreeArc<FalseKw>; | ||
1139 | fn to_owned(&self) -> TreeArc<FalseKw> { TreeArc::cast(self.syntax.to_owned()) } | ||
1140 | } | ||
1141 | |||
1142 | |||
1143 | impl ast::AstToken for FalseKw {} | ||
1144 | impl FalseKw {} | ||
1145 | |||
1146 | // FieldExpr | 1014 | // FieldExpr |
1147 | #[derive(Debug, PartialEq, Eq, Hash)] | 1015 | #[derive(Debug, PartialEq, Eq, Hash)] |
1148 | #[repr(transparent)] | 1016 | #[repr(transparent)] |
@@ -1248,35 +1116,6 @@ impl FieldPatList { | |||
1248 | } | 1116 | } |
1249 | } | 1117 | } |
1250 | 1118 | ||
1251 | // FloatNumber | ||
1252 | #[derive(Debug, PartialEq, Eq, Hash)] | ||
1253 | #[repr(transparent)] | ||
1254 | pub struct FloatNumber { | ||
1255 | pub(crate) syntax: SyntaxNode, | ||
1256 | } | ||
1257 | unsafe impl TransparentNewType for FloatNumber { | ||
1258 | type Repr = rowan::SyntaxNode<RaTypes>; | ||
1259 | } | ||
1260 | |||
1261 | impl AstNode for FloatNumber { | ||
1262 | fn cast(syntax: &SyntaxNode) -> Option<&Self> { | ||
1263 | match syntax.kind() { | ||
1264 | FLOAT_NUMBER => Some(FloatNumber::from_repr(syntax.into_repr())), | ||
1265 | _ => None, | ||
1266 | } | ||
1267 | } | ||
1268 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1269 | } | ||
1270 | |||
1271 | impl ToOwned for FloatNumber { | ||
1272 | type Owned = TreeArc<FloatNumber>; | ||
1273 | fn to_owned(&self) -> TreeArc<FloatNumber> { TreeArc::cast(self.syntax.to_owned()) } | ||
1274 | } | ||
1275 | |||
1276 | |||
1277 | impl ast::AstToken for FloatNumber {} | ||
1278 | impl FloatNumber {} | ||
1279 | |||
1280 | // FnDef | 1119 | // FnDef |
1281 | #[derive(Debug, PartialEq, Eq, Hash)] | 1120 | #[derive(Debug, PartialEq, Eq, Hash)] |
1282 | #[repr(transparent)] | 1121 | #[repr(transparent)] |
@@ -1581,6 +1420,7 @@ impl ToOwned for ImplTraitType { | |||
1581 | } | 1420 | } |
1582 | 1421 | ||
1583 | 1422 | ||
1423 | impl ast::TypeBoundsOwner for ImplTraitType {} | ||
1584 | impl ImplTraitType {} | 1424 | impl ImplTraitType {} |
1585 | 1425 | ||
1586 | // IndexExpr | 1426 | // IndexExpr |
@@ -1611,35 +1451,6 @@ impl ToOwned for IndexExpr { | |||
1611 | 1451 | ||
1612 | impl IndexExpr {} | 1452 | impl IndexExpr {} |
1613 | 1453 | ||
1614 | // IntNumber | ||
1615 | #[derive(Debug, PartialEq, Eq, Hash)] | ||
1616 | #[repr(transparent)] | ||
1617 | pub struct IntNumber { | ||
1618 | pub(crate) syntax: SyntaxNode, | ||
1619 | } | ||
1620 | unsafe impl TransparentNewType for IntNumber { | ||
1621 | type Repr = rowan::SyntaxNode<RaTypes>; | ||
1622 | } | ||
1623 | |||
1624 | impl AstNode for IntNumber { | ||
1625 | fn cast(syntax: &SyntaxNode) -> Option<&Self> { | ||
1626 | match syntax.kind() { | ||
1627 | INT_NUMBER => Some(IntNumber::from_repr(syntax.into_repr())), | ||
1628 | _ => None, | ||
1629 | } | ||
1630 | } | ||
1631 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1632 | } | ||
1633 | |||
1634 | impl ToOwned for IntNumber { | ||
1635 | type Owned = TreeArc<IntNumber>; | ||
1636 | fn to_owned(&self) -> TreeArc<IntNumber> { TreeArc::cast(self.syntax.to_owned()) } | ||
1637 | } | ||
1638 | |||
1639 | |||
1640 | impl ast::AstToken for IntNumber {} | ||
1641 | impl IntNumber {} | ||
1642 | |||
1643 | // ItemList | 1454 | // ItemList |
1644 | #[derive(Debug, PartialEq, Eq, Hash)] | 1455 | #[derive(Debug, PartialEq, Eq, Hash)] |
1645 | #[repr(transparent)] | 1456 | #[repr(transparent)] |
@@ -1775,35 +1586,6 @@ impl LetStmt { | |||
1775 | } | 1586 | } |
1776 | } | 1587 | } |
1777 | 1588 | ||
1778 | // Lifetime | ||
1779 | #[derive(Debug, PartialEq, Eq, Hash)] | ||
1780 | #[repr(transparent)] | ||
1781 | pub struct Lifetime { | ||
1782 | pub(crate) syntax: SyntaxNode, | ||
1783 | } | ||
1784 | unsafe impl TransparentNewType for Lifetime { | ||
1785 | type Repr = rowan::SyntaxNode<RaTypes>; | ||
1786 | } | ||
1787 | |||
1788 | impl AstNode for Lifetime { | ||
1789 | fn cast(syntax: &SyntaxNode) -> Option<&Self> { | ||
1790 | match syntax.kind() { | ||
1791 | LIFETIME => Some(Lifetime::from_repr(syntax.into_repr())), | ||
1792 | _ => None, | ||
1793 | } | ||
1794 | } | ||
1795 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1796 | } | ||
1797 | |||
1798 | impl ToOwned for Lifetime { | ||
1799 | type Owned = TreeArc<Lifetime>; | ||
1800 | fn to_owned(&self) -> TreeArc<Lifetime> { TreeArc::cast(self.syntax.to_owned()) } | ||
1801 | } | ||
1802 | |||
1803 | |||
1804 | impl ast::AstToken for Lifetime {} | ||
1805 | impl Lifetime {} | ||
1806 | |||
1807 | // LifetimeArg | 1589 | // LifetimeArg |
1808 | #[derive(Debug, PartialEq, Eq, Hash)] | 1590 | #[derive(Debug, PartialEq, Eq, Hash)] |
1809 | #[repr(transparent)] | 1591 | #[repr(transparent)] |
@@ -1830,11 +1612,7 @@ impl ToOwned for LifetimeArg { | |||
1830 | } | 1612 | } |
1831 | 1613 | ||
1832 | 1614 | ||
1833 | impl LifetimeArg { | 1615 | impl LifetimeArg {} |
1834 | pub fn lifetime(&self) -> Option<&Lifetime> { | ||
1835 | super::child_opt(self) | ||
1836 | } | ||
1837 | } | ||
1838 | 1616 | ||
1839 | // LifetimeParam | 1617 | // LifetimeParam |
1840 | #[derive(Debug, PartialEq, Eq, Hash)] | 1618 | #[derive(Debug, PartialEq, Eq, Hash)] |
@@ -1863,11 +1641,7 @@ impl ToOwned for LifetimeParam { | |||
1863 | 1641 | ||
1864 | 1642 | ||
1865 | impl ast::AttrsOwner for LifetimeParam {} | 1643 | impl ast::AttrsOwner for LifetimeParam {} |
1866 | impl LifetimeParam { | 1644 | impl LifetimeParam {} |
1867 | pub fn lifetime(&self) -> Option<&Lifetime> { | ||
1868 | super::child_opt(self) | ||
1869 | } | ||
1870 | } | ||
1871 | 1645 | ||
1872 | // Literal | 1646 | // Literal |
1873 | #[derive(Debug, PartialEq, Eq, Hash)] | 1647 | #[derive(Debug, PartialEq, Eq, Hash)] |
@@ -1895,130 +1669,7 @@ impl ToOwned for Literal { | |||
1895 | } | 1669 | } |
1896 | 1670 | ||
1897 | 1671 | ||
1898 | impl Literal { | 1672 | impl Literal {} |
1899 | pub fn literal_expr(&self) -> Option<&LiteralExpr> { | ||
1900 | super::child_opt(self) | ||
1901 | } | ||
1902 | } | ||
1903 | |||
1904 | // LiteralExpr | ||
1905 | #[derive(Debug, PartialEq, Eq, Hash)] | ||
1906 | #[repr(transparent)] | ||
1907 | pub struct LiteralExpr { | ||
1908 | pub(crate) syntax: SyntaxNode, | ||
1909 | } | ||
1910 | unsafe impl TransparentNewType for LiteralExpr { | ||
1911 | type Repr = rowan::SyntaxNode<RaTypes>; | ||
1912 | } | ||
1913 | |||
1914 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
1915 | pub enum LiteralExprKind<'a> { | ||
1916 | String(&'a String), | ||
1917 | ByteString(&'a ByteString), | ||
1918 | RawString(&'a RawString), | ||
1919 | RawByteString(&'a RawByteString), | ||
1920 | Char(&'a Char), | ||
1921 | Byte(&'a Byte), | ||
1922 | IntNumber(&'a IntNumber), | ||
1923 | FloatNumber(&'a FloatNumber), | ||
1924 | TrueKw(&'a TrueKw), | ||
1925 | FalseKw(&'a FalseKw), | ||
1926 | } | ||
1927 | impl<'a> From<&'a String> for &'a LiteralExpr { | ||
1928 | fn from(n: &'a String) -> &'a LiteralExpr { | ||
1929 | LiteralExpr::cast(&n.syntax).unwrap() | ||
1930 | } | ||
1931 | } | ||
1932 | impl<'a> From<&'a ByteString> for &'a LiteralExpr { | ||
1933 | fn from(n: &'a ByteString) -> &'a LiteralExpr { | ||
1934 | LiteralExpr::cast(&n.syntax).unwrap() | ||
1935 | } | ||
1936 | } | ||
1937 | impl<'a> From<&'a RawString> for &'a LiteralExpr { | ||
1938 | fn from(n: &'a RawString) -> &'a LiteralExpr { | ||
1939 | LiteralExpr::cast(&n.syntax).unwrap() | ||
1940 | } | ||
1941 | } | ||
1942 | impl<'a> From<&'a RawByteString> for &'a LiteralExpr { | ||
1943 | fn from(n: &'a RawByteString) -> &'a LiteralExpr { | ||
1944 | LiteralExpr::cast(&n.syntax).unwrap() | ||
1945 | } | ||
1946 | } | ||
1947 | impl<'a> From<&'a Char> for &'a LiteralExpr { | ||
1948 | fn from(n: &'a Char) -> &'a LiteralExpr { | ||
1949 | LiteralExpr::cast(&n.syntax).unwrap() | ||
1950 | } | ||
1951 | } | ||
1952 | impl<'a> From<&'a Byte> for &'a LiteralExpr { | ||
1953 | fn from(n: &'a Byte) -> &'a LiteralExpr { | ||
1954 | LiteralExpr::cast(&n.syntax).unwrap() | ||
1955 | } | ||
1956 | } | ||
1957 | impl<'a> From<&'a IntNumber> for &'a LiteralExpr { | ||
1958 | fn from(n: &'a IntNumber) -> &'a LiteralExpr { | ||
1959 | LiteralExpr::cast(&n.syntax).unwrap() | ||
1960 | } | ||
1961 | } | ||
1962 | impl<'a> From<&'a FloatNumber> for &'a LiteralExpr { | ||
1963 | fn from(n: &'a FloatNumber) -> &'a LiteralExpr { | ||
1964 | LiteralExpr::cast(&n.syntax).unwrap() | ||
1965 | } | ||
1966 | } | ||
1967 | impl<'a> From<&'a TrueKw> for &'a LiteralExpr { | ||
1968 | fn from(n: &'a TrueKw) -> &'a LiteralExpr { | ||
1969 | LiteralExpr::cast(&n.syntax).unwrap() | ||
1970 | } | ||
1971 | } | ||
1972 | impl<'a> From<&'a FalseKw> for &'a LiteralExpr { | ||
1973 | fn from(n: &'a FalseKw) -> &'a LiteralExpr { | ||
1974 | LiteralExpr::cast(&n.syntax).unwrap() | ||
1975 | } | ||
1976 | } | ||
1977 | |||
1978 | |||
1979 | impl AstNode for LiteralExpr { | ||
1980 | fn cast(syntax: &SyntaxNode) -> Option<&Self> { | ||
1981 | match syntax.kind() { | ||
1982 | | STRING | ||
1983 | | BYTE_STRING | ||
1984 | | RAW_STRING | ||
1985 | | RAW_BYTE_STRING | ||
1986 | | CHAR | ||
1987 | | BYTE | ||
1988 | | INT_NUMBER | ||
1989 | | FLOAT_NUMBER | ||
1990 | | TRUE_KW | ||
1991 | | FALSE_KW => Some(LiteralExpr::from_repr(syntax.into_repr())), | ||
1992 | _ => None, | ||
1993 | } | ||
1994 | } | ||
1995 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1996 | } | ||
1997 | |||
1998 | impl ToOwned for LiteralExpr { | ||
1999 | type Owned = TreeArc<LiteralExpr>; | ||
2000 | fn to_owned(&self) -> TreeArc<LiteralExpr> { TreeArc::cast(self.syntax.to_owned()) } | ||
2001 | } | ||
2002 | |||
2003 | impl LiteralExpr { | ||
2004 | pub fn kind(&self) -> LiteralExprKind { | ||
2005 | match self.syntax.kind() { | ||
2006 | STRING => LiteralExprKind::String(String::cast(&self.syntax).unwrap()), | ||
2007 | BYTE_STRING => LiteralExprKind::ByteString(ByteString::cast(&self.syntax).unwrap()), | ||
2008 | RAW_STRING => LiteralExprKind::RawString(RawString::cast(&self.syntax).unwrap()), | ||
2009 | RAW_BYTE_STRING => LiteralExprKind::RawByteString(RawByteString::cast(&self.syntax).unwrap()), | ||
2010 | CHAR => LiteralExprKind::Char(Char::cast(&self.syntax).unwrap()), | ||
2011 | BYTE => LiteralExprKind::Byte(Byte::cast(&self.syntax).unwrap()), | ||
2012 | INT_NUMBER => LiteralExprKind::IntNumber(IntNumber::cast(&self.syntax).unwrap()), | ||
2013 | FLOAT_NUMBER => LiteralExprKind::FloatNumber(FloatNumber::cast(&self.syntax).unwrap()), | ||
2014 | TRUE_KW => LiteralExprKind::TrueKw(TrueKw::cast(&self.syntax).unwrap()), | ||
2015 | FALSE_KW => LiteralExprKind::FalseKw(FalseKw::cast(&self.syntax).unwrap()), | ||
2016 | _ => unreachable!(), | ||
2017 | } | ||
2018 | } | ||
2019 | } | ||
2020 | |||
2021 | impl LiteralExpr {} | ||
2022 | 1673 | ||
2023 | // LiteralPat | 1674 | // LiteralPat |
2024 | #[derive(Debug, PartialEq, Eq, Hash)] | 1675 | #[derive(Debug, PartialEq, Eq, Hash)] |
@@ -3402,64 +3053,6 @@ impl ToOwned for RangePat { | |||
3402 | 3053 | ||
3403 | impl RangePat {} | 3054 | impl RangePat {} |
3404 | 3055 | ||
3405 | // RawByteString | ||
3406 | #[derive(Debug, PartialEq, Eq, Hash)] | ||
3407 | #[repr(transparent)] | ||
3408 | pub struct RawByteString { | ||
3409 | pub(crate) syntax: SyntaxNode, | ||
3410 | } | ||
3411 | unsafe impl TransparentNewType for RawByteString { | ||
3412 | type Repr = rowan::SyntaxNode<RaTypes>; | ||
3413 | } | ||
3414 | |||
3415 | impl AstNode for RawByteString { | ||
3416 | fn cast(syntax: &SyntaxNode) -> Option<&Self> { | ||
3417 | match syntax.kind() { | ||
3418 | RAW_BYTE_STRING => Some(RawByteString::from_repr(syntax.into_repr())), | ||
3419 | _ => None, | ||
3420 | } | ||
3421 | } | ||
3422 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
3423 | } | ||
3424 | |||
3425 | impl ToOwned for RawByteString { | ||
3426 | type Owned = TreeArc<RawByteString>; | ||
3427 | fn to_owned(&self) -> TreeArc<RawByteString> { TreeArc::cast(self.syntax.to_owned()) } | ||
3428 | } | ||
3429 | |||
3430 | |||
3431 | impl ast::AstToken for RawByteString {} | ||
3432 | impl RawByteString {} | ||
3433 | |||
3434 | // RawString | ||
3435 | #[derive(Debug, PartialEq, Eq, Hash)] | ||
3436 | #[repr(transparent)] | ||
3437 | pub struct RawString { | ||
3438 | pub(crate) syntax: SyntaxNode, | ||
3439 | } | ||
3440 | unsafe impl TransparentNewType for RawString { | ||
3441 | type Repr = rowan::SyntaxNode<RaTypes>; | ||
3442 | } | ||
3443 | |||
3444 | impl AstNode for RawString { | ||
3445 | fn cast(syntax: &SyntaxNode) -> Option<&Self> { | ||
3446 | match syntax.kind() { | ||
3447 | RAW_STRING => Some(RawString::from_repr(syntax.into_repr())), | ||
3448 | _ => None, | ||
3449 | } | ||
3450 | } | ||
3451 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
3452 | } | ||
3453 | |||
3454 | impl ToOwned for RawString { | ||
3455 | type Owned = TreeArc<RawString>; | ||
3456 | fn to_owned(&self) -> TreeArc<RawString> { TreeArc::cast(self.syntax.to_owned()) } | ||
3457 | } | ||
3458 | |||
3459 | |||
3460 | impl ast::AstToken for RawString {} | ||
3461 | impl RawString {} | ||
3462 | |||
3463 | // RefExpr | 3056 | // RefExpr |
3464 | #[derive(Debug, PartialEq, Eq, Hash)] | 3057 | #[derive(Debug, PartialEq, Eq, Hash)] |
3465 | #[repr(transparent)] | 3058 | #[repr(transparent)] |
@@ -3620,34 +3213,6 @@ impl ReturnExpr { | |||
3620 | } | 3213 | } |
3621 | } | 3214 | } |
3622 | 3215 | ||
3623 | // SelfKw | ||
3624 | #[derive(Debug, PartialEq, Eq, Hash)] | ||
3625 | #[repr(transparent)] | ||
3626 | pub struct SelfKw { | ||
3627 | pub(crate) syntax: SyntaxNode, | ||
3628 | } | ||
3629 | unsafe impl TransparentNewType for SelfKw { | ||
3630 | type Repr = rowan::SyntaxNode<RaTypes>; | ||
3631 | } | ||
3632 | |||
3633 | impl AstNode for SelfKw { | ||
3634 | fn cast(syntax: &SyntaxNode) -> Option<&Self> { | ||
3635 | match syntax.kind() { | ||
3636 | SELF_KW => Some(SelfKw::from_repr(syntax.into_repr())), | ||
3637 | _ => None, | ||
3638 | } | ||
3639 | } | ||
3640 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
3641 | } | ||
3642 | |||
3643 | impl ToOwned for SelfKw { | ||
3644 | type Owned = TreeArc<SelfKw>; | ||
3645 | fn to_owned(&self) -> TreeArc<SelfKw> { TreeArc::cast(self.syntax.to_owned()) } | ||
3646 | } | ||
3647 | |||
3648 | |||
3649 | impl SelfKw {} | ||
3650 | |||
3651 | // SelfParam | 3216 | // SelfParam |
3652 | #[derive(Debug, PartialEq, Eq, Hash)] | 3217 | #[derive(Debug, PartialEq, Eq, Hash)] |
3653 | #[repr(transparent)] | 3218 | #[repr(transparent)] |
@@ -3675,11 +3240,7 @@ impl ToOwned for SelfParam { | |||
3675 | 3240 | ||
3676 | 3241 | ||
3677 | impl ast::TypeAscriptionOwner for SelfParam {} | 3242 | impl ast::TypeAscriptionOwner for SelfParam {} |
3678 | impl SelfParam { | 3243 | impl SelfParam {} |
3679 | pub fn self_kw(&self) -> Option<&SelfKw> { | ||
3680 | super::child_opt(self) | ||
3681 | } | ||
3682 | } | ||
3683 | 3244 | ||
3684 | // SlicePat | 3245 | // SlicePat |
3685 | #[derive(Debug, PartialEq, Eq, Hash)] | 3246 | #[derive(Debug, PartialEq, Eq, Hash)] |
@@ -3807,7 +3368,11 @@ impl ast::TypeParamsOwner for StaticDef {} | |||
3807 | impl ast::AttrsOwner for StaticDef {} | 3368 | impl ast::AttrsOwner for StaticDef {} |
3808 | impl ast::DocCommentsOwner for StaticDef {} | 3369 | impl ast::DocCommentsOwner for StaticDef {} |
3809 | impl ast::TypeAscriptionOwner for StaticDef {} | 3370 | impl ast::TypeAscriptionOwner for StaticDef {} |
3810 | impl StaticDef {} | 3371 | impl StaticDef { |
3372 | pub fn body(&self) -> Option<&Expr> { | ||
3373 | super::child_opt(self) | ||
3374 | } | ||
3375 | } | ||
3811 | 3376 | ||
3812 | // Stmt | 3377 | // Stmt |
3813 | #[derive(Debug, PartialEq, Eq, Hash)] | 3378 | #[derive(Debug, PartialEq, Eq, Hash)] |
@@ -3864,35 +3429,6 @@ impl Stmt { | |||
3864 | 3429 | ||
3865 | impl Stmt {} | 3430 | impl Stmt {} |
3866 | 3431 | ||
3867 | // String | ||
3868 | #[derive(Debug, PartialEq, Eq, Hash)] | ||
3869 | #[repr(transparent)] | ||
3870 | pub struct String { | ||
3871 | pub(crate) syntax: SyntaxNode, | ||
3872 | } | ||
3873 | unsafe impl TransparentNewType for String { | ||
3874 | type Repr = rowan::SyntaxNode<RaTypes>; | ||
3875 | } | ||
3876 | |||
3877 | impl AstNode for String { | ||
3878 | fn cast(syntax: &SyntaxNode) -> Option<&Self> { | ||
3879 | match syntax.kind() { | ||
3880 | STRING => Some(String::from_repr(syntax.into_repr())), | ||
3881 | _ => None, | ||
3882 | } | ||
3883 | } | ||
3884 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
3885 | } | ||
3886 | |||
3887 | impl ToOwned for String { | ||
3888 | type Owned = TreeArc<String>; | ||
3889 | fn to_owned(&self) -> TreeArc<String> { TreeArc::cast(self.syntax.to_owned()) } | ||
3890 | } | ||
3891 | |||
3892 | |||
3893 | impl ast::AstToken for String {} | ||
3894 | impl String {} | ||
3895 | |||
3896 | // StructDef | 3432 | // StructDef |
3897 | #[derive(Debug, PartialEq, Eq, Hash)] | 3433 | #[derive(Debug, PartialEq, Eq, Hash)] |
3898 | #[repr(transparent)] | 3434 | #[repr(transparent)] |
@@ -4061,41 +3597,13 @@ impl ast::NameOwner for TraitDef {} | |||
4061 | impl ast::AttrsOwner for TraitDef {} | 3597 | impl ast::AttrsOwner for TraitDef {} |
4062 | impl ast::DocCommentsOwner for TraitDef {} | 3598 | impl ast::DocCommentsOwner for TraitDef {} |
4063 | impl ast::TypeParamsOwner for TraitDef {} | 3599 | impl ast::TypeParamsOwner for TraitDef {} |
3600 | impl ast::TypeBoundsOwner for TraitDef {} | ||
4064 | impl TraitDef { | 3601 | impl TraitDef { |
4065 | pub fn item_list(&self) -> Option<&ItemList> { | 3602 | pub fn item_list(&self) -> Option<&ItemList> { |
4066 | super::child_opt(self) | 3603 | super::child_opt(self) |
4067 | } | 3604 | } |
4068 | } | 3605 | } |
4069 | 3606 | ||
4070 | // TrueKw | ||
4071 | #[derive(Debug, PartialEq, Eq, Hash)] | ||
4072 | #[repr(transparent)] | ||
4073 | pub struct TrueKw { | ||
4074 | pub(crate) syntax: SyntaxNode, | ||
4075 | } | ||
4076 | unsafe impl TransparentNewType for TrueKw { | ||
4077 | type Repr = rowan::SyntaxNode<RaTypes>; | ||
4078 | } | ||
4079 | |||
4080 | impl AstNode for TrueKw { | ||
4081 | fn cast(syntax: &SyntaxNode) -> Option<&Self> { | ||
4082 | match syntax.kind() { | ||
4083 | TRUE_KW => Some(TrueKw::from_repr(syntax.into_repr())), | ||
4084 | _ => None, | ||
4085 | } | ||
4086 | } | ||
4087 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
4088 | } | ||
4089 | |||
4090 | impl ToOwned for TrueKw { | ||
4091 | type Owned = TreeArc<TrueKw>; | ||
4092 | fn to_owned(&self) -> TreeArc<TrueKw> { TreeArc::cast(self.syntax.to_owned()) } | ||
4093 | } | ||
4094 | |||
4095 | |||
4096 | impl ast::AstToken for TrueKw {} | ||
4097 | impl TrueKw {} | ||
4098 | |||
4099 | // TryExpr | 3607 | // TryExpr |
4100 | #[derive(Debug, PartialEq, Eq, Hash)] | 3608 | #[derive(Debug, PartialEq, Eq, Hash)] |
4101 | #[repr(transparent)] | 3609 | #[repr(transparent)] |
@@ -4291,6 +3799,7 @@ impl ast::NameOwner for TypeAliasDef {} | |||
4291 | impl ast::TypeParamsOwner for TypeAliasDef {} | 3799 | impl ast::TypeParamsOwner for TypeAliasDef {} |
4292 | impl ast::AttrsOwner for TypeAliasDef {} | 3800 | impl ast::AttrsOwner for TypeAliasDef {} |
4293 | impl ast::DocCommentsOwner for TypeAliasDef {} | 3801 | impl ast::DocCommentsOwner for TypeAliasDef {} |
3802 | impl ast::TypeBoundsOwner for TypeAliasDef {} | ||
4294 | impl TypeAliasDef { | 3803 | impl TypeAliasDef { |
4295 | pub fn type_ref(&self) -> Option<&TypeRef> { | 3804 | pub fn type_ref(&self) -> Option<&TypeRef> { |
4296 | super::child_opt(self) | 3805 | super::child_opt(self) |
@@ -4369,6 +3878,70 @@ impl TypeArgList { | |||
4369 | } | 3878 | } |
4370 | } | 3879 | } |
4371 | 3880 | ||
3881 | // TypeBound | ||
3882 | #[derive(Debug, PartialEq, Eq, Hash)] | ||
3883 | #[repr(transparent)] | ||
3884 | pub struct TypeBound { | ||
3885 | pub(crate) syntax: SyntaxNode, | ||
3886 | } | ||
3887 | unsafe impl TransparentNewType for TypeBound { | ||
3888 | type Repr = rowan::SyntaxNode<RaTypes>; | ||
3889 | } | ||
3890 | |||
3891 | impl AstNode for TypeBound { | ||
3892 | fn cast(syntax: &SyntaxNode) -> Option<&Self> { | ||
3893 | match syntax.kind() { | ||
3894 | TYPE_BOUND => Some(TypeBound::from_repr(syntax.into_repr())), | ||
3895 | _ => None, | ||
3896 | } | ||
3897 | } | ||
3898 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
3899 | } | ||
3900 | |||
3901 | impl ToOwned for TypeBound { | ||
3902 | type Owned = TreeArc<TypeBound>; | ||
3903 | fn to_owned(&self) -> TreeArc<TypeBound> { TreeArc::cast(self.syntax.to_owned()) } | ||
3904 | } | ||
3905 | |||
3906 | |||
3907 | impl TypeBound { | ||
3908 | pub fn type_ref(&self) -> Option<&TypeRef> { | ||
3909 | super::child_opt(self) | ||
3910 | } | ||
3911 | } | ||
3912 | |||
3913 | // TypeBoundList | ||
3914 | #[derive(Debug, PartialEq, Eq, Hash)] | ||
3915 | #[repr(transparent)] | ||
3916 | pub struct TypeBoundList { | ||
3917 | pub(crate) syntax: SyntaxNode, | ||
3918 | } | ||
3919 | unsafe impl TransparentNewType for TypeBoundList { | ||
3920 | type Repr = rowan::SyntaxNode<RaTypes>; | ||
3921 | } | ||
3922 | |||
3923 | impl AstNode for TypeBoundList { | ||
3924 | fn cast(syntax: &SyntaxNode) -> Option<&Self> { | ||
3925 | match syntax.kind() { | ||
3926 | TYPE_BOUND_LIST => Some(TypeBoundList::from_repr(syntax.into_repr())), | ||
3927 | _ => None, | ||
3928 | } | ||
3929 | } | ||
3930 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
3931 | } | ||
3932 | |||
3933 | impl ToOwned for TypeBoundList { | ||
3934 | type Owned = TreeArc<TypeBoundList>; | ||
3935 | fn to_owned(&self) -> TreeArc<TypeBoundList> { TreeArc::cast(self.syntax.to_owned()) } | ||
3936 | } | ||
3937 | |||
3938 | |||
3939 | impl TypeBoundList { | ||
3940 | pub fn bounds(&self) -> impl Iterator<Item = &TypeBound> { | ||
3941 | super::children(self) | ||
3942 | } | ||
3943 | } | ||
3944 | |||
4372 | // TypeParam | 3945 | // TypeParam |
4373 | #[derive(Debug, PartialEq, Eq, Hash)] | 3946 | #[derive(Debug, PartialEq, Eq, Hash)] |
4374 | #[repr(transparent)] | 3947 | #[repr(transparent)] |
@@ -4397,6 +3970,7 @@ impl ToOwned for TypeParam { | |||
4397 | 3970 | ||
4398 | impl ast::NameOwner for TypeParam {} | 3971 | impl ast::NameOwner for TypeParam {} |
4399 | impl ast::AttrsOwner for TypeParam {} | 3972 | impl ast::AttrsOwner for TypeParam {} |
3973 | impl ast::TypeBoundsOwner for TypeParam {} | ||
4400 | impl TypeParam {} | 3974 | impl TypeParam {} |
4401 | 3975 | ||
4402 | // TypeParamList | 3976 | // TypeParamList |
@@ -4737,67 +4311,75 @@ impl ToOwned for WhereClause { | |||
4737 | } | 4311 | } |
4738 | 4312 | ||
4739 | 4313 | ||
4740 | impl WhereClause {} | 4314 | impl WhereClause { |
4315 | pub fn predicates(&self) -> impl Iterator<Item = &WherePred> { | ||
4316 | super::children(self) | ||
4317 | } | ||
4318 | } | ||
4741 | 4319 | ||
4742 | // WhileExpr | 4320 | // WherePred |
4743 | #[derive(Debug, PartialEq, Eq, Hash)] | 4321 | #[derive(Debug, PartialEq, Eq, Hash)] |
4744 | #[repr(transparent)] | 4322 | #[repr(transparent)] |
4745 | pub struct WhileExpr { | 4323 | pub struct WherePred { |
4746 | pub(crate) syntax: SyntaxNode, | 4324 | pub(crate) syntax: SyntaxNode, |
4747 | } | 4325 | } |
4748 | unsafe impl TransparentNewType for WhileExpr { | 4326 | unsafe impl TransparentNewType for WherePred { |
4749 | type Repr = rowan::SyntaxNode<RaTypes>; | 4327 | type Repr = rowan::SyntaxNode<RaTypes>; |
4750 | } | 4328 | } |
4751 | 4329 | ||
4752 | impl AstNode for WhileExpr { | 4330 | impl AstNode for WherePred { |
4753 | fn cast(syntax: &SyntaxNode) -> Option<&Self> { | 4331 | fn cast(syntax: &SyntaxNode) -> Option<&Self> { |
4754 | match syntax.kind() { | 4332 | match syntax.kind() { |
4755 | WHILE_EXPR => Some(WhileExpr::from_repr(syntax.into_repr())), | 4333 | WHERE_PRED => Some(WherePred::from_repr(syntax.into_repr())), |
4756 | _ => None, | 4334 | _ => None, |
4757 | } | 4335 | } |
4758 | } | 4336 | } |
4759 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 4337 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
4760 | } | 4338 | } |
4761 | 4339 | ||
4762 | impl ToOwned for WhileExpr { | 4340 | impl ToOwned for WherePred { |
4763 | type Owned = TreeArc<WhileExpr>; | 4341 | type Owned = TreeArc<WherePred>; |
4764 | fn to_owned(&self) -> TreeArc<WhileExpr> { TreeArc::cast(self.syntax.to_owned()) } | 4342 | fn to_owned(&self) -> TreeArc<WherePred> { TreeArc::cast(self.syntax.to_owned()) } |
4765 | } | 4343 | } |
4766 | 4344 | ||
4767 | 4345 | ||
4768 | impl ast::LoopBodyOwner for WhileExpr {} | 4346 | impl ast::TypeBoundsOwner for WherePred {} |
4769 | impl WhileExpr { | 4347 | impl WherePred { |
4770 | pub fn condition(&self) -> Option<&Condition> { | 4348 | pub fn type_ref(&self) -> Option<&TypeRef> { |
4771 | super::child_opt(self) | 4349 | super::child_opt(self) |
4772 | } | 4350 | } |
4773 | } | 4351 | } |
4774 | 4352 | ||
4775 | // Whitespace | 4353 | // WhileExpr |
4776 | #[derive(Debug, PartialEq, Eq, Hash)] | 4354 | #[derive(Debug, PartialEq, Eq, Hash)] |
4777 | #[repr(transparent)] | 4355 | #[repr(transparent)] |
4778 | pub struct Whitespace { | 4356 | pub struct WhileExpr { |
4779 | pub(crate) syntax: SyntaxNode, | 4357 | pub(crate) syntax: SyntaxNode, |
4780 | } | 4358 | } |
4781 | unsafe impl TransparentNewType for Whitespace { | 4359 | unsafe impl TransparentNewType for WhileExpr { |
4782 | type Repr = rowan::SyntaxNode<RaTypes>; | 4360 | type Repr = rowan::SyntaxNode<RaTypes>; |
4783 | } | 4361 | } |
4784 | 4362 | ||
4785 | impl AstNode for Whitespace { | 4363 | impl AstNode for WhileExpr { |
4786 | fn cast(syntax: &SyntaxNode) -> Option<&Self> { | 4364 | fn cast(syntax: &SyntaxNode) -> Option<&Self> { |
4787 | match syntax.kind() { | 4365 | match syntax.kind() { |
4788 | WHITESPACE => Some(Whitespace::from_repr(syntax.into_repr())), | 4366 | WHILE_EXPR => Some(WhileExpr::from_repr(syntax.into_repr())), |
4789 | _ => None, | 4367 | _ => None, |
4790 | } | 4368 | } |
4791 | } | 4369 | } |
4792 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 4370 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
4793 | } | 4371 | } |
4794 | 4372 | ||
4795 | impl ToOwned for Whitespace { | 4373 | impl ToOwned for WhileExpr { |
4796 | type Owned = TreeArc<Whitespace>; | 4374 | type Owned = TreeArc<WhileExpr>; |
4797 | fn to_owned(&self) -> TreeArc<Whitespace> { TreeArc::cast(self.syntax.to_owned()) } | 4375 | fn to_owned(&self) -> TreeArc<WhileExpr> { TreeArc::cast(self.syntax.to_owned()) } |
4798 | } | 4376 | } |
4799 | 4377 | ||
4800 | 4378 | ||
4801 | impl ast::AstToken for Whitespace {} | 4379 | impl ast::LoopBodyOwner for WhileExpr {} |
4802 | impl Whitespace {} | 4380 | impl WhileExpr { |
4381 | pub fn condition(&self) -> Option<&Condition> { | ||
4382 | super::child_opt(self) | ||
4383 | } | ||
4384 | } | ||
4803 | 4385 | ||