aboutsummaryrefslogtreecommitdiff
path: root/crates/syntax/src/ast/generated
diff options
context:
space:
mode:
Diffstat (limited to 'crates/syntax/src/ast/generated')
-rw-r--r--crates/syntax/src/ast/generated/nodes.rs98
1 files changed, 70 insertions, 28 deletions
diff --git a/crates/syntax/src/ast/generated/nodes.rs b/crates/syntax/src/ast/generated/nodes.rs
index 0ad75214f..1588ba93e 100644
--- a/crates/syntax/src/ast/generated/nodes.rs
+++ b/crates/syntax/src/ast/generated/nodes.rs
@@ -20,6 +20,15 @@ impl NameRef {
20 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) } 20 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) }
21} 21}
22#[derive(Debug, Clone, PartialEq, Eq, Hash)] 22#[derive(Debug, Clone, PartialEq, Eq, Hash)]
23pub struct Lifetime {
24 pub(crate) syntax: SyntaxNode,
25}
26impl Lifetime {
27 pub fn lifetime_ident_token(&self) -> Option<SyntaxToken> {
28 support::token(&self.syntax, T![lifetime_ident])
29 }
30}
31#[derive(Debug, Clone, PartialEq, Eq, Hash)]
23pub struct Path { 32pub struct Path {
24 pub(crate) syntax: SyntaxNode, 33 pub(crate) syntax: SyntaxNode,
25} 34}
@@ -105,9 +114,7 @@ pub struct LifetimeArg {
105 pub(crate) syntax: SyntaxNode, 114 pub(crate) syntax: SyntaxNode,
106} 115}
107impl LifetimeArg { 116impl LifetimeArg {
108 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 117 pub fn lifetime(&self) -> Option<Lifetime> { support::child(&self.syntax) }
109 support::token(&self.syntax, T![lifetime])
110 }
111} 118}
112#[derive(Debug, Clone, PartialEq, Eq, Hash)] 119#[derive(Debug, Clone, PartialEq, Eq, Hash)]
113pub struct ConstArg { 120pub struct ConstArg {
@@ -286,6 +293,18 @@ impl MacroRules {
286 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) } 293 pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
287} 294}
288#[derive(Debug, Clone, PartialEq, Eq, Hash)] 295#[derive(Debug, Clone, PartialEq, Eq, Hash)]
296pub struct MacroDef {
297 pub(crate) syntax: SyntaxNode,
298}
299impl ast::AttrsOwner for MacroDef {}
300impl ast::NameOwner for MacroDef {}
301impl ast::VisibilityOwner for MacroDef {}
302impl MacroDef {
303 pub fn macro_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![macro]) }
304 pub fn args(&self) -> Option<TokenTree> { support::child(&self.syntax) }
305 pub fn body(&self) -> Option<TokenTree> { support::child(&self.syntax) }
306}
307#[derive(Debug, Clone, PartialEq, Eq, Hash)]
289pub struct Module { 308pub struct Module {
290 pub(crate) syntax: SyntaxNode, 309 pub(crate) syntax: SyntaxNode,
291} 310}
@@ -475,9 +494,7 @@ pub struct SelfParam {
475impl ast::AttrsOwner for SelfParam {} 494impl ast::AttrsOwner for SelfParam {}
476impl SelfParam { 495impl SelfParam {
477 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) } 496 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
478 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 497 pub fn lifetime(&self) -> Option<Lifetime> { support::child(&self.syntax) }
479 support::token(&self.syntax, T![lifetime])
480 }
481 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 498 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
482 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) } 499 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
483 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } 500 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
@@ -593,9 +610,7 @@ pub struct LifetimeParam {
593impl ast::AttrsOwner for LifetimeParam {} 610impl ast::AttrsOwner for LifetimeParam {}
594impl ast::TypeBoundsOwner for LifetimeParam {} 611impl ast::TypeBoundsOwner for LifetimeParam {}
595impl LifetimeParam { 612impl LifetimeParam {
596 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 613 pub fn lifetime(&self) -> Option<Lifetime> { support::child(&self.syntax) }
597 support::token(&self.syntax, T![lifetime])
598 }
599} 614}
600#[derive(Debug, Clone, PartialEq, Eq, Hash)] 615#[derive(Debug, Clone, PartialEq, Eq, Hash)]
601pub struct TypeParam { 616pub struct TypeParam {
@@ -616,9 +631,7 @@ impl ast::TypeBoundsOwner for WherePred {}
616impl WherePred { 631impl WherePred {
617 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } 632 pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) }
618 pub fn generic_param_list(&self) -> Option<GenericParamList> { support::child(&self.syntax) } 633 pub fn generic_param_list(&self) -> Option<GenericParamList> { support::child(&self.syntax) }
619 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 634 pub fn lifetime(&self) -> Option<Lifetime> { support::child(&self.syntax) }
620 support::token(&self.syntax, T![lifetime])
621 }
622 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } 635 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
623} 636}
624#[derive(Debug, Clone, PartialEq, Eq, Hash)] 637#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -694,9 +707,7 @@ pub struct BreakExpr {
694impl ast::AttrsOwner for BreakExpr {} 707impl ast::AttrsOwner for BreakExpr {}
695impl BreakExpr { 708impl BreakExpr {
696 pub fn break_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![break]) } 709 pub fn break_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![break]) }
697 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 710 pub fn lifetime(&self) -> Option<Lifetime> { support::child(&self.syntax) }
698 support::token(&self.syntax, T![lifetime])
699 }
700 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } 711 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
701} 712}
702#[derive(Debug, Clone, PartialEq, Eq, Hash)] 713#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -740,9 +751,7 @@ impl ContinueExpr {
740 pub fn continue_token(&self) -> Option<SyntaxToken> { 751 pub fn continue_token(&self) -> Option<SyntaxToken> {
741 support::token(&self.syntax, T![continue]) 752 support::token(&self.syntax, T![continue])
742 } 753 }
743 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 754 pub fn lifetime(&self) -> Option<Lifetime> { support::child(&self.syntax) }
744 support::token(&self.syntax, T![lifetime])
745 }
746} 755}
747#[derive(Debug, Clone, PartialEq, Eq, Hash)] 756#[derive(Debug, Clone, PartialEq, Eq, Hash)]
748pub struct EffectExpr { 757pub struct EffectExpr {
@@ -925,9 +934,8 @@ pub struct Label {
925 pub(crate) syntax: SyntaxNode, 934 pub(crate) syntax: SyntaxNode,
926} 935}
927impl Label { 936impl Label {
928 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 937 pub fn lifetime(&self) -> Option<Lifetime> { support::child(&self.syntax) }
929 support::token(&self.syntax, T![lifetime]) 938 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
930 }
931} 939}
932#[derive(Debug, Clone, PartialEq, Eq, Hash)] 940#[derive(Debug, Clone, PartialEq, Eq, Hash)]
933pub struct RecordExprFieldList { 941pub struct RecordExprFieldList {
@@ -1088,9 +1096,7 @@ pub struct RefType {
1088} 1096}
1089impl RefType { 1097impl RefType {
1090 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) } 1098 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
1091 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 1099 pub fn lifetime(&self) -> Option<Lifetime> { support::child(&self.syntax) }
1092 support::token(&self.syntax, T![lifetime])
1093 }
1094 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 1100 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
1095 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } 1101 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
1096} 1102}
@@ -1117,9 +1123,7 @@ pub struct TypeBound {
1117 pub(crate) syntax: SyntaxNode, 1123 pub(crate) syntax: SyntaxNode,
1118} 1124}
1119impl TypeBound { 1125impl TypeBound {
1120 pub fn lifetime_token(&self) -> Option<SyntaxToken> { 1126 pub fn lifetime(&self) -> Option<Lifetime> { support::child(&self.syntax) }
1121 support::token(&self.syntax, T![lifetime])
1122 }
1123 pub fn question_mark_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![?]) } 1127 pub fn question_mark_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![?]) }
1124 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } 1128 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
1125} 1129}
@@ -1332,6 +1336,7 @@ pub enum Item {
1332 Impl(Impl), 1336 Impl(Impl),
1333 MacroCall(MacroCall), 1337 MacroCall(MacroCall),
1334 MacroRules(MacroRules), 1338 MacroRules(MacroRules),
1339 MacroDef(MacroDef),
1335 Module(Module), 1340 Module(Module),
1336 Static(Static), 1341 Static(Static),
1337 Struct(Struct), 1342 Struct(Struct),
@@ -1425,6 +1430,17 @@ impl AstNode for NameRef {
1425 } 1430 }
1426 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1431 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1427} 1432}
1433impl AstNode for Lifetime {
1434 fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME }
1435 fn cast(syntax: SyntaxNode) -> Option<Self> {
1436 if Self::can_cast(syntax.kind()) {
1437 Some(Self { syntax })
1438 } else {
1439 None
1440 }
1441 }
1442 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1443}
1428impl AstNode for Path { 1444impl AstNode for Path {
1429 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH } 1445 fn can_cast(kind: SyntaxKind) -> bool { kind == PATH }
1430 fn cast(syntax: SyntaxNode) -> Option<Self> { 1446 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -1689,6 +1705,17 @@ impl AstNode for MacroRules {
1689 } 1705 }
1690 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1706 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1691} 1707}
1708impl AstNode for MacroDef {
1709 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_DEF }
1710 fn cast(syntax: SyntaxNode) -> Option<Self> {
1711 if Self::can_cast(syntax.kind()) {
1712 Some(Self { syntax })
1713 } else {
1714 None
1715 }
1716 }
1717 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1718}
1692impl AstNode for Module { 1719impl AstNode for Module {
1693 fn can_cast(kind: SyntaxKind) -> bool { kind == MODULE } 1720 fn can_cast(kind: SyntaxKind) -> bool { kind == MODULE }
1694 fn cast(syntax: SyntaxNode) -> Option<Self> { 1721 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -3086,6 +3113,9 @@ impl From<MacroCall> for Item {
3086impl From<MacroRules> for Item { 3113impl From<MacroRules> for Item {
3087 fn from(node: MacroRules) -> Item { Item::MacroRules(node) } 3114 fn from(node: MacroRules) -> Item { Item::MacroRules(node) }
3088} 3115}
3116impl From<MacroDef> for Item {
3117 fn from(node: MacroDef) -> Item { Item::MacroDef(node) }
3118}
3089impl From<Module> for Item { 3119impl From<Module> for Item {
3090 fn from(node: Module) -> Item { Item::Module(node) } 3120 fn from(node: Module) -> Item { Item::Module(node) }
3091} 3121}
@@ -3111,7 +3141,7 @@ impl AstNode for Item {
3111 fn can_cast(kind: SyntaxKind) -> bool { 3141 fn can_cast(kind: SyntaxKind) -> bool {
3112 match kind { 3142 match kind {
3113 CONST | ENUM | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL | MACRO_CALL | MACRO_RULES 3143 CONST | ENUM | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL | MACRO_CALL | MACRO_RULES
3114 | MODULE | STATIC | STRUCT | TRAIT | TYPE_ALIAS | UNION | USE => true, 3144 | MACRO_DEF | MODULE | STATIC | STRUCT | TRAIT | TYPE_ALIAS | UNION | USE => true,
3115 _ => false, 3145 _ => false,
3116 } 3146 }
3117 } 3147 }
@@ -3125,6 +3155,7 @@ impl AstNode for Item {
3125 IMPL => Item::Impl(Impl { syntax }), 3155 IMPL => Item::Impl(Impl { syntax }),
3126 MACRO_CALL => Item::MacroCall(MacroCall { syntax }), 3156 MACRO_CALL => Item::MacroCall(MacroCall { syntax }),
3127 MACRO_RULES => Item::MacroRules(MacroRules { syntax }), 3157 MACRO_RULES => Item::MacroRules(MacroRules { syntax }),
3158 MACRO_DEF => Item::MacroDef(MacroDef { syntax }),
3128 MODULE => Item::Module(Module { syntax }), 3159 MODULE => Item::Module(Module { syntax }),
3129 STATIC => Item::Static(Static { syntax }), 3160 STATIC => Item::Static(Static { syntax }),
3130 STRUCT => Item::Struct(Struct { syntax }), 3161 STRUCT => Item::Struct(Struct { syntax }),
@@ -3146,6 +3177,7 @@ impl AstNode for Item {
3146 Item::Impl(it) => &it.syntax, 3177 Item::Impl(it) => &it.syntax,
3147 Item::MacroCall(it) => &it.syntax, 3178 Item::MacroCall(it) => &it.syntax,
3148 Item::MacroRules(it) => &it.syntax, 3179 Item::MacroRules(it) => &it.syntax,
3180 Item::MacroDef(it) => &it.syntax,
3149 Item::Module(it) => &it.syntax, 3181 Item::Module(it) => &it.syntax,
3150 Item::Static(it) => &it.syntax, 3182 Item::Static(it) => &it.syntax,
3151 Item::Struct(it) => &it.syntax, 3183 Item::Struct(it) => &it.syntax,
@@ -3495,6 +3527,11 @@ impl std::fmt::Display for NameRef {
3495 std::fmt::Display::fmt(self.syntax(), f) 3527 std::fmt::Display::fmt(self.syntax(), f)
3496 } 3528 }
3497} 3529}
3530impl std::fmt::Display for Lifetime {
3531 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3532 std::fmt::Display::fmt(self.syntax(), f)
3533 }
3534}
3498impl std::fmt::Display for Path { 3535impl std::fmt::Display for Path {
3499 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3536 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3500 std::fmt::Display::fmt(self.syntax(), f) 3537 std::fmt::Display::fmt(self.syntax(), f)
@@ -3615,6 +3652,11 @@ impl std::fmt::Display for MacroRules {
3615 std::fmt::Display::fmt(self.syntax(), f) 3652 std::fmt::Display::fmt(self.syntax(), f)
3616 } 3653 }
3617} 3654}
3655impl std::fmt::Display for MacroDef {
3656 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3657 std::fmt::Display::fmt(self.syntax(), f)
3658 }
3659}
3618impl std::fmt::Display for Module { 3660impl std::fmt::Display for Module {
3619 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3661 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3620 std::fmt::Display::fmt(self.syntax(), f) 3662 std::fmt::Display::fmt(self.syntax(), f)