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.rs80
1 files changed, 69 insertions, 11 deletions
diff --git a/crates/syntax/src/ast/generated/nodes.rs b/crates/syntax/src/ast/generated/nodes.rs
index 92ed2ee9d..5baa54a3f 100644
--- a/crates/syntax/src/ast/generated/nodes.rs
+++ b/crates/syntax/src/ast/generated/nodes.rs
@@ -11,6 +11,7 @@ pub struct Name {
11} 11}
12impl Name { 12impl Name {
13 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) } 13 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) }
14 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
14} 15}
15#[derive(Debug, Clone, PartialEq, Eq, Hash)] 16#[derive(Debug, Clone, PartialEq, Eq, Hash)]
16pub struct NameRef { 17pub struct NameRef {
@@ -18,6 +19,9 @@ pub struct NameRef {
18} 19}
19impl NameRef { 20impl NameRef {
20 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) } 21 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) }
22 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
23 pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) }
24 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
21} 25}
22#[derive(Debug, Clone, PartialEq, Eq, Hash)] 26#[derive(Debug, Clone, PartialEq, Eq, Hash)]
23pub struct Lifetime { 27pub struct Lifetime {
@@ -42,9 +46,6 @@ pub struct PathSegment {
42 pub(crate) syntax: SyntaxNode, 46 pub(crate) syntax: SyntaxNode,
43} 47}
44impl PathSegment { 48impl PathSegment {
45 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
46 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
47 pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) }
48 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) } 49 pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
49 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 50 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
50 pub fn generic_arg_list(&self) -> Option<GenericArgList> { support::child(&self.syntax) } 51 pub fn generic_arg_list(&self) -> Option<GenericArgList> { support::child(&self.syntax) }
@@ -238,7 +239,6 @@ impl ExternCrate {
238 pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) } 239 pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) }
239 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) } 240 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
240 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 241 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
241 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
242 pub fn rename(&self) -> Option<Rename> { support::child(&self.syntax) } 242 pub fn rename(&self) -> Option<Rename> { support::child(&self.syntax) }
243 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 243 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
244} 244}
@@ -406,9 +406,6 @@ pub struct Visibility {
406impl Visibility { 406impl Visibility {
407 pub fn pub_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![pub]) } 407 pub fn pub_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![pub]) }
408 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } 408 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
409 pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) }
410 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
411 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
412 pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) } 409 pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) }
413 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 410 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
414 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 411 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
@@ -492,11 +489,11 @@ pub struct SelfParam {
492 pub(crate) syntax: SyntaxNode, 489 pub(crate) syntax: SyntaxNode,
493} 490}
494impl ast::AttrsOwner for SelfParam {} 491impl ast::AttrsOwner for SelfParam {}
492impl ast::NameOwner for SelfParam {}
495impl SelfParam { 493impl SelfParam {
496 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) } 494 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
497 pub fn lifetime(&self) -> Option<Lifetime> { support::child(&self.syntax) } 495 pub fn lifetime(&self) -> Option<Lifetime> { support::child(&self.syntax) }
498 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 496 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
499 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
500 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } 497 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
501 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } 498 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
502} 499}
@@ -931,6 +928,15 @@ impl WhileExpr {
931 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } 928 pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
932} 929}
933#[derive(Debug, Clone, PartialEq, Eq, Hash)] 930#[derive(Debug, Clone, PartialEq, Eq, Hash)]
931pub struct YieldExpr {
932 pub(crate) syntax: SyntaxNode,
933}
934impl ast::AttrsOwner for YieldExpr {}
935impl YieldExpr {
936 pub fn yield_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![yield]) }
937 pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
938}
939#[derive(Debug, Clone, PartialEq, Eq, Hash)]
934pub struct Label { 940pub struct Label {
935 pub(crate) syntax: SyntaxNode, 941 pub(crate) syntax: SyntaxNode,
936} 942}
@@ -1066,6 +1072,13 @@ impl InferType {
1066 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) } 1072 pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) }
1067} 1073}
1068#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1074#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1075pub struct MacroType {
1076 pub(crate) syntax: SyntaxNode,
1077}
1078impl MacroType {
1079 pub fn macro_call(&self) -> Option<MacroCall> { support::child(&self.syntax) }
1080}
1081#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1069pub struct NeverType { 1082pub struct NeverType {
1070 pub(crate) syntax: SyntaxNode, 1083 pub(crate) syntax: SyntaxNode,
1071} 1084}
@@ -1294,6 +1307,7 @@ pub enum Type {
1294 ForType(ForType), 1307 ForType(ForType),
1295 ImplTraitType(ImplTraitType), 1308 ImplTraitType(ImplTraitType),
1296 InferType(InferType), 1309 InferType(InferType),
1310 MacroType(MacroType),
1297 NeverType(NeverType), 1311 NeverType(NeverType),
1298 ParenType(ParenType), 1312 ParenType(ParenType),
1299 PathType(PathType), 1313 PathType(PathType),
@@ -1334,6 +1348,7 @@ pub enum Expr {
1334 TryExpr(TryExpr), 1348 TryExpr(TryExpr),
1335 TupleExpr(TupleExpr), 1349 TupleExpr(TupleExpr),
1336 WhileExpr(WhileExpr), 1350 WhileExpr(WhileExpr),
1351 YieldExpr(YieldExpr),
1337} 1352}
1338#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1353#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1339pub enum Item { 1354pub enum Item {
@@ -2386,6 +2401,17 @@ impl AstNode for WhileExpr {
2386 } 2401 }
2387 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2402 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2388} 2403}
2404impl AstNode for YieldExpr {
2405 fn can_cast(kind: SyntaxKind) -> bool { kind == YIELD_EXPR }
2406 fn cast(syntax: SyntaxNode) -> Option<Self> {
2407 if Self::can_cast(syntax.kind()) {
2408 Some(Self { syntax })
2409 } else {
2410 None
2411 }
2412 }
2413 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2414}
2389impl AstNode for Label { 2415impl AstNode for Label {
2390 fn can_cast(kind: SyntaxKind) -> bool { kind == LABEL } 2416 fn can_cast(kind: SyntaxKind) -> bool { kind == LABEL }
2391 fn cast(syntax: SyntaxNode) -> Option<Self> { 2417 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2540,6 +2566,17 @@ impl AstNode for InferType {
2540 } 2566 }
2541 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2567 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2542} 2568}
2569impl AstNode for MacroType {
2570 fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_TYPE }
2571 fn cast(syntax: SyntaxNode) -> Option<Self> {
2572 if Self::can_cast(syntax.kind()) {
2573 Some(Self { syntax })
2574 } else {
2575 None
2576 }
2577 }
2578 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2579}
2543impl AstNode for NeverType { 2580impl AstNode for NeverType {
2544 fn can_cast(kind: SyntaxKind) -> bool { kind == NEVER_TYPE } 2581 fn can_cast(kind: SyntaxKind) -> bool { kind == NEVER_TYPE }
2545 fn cast(syntax: SyntaxNode) -> Option<Self> { 2582 fn cast(syntax: SyntaxNode) -> Option<Self> {
@@ -2871,6 +2908,9 @@ impl From<ImplTraitType> for Type {
2871impl From<InferType> for Type { 2908impl From<InferType> for Type {
2872 fn from(node: InferType) -> Type { Type::InferType(node) } 2909 fn from(node: InferType) -> Type { Type::InferType(node) }
2873} 2910}
2911impl From<MacroType> for Type {
2912 fn from(node: MacroType) -> Type { Type::MacroType(node) }
2913}
2874impl From<NeverType> for Type { 2914impl From<NeverType> for Type {
2875 fn from(node: NeverType) -> Type { Type::NeverType(node) } 2915 fn from(node: NeverType) -> Type { Type::NeverType(node) }
2876} 2916}
@@ -2896,8 +2936,8 @@ impl AstNode for Type {
2896 fn can_cast(kind: SyntaxKind) -> bool { 2936 fn can_cast(kind: SyntaxKind) -> bool {
2897 match kind { 2937 match kind {
2898 ARRAY_TYPE | DYN_TRAIT_TYPE | FN_PTR_TYPE | FOR_TYPE | IMPL_TRAIT_TYPE | INFER_TYPE 2938 ARRAY_TYPE | DYN_TRAIT_TYPE | FN_PTR_TYPE | FOR_TYPE | IMPL_TRAIT_TYPE | INFER_TYPE
2899 | NEVER_TYPE | PAREN_TYPE | PATH_TYPE | PTR_TYPE | REF_TYPE | SLICE_TYPE 2939 | MACRO_TYPE | NEVER_TYPE | PAREN_TYPE | PATH_TYPE | PTR_TYPE | REF_TYPE
2900 | TUPLE_TYPE => true, 2940 | SLICE_TYPE | TUPLE_TYPE => true,
2901 _ => false, 2941 _ => false,
2902 } 2942 }
2903 } 2943 }
@@ -2909,6 +2949,7 @@ impl AstNode for Type {
2909 FOR_TYPE => Type::ForType(ForType { syntax }), 2949 FOR_TYPE => Type::ForType(ForType { syntax }),
2910 IMPL_TRAIT_TYPE => Type::ImplTraitType(ImplTraitType { syntax }), 2950 IMPL_TRAIT_TYPE => Type::ImplTraitType(ImplTraitType { syntax }),
2911 INFER_TYPE => Type::InferType(InferType { syntax }), 2951 INFER_TYPE => Type::InferType(InferType { syntax }),
2952 MACRO_TYPE => Type::MacroType(MacroType { syntax }),
2912 NEVER_TYPE => Type::NeverType(NeverType { syntax }), 2953 NEVER_TYPE => Type::NeverType(NeverType { syntax }),
2913 PAREN_TYPE => Type::ParenType(ParenType { syntax }), 2954 PAREN_TYPE => Type::ParenType(ParenType { syntax }),
2914 PATH_TYPE => Type::PathType(PathType { syntax }), 2955 PATH_TYPE => Type::PathType(PathType { syntax }),
@@ -2928,6 +2969,7 @@ impl AstNode for Type {
2928 Type::ForType(it) => &it.syntax, 2969 Type::ForType(it) => &it.syntax,
2929 Type::ImplTraitType(it) => &it.syntax, 2970 Type::ImplTraitType(it) => &it.syntax,
2930 Type::InferType(it) => &it.syntax, 2971 Type::InferType(it) => &it.syntax,
2972 Type::MacroType(it) => &it.syntax,
2931 Type::NeverType(it) => &it.syntax, 2973 Type::NeverType(it) => &it.syntax,
2932 Type::ParenType(it) => &it.syntax, 2974 Type::ParenType(it) => &it.syntax,
2933 Type::PathType(it) => &it.syntax, 2975 Type::PathType(it) => &it.syntax,
@@ -3028,6 +3070,9 @@ impl From<TupleExpr> for Expr {
3028impl From<WhileExpr> for Expr { 3070impl From<WhileExpr> for Expr {
3029 fn from(node: WhileExpr) -> Expr { Expr::WhileExpr(node) } 3071 fn from(node: WhileExpr) -> Expr { Expr::WhileExpr(node) }
3030} 3072}
3073impl From<YieldExpr> for Expr {
3074 fn from(node: YieldExpr) -> Expr { Expr::YieldExpr(node) }
3075}
3031impl AstNode for Expr { 3076impl AstNode for Expr {
3032 fn can_cast(kind: SyntaxKind) -> bool { 3077 fn can_cast(kind: SyntaxKind) -> bool {
3033 match kind { 3078 match kind {
@@ -3035,7 +3080,8 @@ impl AstNode for Expr {
3035 | CAST_EXPR | CLOSURE_EXPR | CONTINUE_EXPR | EFFECT_EXPR | FIELD_EXPR | FOR_EXPR 3080 | CAST_EXPR | CLOSURE_EXPR | CONTINUE_EXPR | EFFECT_EXPR | FIELD_EXPR | FOR_EXPR
3036 | IF_EXPR | INDEX_EXPR | LITERAL | LOOP_EXPR | MACRO_CALL | MATCH_EXPR 3081 | IF_EXPR | INDEX_EXPR | LITERAL | LOOP_EXPR | MACRO_CALL | MATCH_EXPR
3037 | METHOD_CALL_EXPR | PAREN_EXPR | PATH_EXPR | PREFIX_EXPR | RANGE_EXPR 3082 | METHOD_CALL_EXPR | PAREN_EXPR | PATH_EXPR | PREFIX_EXPR | RANGE_EXPR
3038 | RECORD_EXPR | REF_EXPR | RETURN_EXPR | TRY_EXPR | TUPLE_EXPR | WHILE_EXPR => true, 3083 | RECORD_EXPR | REF_EXPR | RETURN_EXPR | TRY_EXPR | TUPLE_EXPR | WHILE_EXPR
3084 | YIELD_EXPR => true,
3039 _ => false, 3085 _ => false,
3040 } 3086 }
3041 } 3087 }
@@ -3071,6 +3117,7 @@ impl AstNode for Expr {
3071 TRY_EXPR => Expr::TryExpr(TryExpr { syntax }), 3117 TRY_EXPR => Expr::TryExpr(TryExpr { syntax }),
3072 TUPLE_EXPR => Expr::TupleExpr(TupleExpr { syntax }), 3118 TUPLE_EXPR => Expr::TupleExpr(TupleExpr { syntax }),
3073 WHILE_EXPR => Expr::WhileExpr(WhileExpr { syntax }), 3119 WHILE_EXPR => Expr::WhileExpr(WhileExpr { syntax }),
3120 YIELD_EXPR => Expr::YieldExpr(YieldExpr { syntax }),
3074 _ => return None, 3121 _ => return None,
3075 }; 3122 };
3076 Some(res) 3123 Some(res)
@@ -3107,6 +3154,7 @@ impl AstNode for Expr {
3107 Expr::TryExpr(it) => &it.syntax, 3154 Expr::TryExpr(it) => &it.syntax,
3108 Expr::TupleExpr(it) => &it.syntax, 3155 Expr::TupleExpr(it) => &it.syntax,
3109 Expr::WhileExpr(it) => &it.syntax, 3156 Expr::WhileExpr(it) => &it.syntax,
3157 Expr::YieldExpr(it) => &it.syntax,
3110 } 3158 }
3111 } 3159 }
3112} 3160}
@@ -3983,6 +4031,11 @@ impl std::fmt::Display for WhileExpr {
3983 std::fmt::Display::fmt(self.syntax(), f) 4031 std::fmt::Display::fmt(self.syntax(), f)
3984 } 4032 }
3985} 4033}
4034impl std::fmt::Display for YieldExpr {
4035 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4036 std::fmt::Display::fmt(self.syntax(), f)
4037 }
4038}
3986impl std::fmt::Display for Label { 4039impl std::fmt::Display for Label {
3987 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4040 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3988 std::fmt::Display::fmt(self.syntax(), f) 4041 std::fmt::Display::fmt(self.syntax(), f)
@@ -4053,6 +4106,11 @@ impl std::fmt::Display for InferType {
4053 std::fmt::Display::fmt(self.syntax(), f) 4106 std::fmt::Display::fmt(self.syntax(), f)
4054 } 4107 }
4055} 4108}
4109impl std::fmt::Display for MacroType {
4110 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4111 std::fmt::Display::fmt(self.syntax(), f)
4112 }
4113}
4056impl std::fmt::Display for NeverType { 4114impl std::fmt::Display for NeverType {
4057 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 4115 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4058 std::fmt::Display::fmt(self.syntax(), f) 4116 std::fmt::Display::fmt(self.syntax(), f)