aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-08-23 13:55:21 +0100
committerAleksey Kladov <[email protected]>2019-08-23 14:59:50 +0100
commit5b18a4eef9e69260ce2f105b33553c929cb7d827 (patch)
tree15f55b3eab48c3d0bbb1975fbd4db7cbb56d3e3e /crates/ra_syntax/src/ast
parentc12dce0073c1766f7d2b10a69f8526a8093e70dc (diff)
rename struct -> record, pos -> tuple
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r--crates/ra_syntax/src/ast/expr_extensions.rs6
-rw-r--r--crates/ra_syntax/src/ast/extensions.rs8
-rw-r--r--crates/ra_syntax/src/ast/generated.rs522
3 files changed, 268 insertions, 268 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
299impl ast::NamedField { 299impl 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)]
197pub enum StructKind { 197pub 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
203impl StructKind { 203impl 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..07cc3e0db 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -607,7 +607,7 @@ pub enum Expr {
607 BlockExpr(BlockExpr), 607 BlockExpr(BlockExpr),
608 ReturnExpr(ReturnExpr), 608 ReturnExpr(ReturnExpr),
609 MatchExpr(MatchExpr), 609 MatchExpr(MatchExpr),
610 StructLit(StructLit), 610 RecordLit(RecordLit),
611 CallExpr(CallExpr), 611 CallExpr(CallExpr),
612 IndexExpr(IndexExpr), 612 IndexExpr(IndexExpr),
613 MethodCallExpr(MethodCallExpr), 613 MethodCallExpr(MethodCallExpr),
@@ -698,9 +698,9 @@ impl From<MatchExpr> for Expr {
698 Expr::MatchExpr(node) 698 Expr::MatchExpr(node)
699 } 699 }
700} 700}
701impl From<StructLit> for Expr { 701impl From<RecordLit> for Expr {
702 fn from(node: StructLit) -> Expr { 702 fn from(node: RecordLit) -> Expr {
703 Expr::StructLit(node) 703 Expr::RecordLit(node)
704 } 704 }
705} 705}
706impl From<CallExpr> for Expr { 706impl From<CallExpr> for Expr {
@@ -778,7 +778,7 @@ impl AstNode for Expr {
778 match kind { 778 match kind {
779 TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR 779 TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR
780 | LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL 780 | LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL
781 | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | STRUCT_LIT | CALL_EXPR | INDEX_EXPR 781 | 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 782 | 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 => { 783 | CAST_EXPR | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL => {
784 true 784 true
@@ -803,7 +803,7 @@ impl AstNode for Expr {
803 BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }), 803 BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }),
804 RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }), 804 RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }),
805 MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }), 805 MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }),
806 STRUCT_LIT => Expr::StructLit(StructLit { syntax }), 806 RECORD_LIT => Expr::RecordLit(RecordLit { syntax }),
807 CALL_EXPR => Expr::CallExpr(CallExpr { syntax }), 807 CALL_EXPR => Expr::CallExpr(CallExpr { syntax }),
808 INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }), 808 INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }),
809 METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }), 809 METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }),
@@ -839,7 +839,7 @@ impl AstNode for Expr {
839 Expr::BlockExpr(it) => &it.syntax, 839 Expr::BlockExpr(it) => &it.syntax,
840 Expr::ReturnExpr(it) => &it.syntax, 840 Expr::ReturnExpr(it) => &it.syntax,
841 Expr::MatchExpr(it) => &it.syntax, 841 Expr::MatchExpr(it) => &it.syntax,
842 Expr::StructLit(it) => &it.syntax, 842 Expr::RecordLit(it) => &it.syntax,
843 Expr::CallExpr(it) => &it.syntax, 843 Expr::CallExpr(it) => &it.syntax,
844 Expr::IndexExpr(it) => &it.syntax, 844 Expr::IndexExpr(it) => &it.syntax,
845 Expr::MethodCallExpr(it) => &it.syntax, 845 Expr::MethodCallExpr(it) => &it.syntax,
@@ -946,64 +946,6 @@ impl FieldExpr {
946 } 946 }
947} 947}
948#[derive(Debug, Clone, PartialEq, Eq, Hash)] 948#[derive(Debug, Clone, PartialEq, Eq, Hash)]
949pub struct FieldPat {
950 pub(crate) syntax: SyntaxNode,
951}
952impl 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}
970impl ast::NameOwner for FieldPat {}
971impl FieldPat {
972 pub fn pat(&self) -> Option<Pat> {
973 AstChildren::new(&self.syntax).next()
974 }
975}
976#[derive(Debug, Clone, PartialEq, Eq, Hash)]
977pub struct FieldPatList {
978 pub(crate) syntax: SyntaxNode,
979}
980impl 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}
998impl 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)]
1007pub struct FnDef { 949pub struct FnDef {
1008 pub(crate) syntax: SyntaxNode, 950 pub(crate) syntax: SyntaxNode,
1009} 951}
@@ -1942,121 +1884,6 @@ impl AstNode for NameRef {
1942} 1884}
1943impl NameRef {} 1885impl NameRef {}
1944#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1886#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1945pub struct NamedField {
1946 pub(crate) syntax: SyntaxNode,
1947}
1948impl 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}
1966impl 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)]
1975pub struct NamedFieldDef {
1976 pub(crate) syntax: SyntaxNode,
1977}
1978impl 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}
1996impl ast::VisibilityOwner for NamedFieldDef {}
1997impl ast::NameOwner for NamedFieldDef {}
1998impl ast::AttrsOwner for NamedFieldDef {}
1999impl ast::DocCommentsOwner for NamedFieldDef {}
2000impl ast::TypeAscriptionOwner for NamedFieldDef {}
2001impl NamedFieldDef {}
2002#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2003pub struct NamedFieldDefList {
2004 pub(crate) syntax: SyntaxNode,
2005}
2006impl 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}
2024impl NamedFieldDefList {
2025 pub fn fields(&self) -> AstChildren<NamedFieldDef> {
2026 AstChildren::new(&self.syntax)
2027 }
2028}
2029#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2030pub struct NamedFieldList {
2031 pub(crate) syntax: SyntaxNode,
2032}
2033impl 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}
2051impl 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)]
2060pub struct NeverType { 1887pub struct NeverType {
2061 pub(crate) syntax: SyntaxNode, 1888 pub(crate) syntax: SyntaxNode,
2062} 1889}
@@ -2239,7 +2066,7 @@ pub enum Pat {
2239 BindPat(BindPat), 2066 BindPat(BindPat),
2240 PlaceholderPat(PlaceholderPat), 2067 PlaceholderPat(PlaceholderPat),
2241 PathPat(PathPat), 2068 PathPat(PathPat),
2242 StructPat(StructPat), 2069 RecordPat(RecordPat),
2243 TupleStructPat(TupleStructPat), 2070 TupleStructPat(TupleStructPat),
2244 TuplePat(TuplePat), 2071 TuplePat(TuplePat),
2245 SlicePat(SlicePat), 2072 SlicePat(SlicePat),
@@ -2266,9 +2093,9 @@ impl From<PathPat> for Pat {
2266 Pat::PathPat(node) 2093 Pat::PathPat(node)
2267 } 2094 }
2268} 2095}
2269impl From<StructPat> for Pat { 2096impl From<RecordPat> for Pat {
2270 fn from(node: StructPat) -> Pat { 2097 fn from(node: RecordPat) -> Pat {
2271 Pat::StructPat(node) 2098 Pat::RecordPat(node)
2272 } 2099 }
2273} 2100}
2274impl From<TupleStructPat> for Pat { 2101impl From<TupleStructPat> for Pat {
@@ -2299,7 +2126,7 @@ impl From<LiteralPat> for Pat {
2299impl AstNode for Pat { 2126impl AstNode for Pat {
2300 fn can_cast(kind: SyntaxKind) -> bool { 2127 fn can_cast(kind: SyntaxKind) -> bool {
2301 match kind { 2128 match kind {
2302 REF_PAT | BIND_PAT | PLACEHOLDER_PAT | PATH_PAT | STRUCT_PAT | TUPLE_STRUCT_PAT 2129 REF_PAT | BIND_PAT | PLACEHOLDER_PAT | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT
2303 | TUPLE_PAT | SLICE_PAT | RANGE_PAT | LITERAL_PAT => true, 2130 | TUPLE_PAT | SLICE_PAT | RANGE_PAT | LITERAL_PAT => true,
2304 _ => false, 2131 _ => false,
2305 } 2132 }
@@ -2310,7 +2137,7 @@ impl AstNode for Pat {
2310 BIND_PAT => Pat::BindPat(BindPat { syntax }), 2137 BIND_PAT => Pat::BindPat(BindPat { syntax }),
2311 PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }), 2138 PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }),
2312 PATH_PAT => Pat::PathPat(PathPat { syntax }), 2139 PATH_PAT => Pat::PathPat(PathPat { syntax }),
2313 STRUCT_PAT => Pat::StructPat(StructPat { syntax }), 2140 RECORD_PAT => Pat::RecordPat(RecordPat { syntax }),
2314 TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }), 2141 TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }),
2315 TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }), 2142 TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }),
2316 SLICE_PAT => Pat::SlicePat(SlicePat { syntax }), 2143 SLICE_PAT => Pat::SlicePat(SlicePat { syntax }),
@@ -2326,7 +2153,7 @@ impl AstNode for Pat {
2326 Pat::BindPat(it) => &it.syntax, 2153 Pat::BindPat(it) => &it.syntax,
2327 Pat::PlaceholderPat(it) => &it.syntax, 2154 Pat::PlaceholderPat(it) => &it.syntax,
2328 Pat::PathPat(it) => &it.syntax, 2155 Pat::PathPat(it) => &it.syntax,
2329 Pat::StructPat(it) => &it.syntax, 2156 Pat::RecordPat(it) => &it.syntax,
2330 Pat::TupleStructPat(it) => &it.syntax, 2157 Pat::TupleStructPat(it) => &it.syntax,
2331 Pat::TuplePat(it) => &it.syntax, 2158 Pat::TuplePat(it) => &it.syntax,
2332 Pat::SlicePat(it) => &it.syntax, 2159 Pat::SlicePat(it) => &it.syntax,
@@ -2551,13 +2378,13 @@ impl PointerType {
2551 } 2378 }
2552} 2379}
2553#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2380#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2554pub struct PosFieldDef { 2381pub struct PrefixExpr {
2555 pub(crate) syntax: SyntaxNode, 2382 pub(crate) syntax: SyntaxNode,
2556} 2383}
2557impl AstNode for PosFieldDef { 2384impl AstNode for PrefixExpr {
2558 fn can_cast(kind: SyntaxKind) -> bool { 2385 fn can_cast(kind: SyntaxKind) -> bool {
2559 match kind { 2386 match kind {
2560 POS_FIELD_DEF => true, 2387 PREFIX_EXPR => true,
2561 _ => false, 2388 _ => false,
2562 } 2389 }
2563 } 2390 }
@@ -2572,21 +2399,19 @@ impl AstNode for PosFieldDef {
2572 &self.syntax 2399 &self.syntax
2573 } 2400 }
2574} 2401}
2575impl ast::VisibilityOwner for PosFieldDef {} 2402impl PrefixExpr {
2576impl ast::AttrsOwner for PosFieldDef {} 2403 pub fn expr(&self) -> Option<Expr> {
2577impl PosFieldDef {
2578 pub fn type_ref(&self) -> Option<TypeRef> {
2579 AstChildren::new(&self.syntax).next() 2404 AstChildren::new(&self.syntax).next()
2580 } 2405 }
2581} 2406}
2582#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2407#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2583pub struct PosFieldDefList { 2408pub struct RangeExpr {
2584 pub(crate) syntax: SyntaxNode, 2409 pub(crate) syntax: SyntaxNode,
2585} 2410}
2586impl AstNode for PosFieldDefList { 2411impl AstNode for RangeExpr {
2587 fn can_cast(kind: SyntaxKind) -> bool { 2412 fn can_cast(kind: SyntaxKind) -> bool {
2588 match kind { 2413 match kind {
2589 POS_FIELD_DEF_LIST => true, 2414 RANGE_EXPR => true,
2590 _ => false, 2415 _ => false,
2591 } 2416 }
2592 } 2417 }
@@ -2601,19 +2426,38 @@ impl AstNode for PosFieldDefList {
2601 &self.syntax 2426 &self.syntax
2602 } 2427 }
2603} 2428}
2604impl PosFieldDefList { 2429impl RangeExpr {}
2605 pub fn fields(&self) -> AstChildren<PosFieldDef> { 2430#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2606 AstChildren::new(&self.syntax) 2431pub struct RangePat {
2432 pub(crate) syntax: SyntaxNode,
2433}
2434impl AstNode for RangePat {
2435 fn can_cast(kind: SyntaxKind) -> bool {
2436 match kind {
2437 RANGE_PAT => true,
2438 _ => false,
2439 }
2440 }
2441 fn cast(syntax: SyntaxNode) -> Option<Self> {
2442 if Self::can_cast(syntax.kind()) {
2443 Some(Self { syntax })
2444 } else {
2445 None
2446 }
2447 }
2448 fn syntax(&self) -> &SyntaxNode {
2449 &self.syntax
2607 } 2450 }
2608} 2451}
2452impl RangePat {}
2609#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2453#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2610pub struct PrefixExpr { 2454pub struct RecordField {
2611 pub(crate) syntax: SyntaxNode, 2455 pub(crate) syntax: SyntaxNode,
2612} 2456}
2613impl AstNode for PrefixExpr { 2457impl AstNode for RecordField {
2614 fn can_cast(kind: SyntaxKind) -> bool { 2458 fn can_cast(kind: SyntaxKind) -> bool {
2615 match kind { 2459 match kind {
2616 PREFIX_EXPR => true, 2460 RECORD_FIELD => true,
2617 _ => false, 2461 _ => false,
2618 } 2462 }
2619 } 2463 }
@@ -2628,19 +2472,22 @@ impl AstNode for PrefixExpr {
2628 &self.syntax 2472 &self.syntax
2629 } 2473 }
2630} 2474}
2631impl PrefixExpr { 2475impl RecordField {
2476 pub fn name_ref(&self) -> Option<NameRef> {
2477 AstChildren::new(&self.syntax).next()
2478 }
2632 pub fn expr(&self) -> Option<Expr> { 2479 pub fn expr(&self) -> Option<Expr> {
2633 AstChildren::new(&self.syntax).next() 2480 AstChildren::new(&self.syntax).next()
2634 } 2481 }
2635} 2482}
2636#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2483#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2637pub struct RangeExpr { 2484pub struct RecordFieldDef {
2638 pub(crate) syntax: SyntaxNode, 2485 pub(crate) syntax: SyntaxNode,
2639} 2486}
2640impl AstNode for RangeExpr { 2487impl AstNode for RecordFieldDef {
2641 fn can_cast(kind: SyntaxKind) -> bool { 2488 fn can_cast(kind: SyntaxKind) -> bool {
2642 match kind { 2489 match kind {
2643 RANGE_EXPR => true, 2490 RECORD_FIELD_DEF => true,
2644 _ => false, 2491 _ => false,
2645 } 2492 }
2646 } 2493 }
@@ -2655,15 +2502,20 @@ impl AstNode for RangeExpr {
2655 &self.syntax 2502 &self.syntax
2656 } 2503 }
2657} 2504}
2658impl RangeExpr {} 2505impl ast::VisibilityOwner for RecordFieldDef {}
2506impl ast::NameOwner for RecordFieldDef {}
2507impl ast::AttrsOwner for RecordFieldDef {}
2508impl ast::DocCommentsOwner for RecordFieldDef {}
2509impl ast::TypeAscriptionOwner for RecordFieldDef {}
2510impl RecordFieldDef {}
2659#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2511#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2660pub struct RangePat { 2512pub struct RecordFieldDefList {
2661 pub(crate) syntax: SyntaxNode, 2513 pub(crate) syntax: SyntaxNode,
2662} 2514}
2663impl AstNode for RangePat { 2515impl AstNode for RecordFieldDefList {
2664 fn can_cast(kind: SyntaxKind) -> bool { 2516 fn can_cast(kind: SyntaxKind) -> bool {
2665 match kind { 2517 match kind {
2666 RANGE_PAT => true, 2518 RECORD_FIELD_DEF_LIST => true,
2667 _ => false, 2519 _ => false,
2668 } 2520 }
2669 } 2521 }
@@ -2678,7 +2530,159 @@ impl AstNode for RangePat {
2678 &self.syntax 2530 &self.syntax
2679 } 2531 }
2680} 2532}
2681impl RangePat {} 2533impl RecordFieldDefList {
2534 pub fn fields(&self) -> AstChildren<RecordFieldDef> {
2535 AstChildren::new(&self.syntax)
2536 }
2537}
2538#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2539pub struct RecordFieldList {
2540 pub(crate) syntax: SyntaxNode,
2541}
2542impl AstNode for RecordFieldList {
2543 fn can_cast(kind: SyntaxKind) -> bool {
2544 match kind {
2545 RECORD_FIELD_LIST => true,
2546 _ => false,
2547 }
2548 }
2549 fn cast(syntax: SyntaxNode) -> Option<Self> {
2550 if Self::can_cast(syntax.kind()) {
2551 Some(Self { syntax })
2552 } else {
2553 None
2554 }
2555 }
2556 fn syntax(&self) -> &SyntaxNode {
2557 &self.syntax
2558 }
2559}
2560impl RecordFieldList {
2561 pub fn fields(&self) -> AstChildren<RecordField> {
2562 AstChildren::new(&self.syntax)
2563 }
2564 pub fn spread(&self) -> Option<Expr> {
2565 AstChildren::new(&self.syntax).next()
2566 }
2567}
2568#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2569pub struct RecordFieldPat {
2570 pub(crate) syntax: SyntaxNode,
2571}
2572impl AstNode for RecordFieldPat {
2573 fn can_cast(kind: SyntaxKind) -> bool {
2574 match kind {
2575 RECORD_FIELD_PAT => true,
2576 _ => false,
2577 }
2578 }
2579 fn cast(syntax: SyntaxNode) -> Option<Self> {
2580 if Self::can_cast(syntax.kind()) {
2581 Some(Self { syntax })
2582 } else {
2583 None
2584 }
2585 }
2586 fn syntax(&self) -> &SyntaxNode {
2587 &self.syntax
2588 }
2589}
2590impl ast::NameOwner for RecordFieldPat {}
2591impl RecordFieldPat {
2592 pub fn pat(&self) -> Option<Pat> {
2593 AstChildren::new(&self.syntax).next()
2594 }
2595}
2596#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2597pub struct RecordFieldPatList {
2598 pub(crate) syntax: SyntaxNode,
2599}
2600impl AstNode for RecordFieldPatList {
2601 fn can_cast(kind: SyntaxKind) -> bool {
2602 match kind {
2603 RECORD_FIELD_PAT_LIST => true,
2604 _ => false,
2605 }
2606 }
2607 fn cast(syntax: SyntaxNode) -> Option<Self> {
2608 if Self::can_cast(syntax.kind()) {
2609 Some(Self { syntax })
2610 } else {
2611 None
2612 }
2613 }
2614 fn syntax(&self) -> &SyntaxNode {
2615 &self.syntax
2616 }
2617}
2618impl RecordFieldPatList {
2619 pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> {
2620 AstChildren::new(&self.syntax)
2621 }
2622 pub fn bind_pats(&self) -> AstChildren<BindPat> {
2623 AstChildren::new(&self.syntax)
2624 }
2625}
2626#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2627pub struct RecordLit {
2628 pub(crate) syntax: SyntaxNode,
2629}
2630impl AstNode for RecordLit {
2631 fn can_cast(kind: SyntaxKind) -> bool {
2632 match kind {
2633 RECORD_LIT => true,
2634 _ => false,
2635 }
2636 }
2637 fn cast(syntax: SyntaxNode) -> Option<Self> {
2638 if Self::can_cast(syntax.kind()) {
2639 Some(Self { syntax })
2640 } else {
2641 None
2642 }
2643 }
2644 fn syntax(&self) -> &SyntaxNode {
2645 &self.syntax
2646 }
2647}
2648impl RecordLit {
2649 pub fn path(&self) -> Option<Path> {
2650 AstChildren::new(&self.syntax).next()
2651 }
2652 pub fn record_field_list(&self) -> Option<RecordFieldList> {
2653 AstChildren::new(&self.syntax).next()
2654 }
2655}
2656#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2657pub struct RecordPat {
2658 pub(crate) syntax: SyntaxNode,
2659}
2660impl AstNode for RecordPat {
2661 fn can_cast(kind: SyntaxKind) -> bool {
2662 match kind {
2663 RECORD_PAT => true,
2664 _ => false,
2665 }
2666 }
2667 fn cast(syntax: SyntaxNode) -> Option<Self> {
2668 if Self::can_cast(syntax.kind()) {
2669 Some(Self { syntax })
2670 } else {
2671 None
2672 }
2673 }
2674 fn syntax(&self) -> &SyntaxNode {
2675 &self.syntax
2676 }
2677}
2678impl RecordPat {
2679 pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> {
2680 AstChildren::new(&self.syntax).next()
2681 }
2682 pub fn path(&self) -> Option<Path> {
2683 AstChildren::new(&self.syntax).next()
2684 }
2685}
2682#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2686#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2683pub struct RefExpr { 2687pub struct RefExpr {
2684 pub(crate) syntax: SyntaxNode, 2688 pub(crate) syntax: SyntaxNode,
@@ -3018,13 +3022,13 @@ impl ast::AttrsOwner for StructDef {}
3018impl ast::DocCommentsOwner for StructDef {} 3022impl ast::DocCommentsOwner for StructDef {}
3019impl StructDef {} 3023impl StructDef {}
3020#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3024#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3021pub struct StructLit { 3025pub struct TokenTree {
3022 pub(crate) syntax: SyntaxNode, 3026 pub(crate) syntax: SyntaxNode,
3023} 3027}
3024impl AstNode for StructLit { 3028impl AstNode for TokenTree {
3025 fn can_cast(kind: SyntaxKind) -> bool { 3029 fn can_cast(kind: SyntaxKind) -> bool {
3026 match kind { 3030 match kind {
3027 STRUCT_LIT => true, 3031 TOKEN_TREE => true,
3028 _ => false, 3032 _ => false,
3029 } 3033 }
3030 } 3034 }
@@ -3039,22 +3043,15 @@ impl AstNode for StructLit {
3039 &self.syntax 3043 &self.syntax
3040 } 3044 }
3041} 3045}
3042impl StructLit { 3046impl 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)] 3047#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3051pub struct StructPat { 3048pub struct TraitDef {
3052 pub(crate) syntax: SyntaxNode, 3049 pub(crate) syntax: SyntaxNode,
3053} 3050}
3054impl AstNode for StructPat { 3051impl AstNode for TraitDef {
3055 fn can_cast(kind: SyntaxKind) -> bool { 3052 fn can_cast(kind: SyntaxKind) -> bool {
3056 match kind { 3053 match kind {
3057 STRUCT_PAT => true, 3054 TRAIT_DEF => true,
3058 _ => false, 3055 _ => false,
3059 } 3056 }
3060 } 3057 }
@@ -3069,22 +3066,25 @@ impl AstNode for StructPat {
3069 &self.syntax 3066 &self.syntax
3070 } 3067 }
3071} 3068}
3072impl StructPat { 3069impl ast::VisibilityOwner for TraitDef {}
3073 pub fn field_pat_list(&self) -> Option<FieldPatList> { 3070impl ast::NameOwner for TraitDef {}
3074 AstChildren::new(&self.syntax).next() 3071impl ast::AttrsOwner for TraitDef {}
3075 } 3072impl ast::DocCommentsOwner for TraitDef {}
3076 pub fn path(&self) -> Option<Path> { 3073impl ast::TypeParamsOwner for TraitDef {}
3074impl ast::TypeBoundsOwner for TraitDef {}
3075impl TraitDef {
3076 pub fn item_list(&self) -> Option<ItemList> {
3077 AstChildren::new(&self.syntax).next() 3077 AstChildren::new(&self.syntax).next()
3078 } 3078 }
3079} 3079}
3080#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3080#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3081pub struct TokenTree { 3081pub struct TryBlockExpr {
3082 pub(crate) syntax: SyntaxNode, 3082 pub(crate) syntax: SyntaxNode,
3083} 3083}
3084impl AstNode for TokenTree { 3084impl AstNode for TryBlockExpr {
3085 fn can_cast(kind: SyntaxKind) -> bool { 3085 fn can_cast(kind: SyntaxKind) -> bool {
3086 match kind { 3086 match kind {
3087 TOKEN_TREE => true, 3087 TRY_BLOCK_EXPR => true,
3088 _ => false, 3088 _ => false,
3089 } 3089 }
3090 } 3090 }
@@ -3099,15 +3099,16 @@ impl AstNode for TokenTree {
3099 &self.syntax 3099 &self.syntax
3100 } 3100 }
3101} 3101}
3102impl TokenTree {} 3102impl ast::TryBlockBodyOwner for TryBlockExpr {}
3103impl TryBlockExpr {}
3103#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3104#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3104pub struct TraitDef { 3105pub struct TryExpr {
3105 pub(crate) syntax: SyntaxNode, 3106 pub(crate) syntax: SyntaxNode,
3106} 3107}
3107impl AstNode for TraitDef { 3108impl AstNode for TryExpr {
3108 fn can_cast(kind: SyntaxKind) -> bool { 3109 fn can_cast(kind: SyntaxKind) -> bool {
3109 match kind { 3110 match kind {
3110 TRAIT_DEF => true, 3111 TRY_EXPR => true,
3111 _ => false, 3112 _ => false,
3112 } 3113 }
3113 } 3114 }
@@ -3122,25 +3123,19 @@ impl AstNode for TraitDef {
3122 &self.syntax 3123 &self.syntax
3123 } 3124 }
3124} 3125}
3125impl ast::VisibilityOwner for TraitDef {} 3126impl TryExpr {
3126impl ast::NameOwner for TraitDef {} 3127 pub fn expr(&self) -> Option<Expr> {
3127impl ast::AttrsOwner for TraitDef {}
3128impl ast::DocCommentsOwner for TraitDef {}
3129impl ast::TypeParamsOwner for TraitDef {}
3130impl ast::TypeBoundsOwner for TraitDef {}
3131impl TraitDef {
3132 pub fn item_list(&self) -> Option<ItemList> {
3133 AstChildren::new(&self.syntax).next() 3128 AstChildren::new(&self.syntax).next()
3134 } 3129 }
3135} 3130}
3136#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3131#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3137pub struct TryBlockExpr { 3132pub struct TupleExpr {
3138 pub(crate) syntax: SyntaxNode, 3133 pub(crate) syntax: SyntaxNode,
3139} 3134}
3140impl AstNode for TryBlockExpr { 3135impl AstNode for TupleExpr {
3141 fn can_cast(kind: SyntaxKind) -> bool { 3136 fn can_cast(kind: SyntaxKind) -> bool {
3142 match kind { 3137 match kind {
3143 TRY_BLOCK_EXPR => true, 3138 TUPLE_EXPR => true,
3144 _ => false, 3139 _ => false,
3145 } 3140 }
3146 } 3141 }
@@ -3155,16 +3150,19 @@ impl AstNode for TryBlockExpr {
3155 &self.syntax 3150 &self.syntax
3156 } 3151 }
3157} 3152}
3158impl ast::TryBlockBodyOwner for TryBlockExpr {} 3153impl TupleExpr {
3159impl TryBlockExpr {} 3154 pub fn exprs(&self) -> AstChildren<Expr> {
3155 AstChildren::new(&self.syntax)
3156 }
3157}
3160#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3158#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3161pub struct TryExpr { 3159pub struct TupleFieldDef {
3162 pub(crate) syntax: SyntaxNode, 3160 pub(crate) syntax: SyntaxNode,
3163} 3161}
3164impl AstNode for TryExpr { 3162impl AstNode for TupleFieldDef {
3165 fn can_cast(kind: SyntaxKind) -> bool { 3163 fn can_cast(kind: SyntaxKind) -> bool {
3166 match kind { 3164 match kind {
3167 TRY_EXPR => true, 3165 TUPLE_FIELD_DEF => true,
3168 _ => false, 3166 _ => false,
3169 } 3167 }
3170 } 3168 }
@@ -3179,19 +3177,21 @@ impl AstNode for TryExpr {
3179 &self.syntax 3177 &self.syntax
3180 } 3178 }
3181} 3179}
3182impl TryExpr { 3180impl ast::VisibilityOwner for TupleFieldDef {}
3183 pub fn expr(&self) -> Option<Expr> { 3181impl ast::AttrsOwner for TupleFieldDef {}
3182impl TupleFieldDef {
3183 pub fn type_ref(&self) -> Option<TypeRef> {
3184 AstChildren::new(&self.syntax).next() 3184 AstChildren::new(&self.syntax).next()
3185 } 3185 }
3186} 3186}
3187#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3187#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3188pub struct TupleExpr { 3188pub struct TupleFieldDefList {
3189 pub(crate) syntax: SyntaxNode, 3189 pub(crate) syntax: SyntaxNode,
3190} 3190}
3191impl AstNode for TupleExpr { 3191impl AstNode for TupleFieldDefList {
3192 fn can_cast(kind: SyntaxKind) -> bool { 3192 fn can_cast(kind: SyntaxKind) -> bool {
3193 match kind { 3193 match kind {
3194 TUPLE_EXPR => true, 3194 TUPLE_FIELD_DEF_LIST => true,
3195 _ => false, 3195 _ => false,
3196 } 3196 }
3197 } 3197 }
@@ -3206,8 +3206,8 @@ impl AstNode for TupleExpr {
3206 &self.syntax 3206 &self.syntax
3207 } 3207 }
3208} 3208}
3209impl TupleExpr { 3209impl TupleFieldDefList {
3210 pub fn exprs(&self) -> AstChildren<Expr> { 3210 pub fn fields(&self) -> AstChildren<TupleFieldDef> {
3211 AstChildren::new(&self.syntax) 3211 AstChildren::new(&self.syntax)
3212 } 3212 }
3213} 3213}