diff options
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r-- | crates/ra_syntax/src/ast/expr_extensions.rs | 6 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/extensions.rs | 8 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs | 559 |
3 files changed, 304 insertions, 269 deletions
diff --git a/crates/ra_syntax/src/ast/expr_extensions.rs b/crates/ra_syntax/src/ast/expr_extensions.rs index cf5b6f251..d7ea4354d 100644 --- a/crates/ra_syntax/src/ast/expr_extensions.rs +++ b/crates/ra_syntax/src/ast/expr_extensions.rs | |||
@@ -296,8 +296,8 @@ fn test_literal_with_attr() { | |||
296 | assert_eq!(lit.token().text(), r#""Hello""#); | 296 | assert_eq!(lit.token().text(), r#""Hello""#); |
297 | } | 297 | } |
298 | 298 | ||
299 | impl ast::NamedField { | 299 | impl ast::RecordField { |
300 | pub fn parent_struct_lit(&self) -> ast::StructLit { | 300 | pub fn parent_record_lit(&self) -> ast::RecordLit { |
301 | self.syntax().ancestors().find_map(ast::StructLit::cast).unwrap() | 301 | self.syntax().ancestors().find_map(ast::RecordLit::cast).unwrap() |
302 | } | 302 | } |
303 | } | 303 | } |
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs index e0ea3e5ab..d3a375f87 100644 --- a/crates/ra_syntax/src/ast/extensions.rs +++ b/crates/ra_syntax/src/ast/extensions.rs | |||
@@ -195,16 +195,16 @@ impl ast::ImplBlock { | |||
195 | 195 | ||
196 | #[derive(Debug, Clone, PartialEq, Eq)] | 196 | #[derive(Debug, Clone, PartialEq, Eq)] |
197 | pub enum StructKind { | 197 | pub enum StructKind { |
198 | Tuple(ast::PosFieldDefList), | 198 | Tuple(ast::TupleFieldDefList), |
199 | Named(ast::NamedFieldDefList), | 199 | Named(ast::RecordFieldDefList), |
200 | Unit, | 200 | Unit, |
201 | } | 201 | } |
202 | 202 | ||
203 | impl StructKind { | 203 | impl StructKind { |
204 | fn from_node<N: AstNode>(node: &N) -> StructKind { | 204 | fn from_node<N: AstNode>(node: &N) -> StructKind { |
205 | if let Some(nfdl) = child_opt::<_, ast::NamedFieldDefList>(node) { | 205 | if let Some(nfdl) = child_opt::<_, ast::RecordFieldDefList>(node) { |
206 | StructKind::Named(nfdl) | 206 | StructKind::Named(nfdl) |
207 | } else if let Some(pfl) = child_opt::<_, ast::PosFieldDefList>(node) { | 207 | } else if let Some(pfl) = child_opt::<_, ast::TupleFieldDefList>(node) { |
208 | StructKind::Tuple(pfl) | 208 | StructKind::Tuple(pfl) |
209 | } else { | 209 | } else { |
210 | StructKind::Unit | 210 | StructKind::Unit |
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 9c5789701..90480b6ca 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs | |||
@@ -307,6 +307,33 @@ impl BlockExpr { | |||
307 | } | 307 | } |
308 | } | 308 | } |
309 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 309 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
310 | pub struct BoxPat { | ||
311 | pub(crate) syntax: SyntaxNode, | ||
312 | } | ||
313 | impl AstNode for BoxPat { | ||
314 | fn can_cast(kind: SyntaxKind) -> bool { | ||
315 | match kind { | ||
316 | BOX_PAT => true, | ||
317 | _ => false, | ||
318 | } | ||
319 | } | ||
320 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
321 | if Self::can_cast(syntax.kind()) { | ||
322 | Some(Self { syntax }) | ||
323 | } else { | ||
324 | None | ||
325 | } | ||
326 | } | ||
327 | fn syntax(&self) -> &SyntaxNode { | ||
328 | &self.syntax | ||
329 | } | ||
330 | } | ||
331 | impl BoxPat { | ||
332 | pub fn pat(&self) -> Option<Pat> { | ||
333 | AstChildren::new(&self.syntax).next() | ||
334 | } | ||
335 | } | ||
336 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
310 | pub struct BreakExpr { | 337 | pub struct BreakExpr { |
311 | pub(crate) syntax: SyntaxNode, | 338 | pub(crate) syntax: SyntaxNode, |
312 | } | 339 | } |
@@ -607,7 +634,7 @@ pub enum Expr { | |||
607 | BlockExpr(BlockExpr), | 634 | BlockExpr(BlockExpr), |
608 | ReturnExpr(ReturnExpr), | 635 | ReturnExpr(ReturnExpr), |
609 | MatchExpr(MatchExpr), | 636 | MatchExpr(MatchExpr), |
610 | StructLit(StructLit), | 637 | RecordLit(RecordLit), |
611 | CallExpr(CallExpr), | 638 | CallExpr(CallExpr), |
612 | IndexExpr(IndexExpr), | 639 | IndexExpr(IndexExpr), |
613 | MethodCallExpr(MethodCallExpr), | 640 | MethodCallExpr(MethodCallExpr), |
@@ -698,9 +725,9 @@ impl From<MatchExpr> for Expr { | |||
698 | Expr::MatchExpr(node) | 725 | Expr::MatchExpr(node) |
699 | } | 726 | } |
700 | } | 727 | } |
701 | impl From<StructLit> for Expr { | 728 | impl From<RecordLit> for Expr { |
702 | fn from(node: StructLit) -> Expr { | 729 | fn from(node: RecordLit) -> Expr { |
703 | Expr::StructLit(node) | 730 | Expr::RecordLit(node) |
704 | } | 731 | } |
705 | } | 732 | } |
706 | impl From<CallExpr> for Expr { | 733 | impl From<CallExpr> for Expr { |
@@ -778,7 +805,7 @@ impl AstNode for Expr { | |||
778 | match kind { | 805 | match kind { |
779 | TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR | 806 | TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR |
780 | | LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL | 807 | | LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL |
781 | | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | STRUCT_LIT | CALL_EXPR | INDEX_EXPR | 808 | | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | RECORD_LIT | CALL_EXPR | INDEX_EXPR |
782 | | METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | TRY_BLOCK_EXPR | 809 | | METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | TRY_BLOCK_EXPR |
783 | | CAST_EXPR | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL => { | 810 | | CAST_EXPR | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL => { |
784 | true | 811 | true |
@@ -803,7 +830,7 @@ impl AstNode for Expr { | |||
803 | BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }), | 830 | BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }), |
804 | RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }), | 831 | RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }), |
805 | MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }), | 832 | MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }), |
806 | STRUCT_LIT => Expr::StructLit(StructLit { syntax }), | 833 | RECORD_LIT => Expr::RecordLit(RecordLit { syntax }), |
807 | CALL_EXPR => Expr::CallExpr(CallExpr { syntax }), | 834 | CALL_EXPR => Expr::CallExpr(CallExpr { syntax }), |
808 | INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }), | 835 | INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }), |
809 | METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }), | 836 | METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }), |
@@ -839,7 +866,7 @@ impl AstNode for Expr { | |||
839 | Expr::BlockExpr(it) => &it.syntax, | 866 | Expr::BlockExpr(it) => &it.syntax, |
840 | Expr::ReturnExpr(it) => &it.syntax, | 867 | Expr::ReturnExpr(it) => &it.syntax, |
841 | Expr::MatchExpr(it) => &it.syntax, | 868 | Expr::MatchExpr(it) => &it.syntax, |
842 | Expr::StructLit(it) => &it.syntax, | 869 | Expr::RecordLit(it) => &it.syntax, |
843 | Expr::CallExpr(it) => &it.syntax, | 870 | Expr::CallExpr(it) => &it.syntax, |
844 | Expr::IndexExpr(it) => &it.syntax, | 871 | Expr::IndexExpr(it) => &it.syntax, |
845 | Expr::MethodCallExpr(it) => &it.syntax, | 872 | Expr::MethodCallExpr(it) => &it.syntax, |
@@ -946,64 +973,6 @@ impl FieldExpr { | |||
946 | } | 973 | } |
947 | } | 974 | } |
948 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 975 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
949 | pub struct FieldPat { | ||
950 | pub(crate) syntax: SyntaxNode, | ||
951 | } | ||
952 | impl AstNode for FieldPat { | ||
953 | fn can_cast(kind: SyntaxKind) -> bool { | ||
954 | match kind { | ||
955 | FIELD_PAT => true, | ||
956 | _ => false, | ||
957 | } | ||
958 | } | ||
959 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
960 | if Self::can_cast(syntax.kind()) { | ||
961 | Some(Self { syntax }) | ||
962 | } else { | ||
963 | None | ||
964 | } | ||
965 | } | ||
966 | fn syntax(&self) -> &SyntaxNode { | ||
967 | &self.syntax | ||
968 | } | ||
969 | } | ||
970 | impl ast::NameOwner for FieldPat {} | ||
971 | impl FieldPat { | ||
972 | pub fn pat(&self) -> Option<Pat> { | ||
973 | AstChildren::new(&self.syntax).next() | ||
974 | } | ||
975 | } | ||
976 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
977 | pub struct FieldPatList { | ||
978 | pub(crate) syntax: SyntaxNode, | ||
979 | } | ||
980 | impl AstNode for FieldPatList { | ||
981 | fn can_cast(kind: SyntaxKind) -> bool { | ||
982 | match kind { | ||
983 | FIELD_PAT_LIST => true, | ||
984 | _ => false, | ||
985 | } | ||
986 | } | ||
987 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
988 | if Self::can_cast(syntax.kind()) { | ||
989 | Some(Self { syntax }) | ||
990 | } else { | ||
991 | None | ||
992 | } | ||
993 | } | ||
994 | fn syntax(&self) -> &SyntaxNode { | ||
995 | &self.syntax | ||
996 | } | ||
997 | } | ||
998 | impl FieldPatList { | ||
999 | pub fn field_pats(&self) -> AstChildren<FieldPat> { | ||
1000 | AstChildren::new(&self.syntax) | ||
1001 | } | ||
1002 | pub fn bind_pats(&self) -> AstChildren<BindPat> { | ||
1003 | AstChildren::new(&self.syntax) | ||
1004 | } | ||
1005 | } | ||
1006 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1007 | pub struct FnDef { | 976 | pub struct FnDef { |
1008 | pub(crate) syntax: SyntaxNode, | 977 | pub(crate) syntax: SyntaxNode, |
1009 | } | 978 | } |
@@ -1942,121 +1911,6 @@ impl AstNode for NameRef { | |||
1942 | } | 1911 | } |
1943 | impl NameRef {} | 1912 | impl NameRef {} |
1944 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1913 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1945 | pub struct NamedField { | ||
1946 | pub(crate) syntax: SyntaxNode, | ||
1947 | } | ||
1948 | impl AstNode for NamedField { | ||
1949 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1950 | match kind { | ||
1951 | NAMED_FIELD => true, | ||
1952 | _ => false, | ||
1953 | } | ||
1954 | } | ||
1955 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1956 | if Self::can_cast(syntax.kind()) { | ||
1957 | Some(Self { syntax }) | ||
1958 | } else { | ||
1959 | None | ||
1960 | } | ||
1961 | } | ||
1962 | fn syntax(&self) -> &SyntaxNode { | ||
1963 | &self.syntax | ||
1964 | } | ||
1965 | } | ||
1966 | impl NamedField { | ||
1967 | pub fn name_ref(&self) -> Option<NameRef> { | ||
1968 | AstChildren::new(&self.syntax).next() | ||
1969 | } | ||
1970 | pub fn expr(&self) -> Option<Expr> { | ||
1971 | AstChildren::new(&self.syntax).next() | ||
1972 | } | ||
1973 | } | ||
1974 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1975 | pub struct NamedFieldDef { | ||
1976 | pub(crate) syntax: SyntaxNode, | ||
1977 | } | ||
1978 | impl AstNode for NamedFieldDef { | ||
1979 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1980 | match kind { | ||
1981 | NAMED_FIELD_DEF => true, | ||
1982 | _ => false, | ||
1983 | } | ||
1984 | } | ||
1985 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1986 | if Self::can_cast(syntax.kind()) { | ||
1987 | Some(Self { syntax }) | ||
1988 | } else { | ||
1989 | None | ||
1990 | } | ||
1991 | } | ||
1992 | fn syntax(&self) -> &SyntaxNode { | ||
1993 | &self.syntax | ||
1994 | } | ||
1995 | } | ||
1996 | impl ast::VisibilityOwner for NamedFieldDef {} | ||
1997 | impl ast::NameOwner for NamedFieldDef {} | ||
1998 | impl ast::AttrsOwner for NamedFieldDef {} | ||
1999 | impl ast::DocCommentsOwner for NamedFieldDef {} | ||
2000 | impl ast::TypeAscriptionOwner for NamedFieldDef {} | ||
2001 | impl NamedFieldDef {} | ||
2002 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2003 | pub struct NamedFieldDefList { | ||
2004 | pub(crate) syntax: SyntaxNode, | ||
2005 | } | ||
2006 | impl AstNode for NamedFieldDefList { | ||
2007 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2008 | match kind { | ||
2009 | NAMED_FIELD_DEF_LIST => true, | ||
2010 | _ => false, | ||
2011 | } | ||
2012 | } | ||
2013 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2014 | if Self::can_cast(syntax.kind()) { | ||
2015 | Some(Self { syntax }) | ||
2016 | } else { | ||
2017 | None | ||
2018 | } | ||
2019 | } | ||
2020 | fn syntax(&self) -> &SyntaxNode { | ||
2021 | &self.syntax | ||
2022 | } | ||
2023 | } | ||
2024 | impl NamedFieldDefList { | ||
2025 | pub fn fields(&self) -> AstChildren<NamedFieldDef> { | ||
2026 | AstChildren::new(&self.syntax) | ||
2027 | } | ||
2028 | } | ||
2029 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2030 | pub struct NamedFieldList { | ||
2031 | pub(crate) syntax: SyntaxNode, | ||
2032 | } | ||
2033 | impl AstNode for NamedFieldList { | ||
2034 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2035 | match kind { | ||
2036 | NAMED_FIELD_LIST => true, | ||
2037 | _ => false, | ||
2038 | } | ||
2039 | } | ||
2040 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2041 | if Self::can_cast(syntax.kind()) { | ||
2042 | Some(Self { syntax }) | ||
2043 | } else { | ||
2044 | None | ||
2045 | } | ||
2046 | } | ||
2047 | fn syntax(&self) -> &SyntaxNode { | ||
2048 | &self.syntax | ||
2049 | } | ||
2050 | } | ||
2051 | impl NamedFieldList { | ||
2052 | pub fn fields(&self) -> AstChildren<NamedField> { | ||
2053 | AstChildren::new(&self.syntax) | ||
2054 | } | ||
2055 | pub fn spread(&self) -> Option<Expr> { | ||
2056 | AstChildren::new(&self.syntax).next() | ||
2057 | } | ||
2058 | } | ||
2059 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2060 | pub struct NeverType { | 1914 | pub struct NeverType { |
2061 | pub(crate) syntax: SyntaxNode, | 1915 | pub(crate) syntax: SyntaxNode, |
2062 | } | 1916 | } |
@@ -2236,10 +2090,11 @@ impl ParenType { | |||
2236 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2090 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
2237 | pub enum Pat { | 2091 | pub enum Pat { |
2238 | RefPat(RefPat), | 2092 | RefPat(RefPat), |
2093 | BoxPat(BoxPat), | ||
2239 | BindPat(BindPat), | 2094 | BindPat(BindPat), |
2240 | PlaceholderPat(PlaceholderPat), | 2095 | PlaceholderPat(PlaceholderPat), |
2241 | PathPat(PathPat), | 2096 | PathPat(PathPat), |
2242 | StructPat(StructPat), | 2097 | RecordPat(RecordPat), |
2243 | TupleStructPat(TupleStructPat), | 2098 | TupleStructPat(TupleStructPat), |
2244 | TuplePat(TuplePat), | 2099 | TuplePat(TuplePat), |
2245 | SlicePat(SlicePat), | 2100 | SlicePat(SlicePat), |
@@ -2251,6 +2106,11 @@ impl From<RefPat> for Pat { | |||
2251 | Pat::RefPat(node) | 2106 | Pat::RefPat(node) |
2252 | } | 2107 | } |
2253 | } | 2108 | } |
2109 | impl From<BoxPat> for Pat { | ||
2110 | fn from(node: BoxPat) -> Pat { | ||
2111 | Pat::BoxPat(node) | ||
2112 | } | ||
2113 | } | ||
2254 | impl From<BindPat> for Pat { | 2114 | impl From<BindPat> for Pat { |
2255 | fn from(node: BindPat) -> Pat { | 2115 | fn from(node: BindPat) -> Pat { |
2256 | Pat::BindPat(node) | 2116 | Pat::BindPat(node) |
@@ -2266,9 +2126,9 @@ impl From<PathPat> for Pat { | |||
2266 | Pat::PathPat(node) | 2126 | Pat::PathPat(node) |
2267 | } | 2127 | } |
2268 | } | 2128 | } |
2269 | impl From<StructPat> for Pat { | 2129 | impl From<RecordPat> for Pat { |
2270 | fn from(node: StructPat) -> Pat { | 2130 | fn from(node: RecordPat) -> Pat { |
2271 | Pat::StructPat(node) | 2131 | Pat::RecordPat(node) |
2272 | } | 2132 | } |
2273 | } | 2133 | } |
2274 | impl From<TupleStructPat> for Pat { | 2134 | impl From<TupleStructPat> for Pat { |
@@ -2299,18 +2159,19 @@ impl From<LiteralPat> for Pat { | |||
2299 | impl AstNode for Pat { | 2159 | impl AstNode for Pat { |
2300 | fn can_cast(kind: SyntaxKind) -> bool { | 2160 | fn can_cast(kind: SyntaxKind) -> bool { |
2301 | match kind { | 2161 | match kind { |
2302 | REF_PAT | BIND_PAT | PLACEHOLDER_PAT | PATH_PAT | STRUCT_PAT | TUPLE_STRUCT_PAT | 2162 | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | PATH_PAT | RECORD_PAT |
2303 | | TUPLE_PAT | SLICE_PAT | RANGE_PAT | LITERAL_PAT => true, | 2163 | | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT | LITERAL_PAT => true, |
2304 | _ => false, | 2164 | _ => false, |
2305 | } | 2165 | } |
2306 | } | 2166 | } |
2307 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2167 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
2308 | let res = match syntax.kind() { | 2168 | let res = match syntax.kind() { |
2309 | REF_PAT => Pat::RefPat(RefPat { syntax }), | 2169 | REF_PAT => Pat::RefPat(RefPat { syntax }), |
2170 | BOX_PAT => Pat::BoxPat(BoxPat { syntax }), | ||
2310 | BIND_PAT => Pat::BindPat(BindPat { syntax }), | 2171 | BIND_PAT => Pat::BindPat(BindPat { syntax }), |
2311 | PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }), | 2172 | PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }), |
2312 | PATH_PAT => Pat::PathPat(PathPat { syntax }), | 2173 | PATH_PAT => Pat::PathPat(PathPat { syntax }), |
2313 | STRUCT_PAT => Pat::StructPat(StructPat { syntax }), | 2174 | RECORD_PAT => Pat::RecordPat(RecordPat { syntax }), |
2314 | TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }), | 2175 | TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }), |
2315 | TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }), | 2176 | TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }), |
2316 | SLICE_PAT => Pat::SlicePat(SlicePat { syntax }), | 2177 | SLICE_PAT => Pat::SlicePat(SlicePat { syntax }), |
@@ -2323,10 +2184,11 @@ impl AstNode for Pat { | |||
2323 | fn syntax(&self) -> &SyntaxNode { | 2184 | fn syntax(&self) -> &SyntaxNode { |
2324 | match self { | 2185 | match self { |
2325 | Pat::RefPat(it) => &it.syntax, | 2186 | Pat::RefPat(it) => &it.syntax, |
2187 | Pat::BoxPat(it) => &it.syntax, | ||
2326 | Pat::BindPat(it) => &it.syntax, | 2188 | Pat::BindPat(it) => &it.syntax, |
2327 | Pat::PlaceholderPat(it) => &it.syntax, | 2189 | Pat::PlaceholderPat(it) => &it.syntax, |
2328 | Pat::PathPat(it) => &it.syntax, | 2190 | Pat::PathPat(it) => &it.syntax, |
2329 | Pat::StructPat(it) => &it.syntax, | 2191 | Pat::RecordPat(it) => &it.syntax, |
2330 | Pat::TupleStructPat(it) => &it.syntax, | 2192 | Pat::TupleStructPat(it) => &it.syntax, |
2331 | Pat::TuplePat(it) => &it.syntax, | 2193 | Pat::TuplePat(it) => &it.syntax, |
2332 | Pat::SlicePat(it) => &it.syntax, | 2194 | Pat::SlicePat(it) => &it.syntax, |
@@ -2551,13 +2413,13 @@ impl PointerType { | |||
2551 | } | 2413 | } |
2552 | } | 2414 | } |
2553 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2415 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
2554 | pub struct PosFieldDef { | 2416 | pub struct PrefixExpr { |
2555 | pub(crate) syntax: SyntaxNode, | 2417 | pub(crate) syntax: SyntaxNode, |
2556 | } | 2418 | } |
2557 | impl AstNode for PosFieldDef { | 2419 | impl AstNode for PrefixExpr { |
2558 | fn can_cast(kind: SyntaxKind) -> bool { | 2420 | fn can_cast(kind: SyntaxKind) -> bool { |
2559 | match kind { | 2421 | match kind { |
2560 | POS_FIELD_DEF => true, | 2422 | PREFIX_EXPR => true, |
2561 | _ => false, | 2423 | _ => false, |
2562 | } | 2424 | } |
2563 | } | 2425 | } |
@@ -2572,21 +2434,19 @@ impl AstNode for PosFieldDef { | |||
2572 | &self.syntax | 2434 | &self.syntax |
2573 | } | 2435 | } |
2574 | } | 2436 | } |
2575 | impl ast::VisibilityOwner for PosFieldDef {} | 2437 | impl PrefixExpr { |
2576 | impl ast::AttrsOwner for PosFieldDef {} | 2438 | pub fn expr(&self) -> Option<Expr> { |
2577 | impl PosFieldDef { | ||
2578 | pub fn type_ref(&self) -> Option<TypeRef> { | ||
2579 | AstChildren::new(&self.syntax).next() | 2439 | AstChildren::new(&self.syntax).next() |
2580 | } | 2440 | } |
2581 | } | 2441 | } |
2582 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2442 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
2583 | pub struct PosFieldDefList { | 2443 | pub struct RangeExpr { |
2584 | pub(crate) syntax: SyntaxNode, | 2444 | pub(crate) syntax: SyntaxNode, |
2585 | } | 2445 | } |
2586 | impl AstNode for PosFieldDefList { | 2446 | impl AstNode for RangeExpr { |
2587 | fn can_cast(kind: SyntaxKind) -> bool { | 2447 | fn can_cast(kind: SyntaxKind) -> bool { |
2588 | match kind { | 2448 | match kind { |
2589 | POS_FIELD_DEF_LIST => true, | 2449 | RANGE_EXPR => true, |
2590 | _ => false, | 2450 | _ => false, |
2591 | } | 2451 | } |
2592 | } | 2452 | } |
@@ -2601,19 +2461,38 @@ impl AstNode for PosFieldDefList { | |||
2601 | &self.syntax | 2461 | &self.syntax |
2602 | } | 2462 | } |
2603 | } | 2463 | } |
2604 | impl PosFieldDefList { | 2464 | impl RangeExpr {} |
2605 | pub fn fields(&self) -> AstChildren<PosFieldDef> { | 2465 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
2606 | AstChildren::new(&self.syntax) | 2466 | pub struct RangePat { |
2467 | pub(crate) syntax: SyntaxNode, | ||
2468 | } | ||
2469 | impl AstNode for RangePat { | ||
2470 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2471 | match kind { | ||
2472 | RANGE_PAT => true, | ||
2473 | _ => false, | ||
2474 | } | ||
2475 | } | ||
2476 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2477 | if Self::can_cast(syntax.kind()) { | ||
2478 | Some(Self { syntax }) | ||
2479 | } else { | ||
2480 | None | ||
2481 | } | ||
2482 | } | ||
2483 | fn syntax(&self) -> &SyntaxNode { | ||
2484 | &self.syntax | ||
2607 | } | 2485 | } |
2608 | } | 2486 | } |
2487 | impl RangePat {} | ||
2609 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2488 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
2610 | pub struct PrefixExpr { | 2489 | pub struct RecordField { |
2611 | pub(crate) syntax: SyntaxNode, | 2490 | pub(crate) syntax: SyntaxNode, |
2612 | } | 2491 | } |
2613 | impl AstNode for PrefixExpr { | 2492 | impl AstNode for RecordField { |
2614 | fn can_cast(kind: SyntaxKind) -> bool { | 2493 | fn can_cast(kind: SyntaxKind) -> bool { |
2615 | match kind { | 2494 | match kind { |
2616 | PREFIX_EXPR => true, | 2495 | RECORD_FIELD => true, |
2617 | _ => false, | 2496 | _ => false, |
2618 | } | 2497 | } |
2619 | } | 2498 | } |
@@ -2628,19 +2507,22 @@ impl AstNode for PrefixExpr { | |||
2628 | &self.syntax | 2507 | &self.syntax |
2629 | } | 2508 | } |
2630 | } | 2509 | } |
2631 | impl PrefixExpr { | 2510 | impl RecordField { |
2511 | pub fn name_ref(&self) -> Option<NameRef> { | ||
2512 | AstChildren::new(&self.syntax).next() | ||
2513 | } | ||
2632 | pub fn expr(&self) -> Option<Expr> { | 2514 | pub fn expr(&self) -> Option<Expr> { |
2633 | AstChildren::new(&self.syntax).next() | 2515 | AstChildren::new(&self.syntax).next() |
2634 | } | 2516 | } |
2635 | } | 2517 | } |
2636 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2518 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
2637 | pub struct RangeExpr { | 2519 | pub struct RecordFieldDef { |
2638 | pub(crate) syntax: SyntaxNode, | 2520 | pub(crate) syntax: SyntaxNode, |
2639 | } | 2521 | } |
2640 | impl AstNode for RangeExpr { | 2522 | impl AstNode for RecordFieldDef { |
2641 | fn can_cast(kind: SyntaxKind) -> bool { | 2523 | fn can_cast(kind: SyntaxKind) -> bool { |
2642 | match kind { | 2524 | match kind { |
2643 | RANGE_EXPR => true, | 2525 | RECORD_FIELD_DEF => true, |
2644 | _ => false, | 2526 | _ => false, |
2645 | } | 2527 | } |
2646 | } | 2528 | } |
@@ -2655,15 +2537,20 @@ impl AstNode for RangeExpr { | |||
2655 | &self.syntax | 2537 | &self.syntax |
2656 | } | 2538 | } |
2657 | } | 2539 | } |
2658 | impl RangeExpr {} | 2540 | impl ast::VisibilityOwner for RecordFieldDef {} |
2541 | impl ast::NameOwner for RecordFieldDef {} | ||
2542 | impl ast::AttrsOwner for RecordFieldDef {} | ||
2543 | impl ast::DocCommentsOwner for RecordFieldDef {} | ||
2544 | impl ast::TypeAscriptionOwner for RecordFieldDef {} | ||
2545 | impl RecordFieldDef {} | ||
2659 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2546 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
2660 | pub struct RangePat { | 2547 | pub struct RecordFieldDefList { |
2661 | pub(crate) syntax: SyntaxNode, | 2548 | pub(crate) syntax: SyntaxNode, |
2662 | } | 2549 | } |
2663 | impl AstNode for RangePat { | 2550 | impl AstNode for RecordFieldDefList { |
2664 | fn can_cast(kind: SyntaxKind) -> bool { | 2551 | fn can_cast(kind: SyntaxKind) -> bool { |
2665 | match kind { | 2552 | match kind { |
2666 | RANGE_PAT => true, | 2553 | RECORD_FIELD_DEF_LIST => true, |
2667 | _ => false, | 2554 | _ => false, |
2668 | } | 2555 | } |
2669 | } | 2556 | } |
@@ -2678,7 +2565,159 @@ impl AstNode for RangePat { | |||
2678 | &self.syntax | 2565 | &self.syntax |
2679 | } | 2566 | } |
2680 | } | 2567 | } |
2681 | impl RangePat {} | 2568 | impl RecordFieldDefList { |
2569 | pub fn fields(&self) -> AstChildren<RecordFieldDef> { | ||
2570 | AstChildren::new(&self.syntax) | ||
2571 | } | ||
2572 | } | ||
2573 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2574 | pub struct RecordFieldList { | ||
2575 | pub(crate) syntax: SyntaxNode, | ||
2576 | } | ||
2577 | impl AstNode for RecordFieldList { | ||
2578 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2579 | match kind { | ||
2580 | RECORD_FIELD_LIST => true, | ||
2581 | _ => false, | ||
2582 | } | ||
2583 | } | ||
2584 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2585 | if Self::can_cast(syntax.kind()) { | ||
2586 | Some(Self { syntax }) | ||
2587 | } else { | ||
2588 | None | ||
2589 | } | ||
2590 | } | ||
2591 | fn syntax(&self) -> &SyntaxNode { | ||
2592 | &self.syntax | ||
2593 | } | ||
2594 | } | ||
2595 | impl RecordFieldList { | ||
2596 | pub fn fields(&self) -> AstChildren<RecordField> { | ||
2597 | AstChildren::new(&self.syntax) | ||
2598 | } | ||
2599 | pub fn spread(&self) -> Option<Expr> { | ||
2600 | AstChildren::new(&self.syntax).next() | ||
2601 | } | ||
2602 | } | ||
2603 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2604 | pub struct RecordFieldPat { | ||
2605 | pub(crate) syntax: SyntaxNode, | ||
2606 | } | ||
2607 | impl AstNode for RecordFieldPat { | ||
2608 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2609 | match kind { | ||
2610 | RECORD_FIELD_PAT => true, | ||
2611 | _ => false, | ||
2612 | } | ||
2613 | } | ||
2614 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2615 | if Self::can_cast(syntax.kind()) { | ||
2616 | Some(Self { syntax }) | ||
2617 | } else { | ||
2618 | None | ||
2619 | } | ||
2620 | } | ||
2621 | fn syntax(&self) -> &SyntaxNode { | ||
2622 | &self.syntax | ||
2623 | } | ||
2624 | } | ||
2625 | impl ast::NameOwner for RecordFieldPat {} | ||
2626 | impl RecordFieldPat { | ||
2627 | pub fn pat(&self) -> Option<Pat> { | ||
2628 | AstChildren::new(&self.syntax).next() | ||
2629 | } | ||
2630 | } | ||
2631 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2632 | pub struct RecordFieldPatList { | ||
2633 | pub(crate) syntax: SyntaxNode, | ||
2634 | } | ||
2635 | impl AstNode for RecordFieldPatList { | ||
2636 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2637 | match kind { | ||
2638 | RECORD_FIELD_PAT_LIST => true, | ||
2639 | _ => false, | ||
2640 | } | ||
2641 | } | ||
2642 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2643 | if Self::can_cast(syntax.kind()) { | ||
2644 | Some(Self { syntax }) | ||
2645 | } else { | ||
2646 | None | ||
2647 | } | ||
2648 | } | ||
2649 | fn syntax(&self) -> &SyntaxNode { | ||
2650 | &self.syntax | ||
2651 | } | ||
2652 | } | ||
2653 | impl RecordFieldPatList { | ||
2654 | pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> { | ||
2655 | AstChildren::new(&self.syntax) | ||
2656 | } | ||
2657 | pub fn bind_pats(&self) -> AstChildren<BindPat> { | ||
2658 | AstChildren::new(&self.syntax) | ||
2659 | } | ||
2660 | } | ||
2661 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2662 | pub struct RecordLit { | ||
2663 | pub(crate) syntax: SyntaxNode, | ||
2664 | } | ||
2665 | impl AstNode for RecordLit { | ||
2666 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2667 | match kind { | ||
2668 | RECORD_LIT => true, | ||
2669 | _ => false, | ||
2670 | } | ||
2671 | } | ||
2672 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2673 | if Self::can_cast(syntax.kind()) { | ||
2674 | Some(Self { syntax }) | ||
2675 | } else { | ||
2676 | None | ||
2677 | } | ||
2678 | } | ||
2679 | fn syntax(&self) -> &SyntaxNode { | ||
2680 | &self.syntax | ||
2681 | } | ||
2682 | } | ||
2683 | impl RecordLit { | ||
2684 | pub fn path(&self) -> Option<Path> { | ||
2685 | AstChildren::new(&self.syntax).next() | ||
2686 | } | ||
2687 | pub fn record_field_list(&self) -> Option<RecordFieldList> { | ||
2688 | AstChildren::new(&self.syntax).next() | ||
2689 | } | ||
2690 | } | ||
2691 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2692 | pub struct RecordPat { | ||
2693 | pub(crate) syntax: SyntaxNode, | ||
2694 | } | ||
2695 | impl AstNode for RecordPat { | ||
2696 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2697 | match kind { | ||
2698 | RECORD_PAT => true, | ||
2699 | _ => false, | ||
2700 | } | ||
2701 | } | ||
2702 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2703 | if Self::can_cast(syntax.kind()) { | ||
2704 | Some(Self { syntax }) | ||
2705 | } else { | ||
2706 | None | ||
2707 | } | ||
2708 | } | ||
2709 | fn syntax(&self) -> &SyntaxNode { | ||
2710 | &self.syntax | ||
2711 | } | ||
2712 | } | ||
2713 | impl RecordPat { | ||
2714 | pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> { | ||
2715 | AstChildren::new(&self.syntax).next() | ||
2716 | } | ||
2717 | pub fn path(&self) -> Option<Path> { | ||
2718 | AstChildren::new(&self.syntax).next() | ||
2719 | } | ||
2720 | } | ||
2682 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2721 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
2683 | pub struct RefExpr { | 2722 | pub struct RefExpr { |
2684 | pub(crate) syntax: SyntaxNode, | 2723 | pub(crate) syntax: SyntaxNode, |
@@ -3018,13 +3057,13 @@ impl ast::AttrsOwner for StructDef {} | |||
3018 | impl ast::DocCommentsOwner for StructDef {} | 3057 | impl ast::DocCommentsOwner for StructDef {} |
3019 | impl StructDef {} | 3058 | impl StructDef {} |
3020 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 3059 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
3021 | pub struct StructLit { | 3060 | pub struct TokenTree { |
3022 | pub(crate) syntax: SyntaxNode, | 3061 | pub(crate) syntax: SyntaxNode, |
3023 | } | 3062 | } |
3024 | impl AstNode for StructLit { | 3063 | impl AstNode for TokenTree { |
3025 | fn can_cast(kind: SyntaxKind) -> bool { | 3064 | fn can_cast(kind: SyntaxKind) -> bool { |
3026 | match kind { | 3065 | match kind { |
3027 | STRUCT_LIT => true, | 3066 | TOKEN_TREE => true, |
3028 | _ => false, | 3067 | _ => false, |
3029 | } | 3068 | } |
3030 | } | 3069 | } |
@@ -3039,22 +3078,15 @@ impl AstNode for StructLit { | |||
3039 | &self.syntax | 3078 | &self.syntax |
3040 | } | 3079 | } |
3041 | } | 3080 | } |
3042 | impl StructLit { | 3081 | impl TokenTree {} |
3043 | pub fn path(&self) -> Option<Path> { | ||
3044 | AstChildren::new(&self.syntax).next() | ||
3045 | } | ||
3046 | pub fn named_field_list(&self) -> Option<NamedFieldList> { | ||
3047 | AstChildren::new(&self.syntax).next() | ||
3048 | } | ||
3049 | } | ||
3050 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 3082 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
3051 | pub struct StructPat { | 3083 | pub struct TraitDef { |
3052 | pub(crate) syntax: SyntaxNode, | 3084 | pub(crate) syntax: SyntaxNode, |
3053 | } | 3085 | } |
3054 | impl AstNode for StructPat { | 3086 | impl AstNode for TraitDef { |
3055 | fn can_cast(kind: SyntaxKind) -> bool { | 3087 | fn can_cast(kind: SyntaxKind) -> bool { |
3056 | match kind { | 3088 | match kind { |
3057 | STRUCT_PAT => true, | 3089 | TRAIT_DEF => true, |
3058 | _ => false, | 3090 | _ => false, |
3059 | } | 3091 | } |
3060 | } | 3092 | } |
@@ -3069,22 +3101,25 @@ impl AstNode for StructPat { | |||
3069 | &self.syntax | 3101 | &self.syntax |
3070 | } | 3102 | } |
3071 | } | 3103 | } |
3072 | impl StructPat { | 3104 | impl ast::VisibilityOwner for TraitDef {} |
3073 | pub fn field_pat_list(&self) -> Option<FieldPatList> { | 3105 | impl ast::NameOwner for TraitDef {} |
3074 | AstChildren::new(&self.syntax).next() | 3106 | impl ast::AttrsOwner for TraitDef {} |
3075 | } | 3107 | impl ast::DocCommentsOwner for TraitDef {} |
3076 | pub fn path(&self) -> Option<Path> { | 3108 | impl ast::TypeParamsOwner for TraitDef {} |
3109 | impl ast::TypeBoundsOwner for TraitDef {} | ||
3110 | impl TraitDef { | ||
3111 | pub fn item_list(&self) -> Option<ItemList> { | ||
3077 | AstChildren::new(&self.syntax).next() | 3112 | AstChildren::new(&self.syntax).next() |
3078 | } | 3113 | } |
3079 | } | 3114 | } |
3080 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 3115 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
3081 | pub struct TokenTree { | 3116 | pub struct TryBlockExpr { |
3082 | pub(crate) syntax: SyntaxNode, | 3117 | pub(crate) syntax: SyntaxNode, |
3083 | } | 3118 | } |
3084 | impl AstNode for TokenTree { | 3119 | impl AstNode for TryBlockExpr { |
3085 | fn can_cast(kind: SyntaxKind) -> bool { | 3120 | fn can_cast(kind: SyntaxKind) -> bool { |
3086 | match kind { | 3121 | match kind { |
3087 | TOKEN_TREE => true, | 3122 | TRY_BLOCK_EXPR => true, |
3088 | _ => false, | 3123 | _ => false, |
3089 | } | 3124 | } |
3090 | } | 3125 | } |
@@ -3099,15 +3134,16 @@ impl AstNode for TokenTree { | |||
3099 | &self.syntax | 3134 | &self.syntax |
3100 | } | 3135 | } |
3101 | } | 3136 | } |
3102 | impl TokenTree {} | 3137 | impl ast::TryBlockBodyOwner for TryBlockExpr {} |
3138 | impl TryBlockExpr {} | ||
3103 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 3139 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
3104 | pub struct TraitDef { | 3140 | pub struct TryExpr { |
3105 | pub(crate) syntax: SyntaxNode, | 3141 | pub(crate) syntax: SyntaxNode, |
3106 | } | 3142 | } |
3107 | impl AstNode for TraitDef { | 3143 | impl AstNode for TryExpr { |
3108 | fn can_cast(kind: SyntaxKind) -> bool { | 3144 | fn can_cast(kind: SyntaxKind) -> bool { |
3109 | match kind { | 3145 | match kind { |
3110 | TRAIT_DEF => true, | 3146 | TRY_EXPR => true, |
3111 | _ => false, | 3147 | _ => false, |
3112 | } | 3148 | } |
3113 | } | 3149 | } |
@@ -3122,25 +3158,19 @@ impl AstNode for TraitDef { | |||
3122 | &self.syntax | 3158 | &self.syntax |
3123 | } | 3159 | } |
3124 | } | 3160 | } |
3125 | impl ast::VisibilityOwner for TraitDef {} | 3161 | impl TryExpr { |
3126 | impl ast::NameOwner for TraitDef {} | 3162 | pub fn expr(&self) -> Option<Expr> { |
3127 | impl ast::AttrsOwner for TraitDef {} | ||
3128 | impl ast::DocCommentsOwner for TraitDef {} | ||
3129 | impl ast::TypeParamsOwner for TraitDef {} | ||
3130 | impl ast::TypeBoundsOwner for TraitDef {} | ||
3131 | impl TraitDef { | ||
3132 | pub fn item_list(&self) -> Option<ItemList> { | ||
3133 | AstChildren::new(&self.syntax).next() | 3163 | AstChildren::new(&self.syntax).next() |
3134 | } | 3164 | } |
3135 | } | 3165 | } |
3136 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 3166 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
3137 | pub struct TryBlockExpr { | 3167 | pub struct TupleExpr { |
3138 | pub(crate) syntax: SyntaxNode, | 3168 | pub(crate) syntax: SyntaxNode, |
3139 | } | 3169 | } |
3140 | impl AstNode for TryBlockExpr { | 3170 | impl AstNode for TupleExpr { |
3141 | fn can_cast(kind: SyntaxKind) -> bool { | 3171 | fn can_cast(kind: SyntaxKind) -> bool { |
3142 | match kind { | 3172 | match kind { |
3143 | TRY_BLOCK_EXPR => true, | 3173 | TUPLE_EXPR => true, |
3144 | _ => false, | 3174 | _ => false, |
3145 | } | 3175 | } |
3146 | } | 3176 | } |
@@ -3155,16 +3185,19 @@ impl AstNode for TryBlockExpr { | |||
3155 | &self.syntax | 3185 | &self.syntax |
3156 | } | 3186 | } |
3157 | } | 3187 | } |
3158 | impl ast::TryBlockBodyOwner for TryBlockExpr {} | 3188 | impl TupleExpr { |
3159 | impl TryBlockExpr {} | 3189 | pub fn exprs(&self) -> AstChildren<Expr> { |
3190 | AstChildren::new(&self.syntax) | ||
3191 | } | ||
3192 | } | ||
3160 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 3193 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
3161 | pub struct TryExpr { | 3194 | pub struct TupleFieldDef { |
3162 | pub(crate) syntax: SyntaxNode, | 3195 | pub(crate) syntax: SyntaxNode, |
3163 | } | 3196 | } |
3164 | impl AstNode for TryExpr { | 3197 | impl AstNode for TupleFieldDef { |
3165 | fn can_cast(kind: SyntaxKind) -> bool { | 3198 | fn can_cast(kind: SyntaxKind) -> bool { |
3166 | match kind { | 3199 | match kind { |
3167 | TRY_EXPR => true, | 3200 | TUPLE_FIELD_DEF => true, |
3168 | _ => false, | 3201 | _ => false, |
3169 | } | 3202 | } |
3170 | } | 3203 | } |
@@ -3179,19 +3212,21 @@ impl AstNode for TryExpr { | |||
3179 | &self.syntax | 3212 | &self.syntax |
3180 | } | 3213 | } |
3181 | } | 3214 | } |
3182 | impl TryExpr { | 3215 | impl ast::VisibilityOwner for TupleFieldDef {} |
3183 | pub fn expr(&self) -> Option<Expr> { | 3216 | impl ast::AttrsOwner for TupleFieldDef {} |
3217 | impl TupleFieldDef { | ||
3218 | pub fn type_ref(&self) -> Option<TypeRef> { | ||
3184 | AstChildren::new(&self.syntax).next() | 3219 | AstChildren::new(&self.syntax).next() |
3185 | } | 3220 | } |
3186 | } | 3221 | } |
3187 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 3222 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
3188 | pub struct TupleExpr { | 3223 | pub struct TupleFieldDefList { |
3189 | pub(crate) syntax: SyntaxNode, | 3224 | pub(crate) syntax: SyntaxNode, |
3190 | } | 3225 | } |
3191 | impl AstNode for TupleExpr { | 3226 | impl AstNode for TupleFieldDefList { |
3192 | fn can_cast(kind: SyntaxKind) -> bool { | 3227 | fn can_cast(kind: SyntaxKind) -> bool { |
3193 | match kind { | 3228 | match kind { |
3194 | TUPLE_EXPR => true, | 3229 | TUPLE_FIELD_DEF_LIST => true, |
3195 | _ => false, | 3230 | _ => false, |
3196 | } | 3231 | } |
3197 | } | 3232 | } |
@@ -3206,8 +3241,8 @@ impl AstNode for TupleExpr { | |||
3206 | &self.syntax | 3241 | &self.syntax |
3207 | } | 3242 | } |
3208 | } | 3243 | } |
3209 | impl TupleExpr { | 3244 | impl TupleFieldDefList { |
3210 | pub fn exprs(&self) -> AstChildren<Expr> { | 3245 | pub fn fields(&self) -> AstChildren<TupleFieldDef> { |
3211 | AstChildren::new(&self.syntax) | 3246 | AstChildren::new(&self.syntax) |
3212 | } | 3247 | } |
3213 | } | 3248 | } |