diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 188f0df968e..2cb3ad01145 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs @@ -10,17 +10,6 @@ pub struct SourceFile { pub(crate) syntax: SyntaxNode, } -impl AstNode for SourceFile { - fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::ModuleItemOwner for SourceFile {} impl ast::AttrsOwner for SourceFile {} impl SourceFile { @@ -31,17 +20,6 @@ pub fn modules(&self) -> AstChildren { support::children(&self.syntax) } pub struct FnDef { pub(crate) syntax: SyntaxNode, } -impl AstNode for FnDef { - fn can_cast(kind: SyntaxKind) -> bool { kind == FN_DEF } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::VisibilityOwner for FnDef {} impl ast::NameOwner for FnDef {} impl ast::TypeParamsOwner for FnDef {} @@ -64,17 +42,6 @@ pub fn body(&self) -> Option { support::child(&self.syntax) } pub struct RetType { pub(crate) syntax: SyntaxNode, } -impl AstNode for RetType { - fn can_cast(kind: SyntaxKind) -> bool { kind == RET_TYPE } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl RetType { pub fn thin_arrow_token(&self) -> Option { support::token(&self.syntax, T![->]) } pub fn type_ref(&self) -> Option { support::child(&self.syntax) } @@ -84,17 +51,6 @@ pub fn type_ref(&self) -> Option { support::child(&self.syntax) } pub struct StructDef { pub(crate) syntax: SyntaxNode, } -impl AstNode for StructDef { - fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT_DEF } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::VisibilityOwner for StructDef {} impl ast::NameOwner for StructDef {} impl ast::TypeParamsOwner for StructDef {} @@ -110,17 +66,6 @@ pub fn field_def_list(&self) -> Option { support::child(&self.synt pub struct UnionDef { pub(crate) syntax: SyntaxNode, } -impl AstNode for UnionDef { - fn can_cast(kind: SyntaxKind) -> bool { kind == UNION_DEF } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::VisibilityOwner for UnionDef {} impl ast::NameOwner for UnionDef {} impl ast::TypeParamsOwner for UnionDef {} @@ -137,17 +82,6 @@ pub fn record_field_def_list(&self) -> Option { pub struct RecordFieldDefList { pub(crate) syntax: SyntaxNode, } -impl AstNode for RecordFieldDefList { - fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF_LIST } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl RecordFieldDefList { pub fn l_curly_token(&self) -> Option { support::token(&self.syntax, T!['{']) } pub fn fields(&self) -> AstChildren { support::children(&self.syntax) } @@ -158,17 +92,6 @@ pub fn r_curly_token(&self) -> Option { support::token(&self.syntax pub struct RecordFieldDef { pub(crate) syntax: SyntaxNode, } -impl AstNode for RecordFieldDef { - fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::VisibilityOwner for RecordFieldDef {} impl ast::NameOwner for RecordFieldDef {} impl ast::AttrsOwner for RecordFieldDef {} @@ -180,17 +103,6 @@ impl RecordFieldDef {} pub struct TupleFieldDefList { pub(crate) syntax: SyntaxNode, } -impl AstNode for TupleFieldDefList { - fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF_LIST } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl TupleFieldDefList { pub fn l_paren_token(&self) -> Option { support::token(&self.syntax, T!['(']) } pub fn fields(&self) -> AstChildren { support::children(&self.syntax) } @@ -201,17 +113,6 @@ pub fn r_paren_token(&self) -> Option { support::token(&self.syntax pub struct TupleFieldDef { pub(crate) syntax: SyntaxNode, } -impl AstNode for TupleFieldDef { - fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::VisibilityOwner for TupleFieldDef {} impl ast::AttrsOwner for TupleFieldDef {} impl TupleFieldDef { @@ -222,17 +123,6 @@ pub fn type_ref(&self) -> Option { support::child(&self.syntax) } pub struct EnumDef { pub(crate) syntax: SyntaxNode, } -impl AstNode for EnumDef { - fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_DEF } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::VisibilityOwner for EnumDef {} impl ast::NameOwner for EnumDef {} impl ast::TypeParamsOwner for EnumDef {} @@ -247,17 +137,6 @@ pub fn variant_list(&self) -> Option { support::child(&self.syn pub struct EnumVariantList { pub(crate) syntax: SyntaxNode, } -impl AstNode for EnumVariantList { - fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT_LIST } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl EnumVariantList { pub fn l_curly_token(&self) -> Option { support::token(&self.syntax, T!['{']) } pub fn variants(&self) -> AstChildren { support::children(&self.syntax) } @@ -268,17 +147,6 @@ pub fn r_curly_token(&self) -> Option { support::token(&self.syntax pub struct EnumVariant { pub(crate) syntax: SyntaxNode, } -impl AstNode for EnumVariant { - fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::VisibilityOwner for EnumVariant {} impl ast::NameOwner for EnumVariant {} impl ast::DocCommentsOwner for EnumVariant {} @@ -293,17 +161,6 @@ pub fn expr(&self) -> Option { support::child(&self.syntax) } pub struct TraitDef { pub(crate) syntax: SyntaxNode, } -impl AstNode for TraitDef { - fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT_DEF } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::VisibilityOwner for TraitDef {} impl ast::NameOwner for TraitDef {} impl ast::AttrsOwner for TraitDef {} @@ -321,17 +178,6 @@ pub fn item_list(&self) -> Option { support::child(&self.syntax) } pub struct Module { pub(crate) syntax: SyntaxNode, } -impl AstNode for Module { - fn can_cast(kind: SyntaxKind) -> bool { kind == MODULE } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::VisibilityOwner for Module {} impl ast::NameOwner for Module {} impl ast::AttrsOwner for Module {} @@ -346,17 +192,6 @@ pub fn item_list(&self) -> Option { support::child(&self.syntax) } pub struct ItemList { pub(crate) syntax: SyntaxNode, } -impl AstNode for ItemList { - fn can_cast(kind: SyntaxKind) -> bool { kind == ITEM_LIST } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::ModuleItemOwner for ItemList {} impl ItemList { pub fn l_curly_token(&self) -> Option { support::token(&self.syntax, T!['{']) } @@ -368,17 +203,6 @@ pub fn r_curly_token(&self) -> Option { support::token(&self.syntax pub struct ConstDef { pub(crate) syntax: SyntaxNode, } -impl AstNode for ConstDef { - fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_DEF } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::VisibilityOwner for ConstDef {} impl ast::NameOwner for ConstDef {} impl ast::TypeParamsOwner for ConstDef {} @@ -397,17 +221,6 @@ pub fn body(&self) -> Option { support::child(&self.syntax) } pub struct StaticDef { pub(crate) syntax: SyntaxNode, } -impl AstNode for StaticDef { - fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC_DEF } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::VisibilityOwner for StaticDef {} impl ast::NameOwner for StaticDef {} impl ast::TypeParamsOwner for StaticDef {} @@ -426,17 +239,6 @@ pub fn body(&self) -> Option { support::child(&self.syntax) } pub struct TypeAliasDef { pub(crate) syntax: SyntaxNode, } -impl AstNode for TypeAliasDef { - fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS_DEF } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::VisibilityOwner for TypeAliasDef {} impl ast::NameOwner for TypeAliasDef {} impl ast::TypeParamsOwner for TypeAliasDef {} @@ -455,17 +257,6 @@ pub fn type_ref(&self) -> Option { support::child(&self.syntax) } pub struct ImplDef { pub(crate) syntax: SyntaxNode, } -impl AstNode for ImplDef { - fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_DEF } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::TypeParamsOwner for ImplDef {} impl ast::AttrsOwner for ImplDef {} impl ImplDef { @@ -482,17 +273,6 @@ pub fn item_list(&self) -> Option { support::child(&self.syntax) } pub struct ParenType { pub(crate) syntax: SyntaxNode, } -impl AstNode for ParenType { - fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_TYPE } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ParenType { pub fn l_paren_token(&self) -> Option { support::token(&self.syntax, T!['(']) } pub fn type_ref(&self) -> Option { support::child(&self.syntax) } @@ -503,17 +283,6 @@ pub fn r_paren_token(&self) -> Option { support::token(&self.syntax pub struct TupleType { pub(crate) syntax: SyntaxNode, } -impl AstNode for TupleType { - fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_TYPE } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl TupleType { pub fn l_paren_token(&self) -> Option { support::token(&self.syntax, T!['(']) } pub fn fields(&self) -> AstChildren { support::children(&self.syntax) } @@ -524,17 +293,6 @@ pub fn r_paren_token(&self) -> Option { support::token(&self.syntax pub struct NeverType { pub(crate) syntax: SyntaxNode, } -impl AstNode for NeverType { - fn can_cast(kind: SyntaxKind) -> bool { kind == NEVER_TYPE } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl NeverType { pub fn excl_token(&self) -> Option { support::token(&self.syntax, T![!]) } } @@ -543,17 +301,6 @@ pub fn excl_token(&self) -> Option { support::token(&self.syntax, T pub struct PathType { pub(crate) syntax: SyntaxNode, } -impl AstNode for PathType { - fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_TYPE } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl PathType { pub fn path(&self) -> Option { support::child(&self.syntax) } } @@ -562,17 +309,6 @@ pub fn path(&self) -> Option { support::child(&self.syntax) } pub struct PointerType { pub(crate) syntax: SyntaxNode, } -impl AstNode for PointerType { - fn can_cast(kind: SyntaxKind) -> bool { kind == POINTER_TYPE } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl PointerType { pub fn star_token(&self) -> Option { support::token(&self.syntax, T![*]) } pub fn const_token(&self) -> Option { support::token(&self.syntax, T![const]) } @@ -584,17 +320,6 @@ pub fn type_ref(&self) -> Option { support::child(&self.syntax) } pub struct ArrayType { pub(crate) syntax: SyntaxNode, } -impl AstNode for ArrayType { - fn can_cast(kind: SyntaxKind) -> bool { kind == ARRAY_TYPE } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ArrayType { pub fn l_brack_token(&self) -> Option { support::token(&self.syntax, T!['[']) } pub fn type_ref(&self) -> Option { support::child(&self.syntax) } @@ -607,17 +332,6 @@ pub fn r_brack_token(&self) -> Option { support::token(&self.syntax pub struct SliceType { pub(crate) syntax: SyntaxNode, } -impl AstNode for SliceType { - fn can_cast(kind: SyntaxKind) -> bool { kind == SLICE_TYPE } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl SliceType { pub fn l_brack_token(&self) -> Option { support::token(&self.syntax, T!['[']) } pub fn type_ref(&self) -> Option { support::child(&self.syntax) } @@ -628,17 +342,6 @@ pub fn r_brack_token(&self) -> Option { support::token(&self.syntax pub struct ReferenceType { pub(crate) syntax: SyntaxNode, } -impl AstNode for ReferenceType { - fn can_cast(kind: SyntaxKind) -> bool { kind == REFERENCE_TYPE } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ReferenceType { pub fn amp_token(&self) -> Option { support::token(&self.syntax, T![&]) } pub fn lifetime_token(&self) -> Option { @@ -652,17 +355,6 @@ pub fn type_ref(&self) -> Option { support::child(&self.syntax) } pub struct PlaceholderType { pub(crate) syntax: SyntaxNode, } -impl AstNode for PlaceholderType { - fn can_cast(kind: SyntaxKind) -> bool { kind == PLACEHOLDER_TYPE } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl PlaceholderType { pub fn underscore_token(&self) -> Option { support::token(&self.syntax, T![_]) } } @@ -671,17 +363,6 @@ pub fn underscore_token(&self) -> Option { support::token(&self.syn pub struct FnPointerType { pub(crate) syntax: SyntaxNode, } -impl AstNode for FnPointerType { - fn can_cast(kind: SyntaxKind) -> bool { kind == FN_POINTER_TYPE } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl FnPointerType { pub fn abi(&self) -> Option { support::child(&self.syntax) } pub fn unsafe_token(&self) -> Option { support::token(&self.syntax, T![unsafe]) } @@ -694,17 +375,6 @@ pub fn ret_type(&self) -> Option { support::child(&self.syntax) } pub struct ForType { pub(crate) syntax: SyntaxNode, } -impl AstNode for ForType { - fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_TYPE } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ForType { pub fn for_token(&self) -> Option { support::token(&self.syntax, T![for]) } pub fn type_param_list(&self) -> Option { support::child(&self.syntax) } @@ -715,17 +385,6 @@ pub fn type_ref(&self) -> Option { support::child(&self.syntax) } pub struct ImplTraitType { pub(crate) syntax: SyntaxNode, } -impl AstNode for ImplTraitType { - fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_TRAIT_TYPE } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::TypeBoundsOwner for ImplTraitType {} impl ImplTraitType { pub fn impl_token(&self) -> Option { support::token(&self.syntax, T![impl]) } @@ -735,17 +394,6 @@ pub fn impl_token(&self) -> Option { support::token(&self.syntax, T pub struct DynTraitType { pub(crate) syntax: SyntaxNode, } -impl AstNode for DynTraitType { - fn can_cast(kind: SyntaxKind) -> bool { kind == DYN_TRAIT_TYPE } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::TypeBoundsOwner for DynTraitType {} impl DynTraitType { pub fn dyn_token(&self) -> Option { support::token(&self.syntax, T![dyn]) } @@ -755,17 +403,6 @@ pub fn dyn_token(&self) -> Option { support::token(&self.syntax, T! pub struct TupleExpr { pub(crate) syntax: SyntaxNode, } -impl AstNode for TupleExpr { - fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_EXPR } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::AttrsOwner for TupleExpr {} impl TupleExpr { pub fn l_paren_token(&self) -> Option { support::token(&self.syntax, T!['(']) } @@ -777,17 +414,6 @@ pub fn r_paren_token(&self) -> Option { support::token(&self.syntax pub struct ArrayExpr { pub(crate) syntax: SyntaxNode, } -impl AstNode for ArrayExpr { - fn can_cast(kind: SyntaxKind) -> bool { kind == ARRAY_EXPR } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::AttrsOwner for ArrayExpr {} impl ArrayExpr { pub fn l_brack_token(&self) -> Option { support::token(&self.syntax, T!['[']) } @@ -800,17 +426,6 @@ pub fn r_brack_token(&self) -> Option { support::token(&self.syntax pub struct ParenExpr { pub(crate) syntax: SyntaxNode, } -impl AstNode for ParenExpr { - fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_EXPR } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::AttrsOwner for ParenExpr {} impl ParenExpr { pub fn l_paren_token(&self) -> Option { support::token(&self.syntax, T!['(']) } @@ -822,17 +437,6 @@ pub fn r_paren_token(&self) -> Option { support::token(&self.syntax pub struct PathExpr { pub(crate) syntax: SyntaxNode, } -impl AstNode for PathExpr { - fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_EXPR } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl PathExpr { pub fn path(&self) -> Option { support::child(&self.syntax) } } @@ -841,17 +445,6 @@ pub fn path(&self) -> Option { support::child(&self.syntax) } pub struct LambdaExpr { pub(crate) syntax: SyntaxNode, } -impl AstNode for LambdaExpr { - fn can_cast(kind: SyntaxKind) -> bool { kind == LAMBDA_EXPR } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::AttrsOwner for LambdaExpr {} impl LambdaExpr { pub fn static_token(&self) -> Option { support::token(&self.syntax, T![static]) } @@ -866,17 +459,6 @@ pub fn body(&self) -> Option { support::child(&self.syntax) } pub struct IfExpr { pub(crate) syntax: SyntaxNode, } -impl AstNode for IfExpr { - fn can_cast(kind: SyntaxKind) -> bool { kind == IF_EXPR } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::AttrsOwner for IfExpr {} impl IfExpr { pub fn if_token(&self) -> Option { support::token(&self.syntax, T![if]) } @@ -887,17 +469,6 @@ pub fn condition(&self) -> Option { support::child(&self.syntax) } pub struct LoopExpr { pub(crate) syntax: SyntaxNode, } -impl AstNode for LoopExpr { - fn can_cast(kind: SyntaxKind) -> bool { kind == LOOP_EXPR } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::AttrsOwner for LoopExpr {} impl ast::LoopBodyOwner for LoopExpr {} impl LoopExpr { @@ -908,17 +479,6 @@ pub fn loop_token(&self) -> Option { support::token(&self.syntax, T pub struct TryBlockExpr { pub(crate) syntax: SyntaxNode, } -impl AstNode for TryBlockExpr { - fn can_cast(kind: SyntaxKind) -> bool { kind == TRY_BLOCK_EXPR } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::AttrsOwner for TryBlockExpr {} impl TryBlockExpr { pub fn try_token(&self) -> Option { support::token(&self.syntax, T![try]) } @@ -929,17 +489,6 @@ pub fn body(&self) -> Option { support::child(&self.syntax) } pub struct ForExpr { pub(crate) syntax: SyntaxNode, } -impl AstNode for ForExpr { - fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_EXPR } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::AttrsOwner for ForExpr {} impl ast::LoopBodyOwner for ForExpr {} impl ForExpr { @@ -953,17 +502,6 @@ pub fn iterable(&self) -> Option { support::child(&self.syntax) } pub struct WhileExpr { pub(crate) syntax: SyntaxNode, } -impl AstNode for WhileExpr { - fn can_cast(kind: SyntaxKind) -> bool { kind == WHILE_EXPR } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::AttrsOwner for WhileExpr {} impl ast::LoopBodyOwner for WhileExpr {} impl WhileExpr { @@ -975,17 +513,6 @@ pub fn condition(&self) -> Option { support::child(&self.syntax) } pub struct ContinueExpr { pub(crate) syntax: SyntaxNode, } -impl AstNode for ContinueExpr { - fn can_cast(kind: SyntaxKind) -> bool { kind == CONTINUE_EXPR } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::AttrsOwner for ContinueExpr {} impl ContinueExpr { pub fn continue_token(&self) -> Option { @@ -1000,17 +527,6 @@ pub fn lifetime_token(&self) -> Option { pub struct BreakExpr { pub(crate) syntax: SyntaxNode, } -impl AstNode for BreakExpr { - fn can_cast(kind: SyntaxKind) -> bool { kind == BREAK_EXPR } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::AttrsOwner for BreakExpr {} impl BreakExpr { pub fn break_token(&self) -> Option { support::token(&self.syntax, T![break]) } @@ -1024,17 +540,6 @@ pub fn expr(&self) -> Option { support::child(&self.syntax) } pub struct Label { pub(crate) syntax: SyntaxNode, } -impl AstNode for Label { - fn can_cast(kind: SyntaxKind) -> bool { kind == LABEL } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl Label { pub fn lifetime_token(&self) -> Option { support::token(&self.syntax, T![lifetime]) @@ -1045,17 +550,6 @@ pub fn lifetime_token(&self) -> Option { pub struct BlockExpr { pub(crate) syntax: SyntaxNode, } -impl AstNode for BlockExpr { - fn can_cast(kind: SyntaxKind) -> bool { kind == BLOCK_EXPR } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl ast::AttrsOwner for BlockExpr {} impl BlockExpr { pub fn label(&self) -> Option