From 9285cbffb66e1c497469fedc5c181b7f295742fd Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 9 Apr 2020 18:08:54 +0200 Subject: More compact --- crates/ra_syntax/src/ast/generated/nodes.rs | 875 ++++----------------------- crates/ra_syntax/src/ast/generated/tokens.rs | 793 ++++-------------------- xtask/src/codegen/gen_syntax.rs | 12 +- 3 files changed, 241 insertions(+), 1439 deletions(-) diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 6e258250c..846212a6f 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs @@ -16,12 +16,7 @@ impl std::fmt::Display for SourceFile { } } impl AstNode for SourceFile { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - SOURCE_FILE => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -47,12 +42,7 @@ impl std::fmt::Display for FnDef { } } impl AstNode for FnDef { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - FN_DEF => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == FN_DEF } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -89,12 +79,7 @@ impl std::fmt::Display for RetType { } } impl AstNode for RetType { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - RET_TYPE => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == RET_TYPE } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -118,12 +103,7 @@ impl std::fmt::Display for StructDef { } } impl AstNode for StructDef { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - STRUCT_DEF => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT_DEF } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -153,12 +133,7 @@ impl std::fmt::Display for UnionDef { } } impl AstNode for UnionDef { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - UNION_DEF => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == UNION_DEF } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -189,12 +164,7 @@ impl std::fmt::Display for RecordFieldDefList { } } impl AstNode for RecordFieldDefList { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - RECORD_FIELD_DEF_LIST => true, - _ => false, - } - } + 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 }) @@ -219,12 +189,7 @@ impl std::fmt::Display for RecordFieldDef { } } impl AstNode for RecordFieldDef { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - RECORD_FIELD_DEF => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -250,12 +215,7 @@ impl std::fmt::Display for TupleFieldDefList { } } impl AstNode for TupleFieldDefList { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - TUPLE_FIELD_DEF_LIST => true, - _ => false, - } - } + 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 }) @@ -280,12 +240,7 @@ impl std::fmt::Display for TupleFieldDef { } } impl AstNode for TupleFieldDef { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - TUPLE_FIELD_DEF => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -310,12 +265,7 @@ impl std::fmt::Display for EnumDef { } } impl AstNode for EnumDef { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - ENUM_DEF => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_DEF } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -344,12 +294,7 @@ impl std::fmt::Display for EnumVariantList { } } impl AstNode for EnumVariantList { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - ENUM_VARIANT_LIST => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT_LIST } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -374,12 +319,7 @@ impl std::fmt::Display for EnumVariant { } } impl AstNode for EnumVariant { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - ENUM_VARIANT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -408,12 +348,7 @@ impl std::fmt::Display for TraitDef { } } impl AstNode for TraitDef { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - TRAIT_DEF => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT_DEF } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -445,12 +380,7 @@ impl std::fmt::Display for Module { } } impl AstNode for Module { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - MODULE => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == MODULE } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -479,12 +409,7 @@ impl std::fmt::Display for ItemList { } } impl AstNode for ItemList { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - ITEM_LIST => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == ITEM_LIST } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -511,12 +436,7 @@ impl std::fmt::Display for ConstDef { } } impl AstNode for ConstDef { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - CONST_DEF => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_DEF } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -549,12 +469,7 @@ impl std::fmt::Display for StaticDef { } } impl AstNode for StaticDef { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - STATIC_DEF => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC_DEF } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -587,12 +502,7 @@ impl std::fmt::Display for TypeAliasDef { } } impl AstNode for TypeAliasDef { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - TYPE_ALIAS_DEF => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS_DEF } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -625,12 +535,7 @@ impl std::fmt::Display for ImplDef { } } impl AstNode for ImplDef { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - IMPL_DEF => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_DEF } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -661,12 +566,7 @@ impl std::fmt::Display for ParenType { } } impl AstNode for ParenType { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - PAREN_TYPE => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_TYPE } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -691,12 +591,7 @@ impl std::fmt::Display for TupleType { } } impl AstNode for TupleType { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - TUPLE_TYPE => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_TYPE } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -721,12 +616,7 @@ impl std::fmt::Display for NeverType { } } impl AstNode for NeverType { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - NEVER_TYPE => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == NEVER_TYPE } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -749,12 +639,7 @@ impl std::fmt::Display for PathType { } } impl AstNode for PathType { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - PATH_TYPE => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_TYPE } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -777,12 +662,7 @@ impl std::fmt::Display for PointerType { } } impl AstNode for PointerType { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - POINTER_TYPE => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == POINTER_TYPE } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -807,12 +687,7 @@ impl std::fmt::Display for ArrayType { } } impl AstNode for ArrayType { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - ARRAY_TYPE => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == ARRAY_TYPE } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -839,12 +714,7 @@ impl std::fmt::Display for SliceType { } } impl AstNode for SliceType { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - SLICE_TYPE => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == SLICE_TYPE } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -869,12 +739,7 @@ impl std::fmt::Display for ReferenceType { } } impl AstNode for ReferenceType { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - REFERENCE_TYPE => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == REFERENCE_TYPE } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -900,12 +765,7 @@ impl std::fmt::Display for PlaceholderType { } } impl AstNode for PlaceholderType { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - PLACEHOLDER_TYPE => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == PLACEHOLDER_TYPE } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -928,12 +788,7 @@ impl std::fmt::Display for FnPointerType { } } impl AstNode for FnPointerType { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - FN_POINTER_TYPE => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == FN_POINTER_TYPE } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -960,12 +815,7 @@ impl std::fmt::Display for ForType { } } impl AstNode for ForType { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - FOR_TYPE => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_TYPE } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -990,12 +840,7 @@ impl std::fmt::Display for ImplTraitType { } } impl AstNode for ImplTraitType { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - IMPL_TRAIT_TYPE => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_TRAIT_TYPE } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1019,12 +864,7 @@ impl std::fmt::Display for DynTraitType { } } impl AstNode for DynTraitType { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - DYN_TRAIT_TYPE => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == DYN_TRAIT_TYPE } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1048,12 +888,7 @@ impl std::fmt::Display for TupleExpr { } } impl AstNode for TupleExpr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - TUPLE_EXPR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_EXPR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1079,12 +914,7 @@ impl std::fmt::Display for ArrayExpr { } } impl AstNode for ArrayExpr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - ARRAY_EXPR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == ARRAY_EXPR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1111,12 +941,7 @@ impl std::fmt::Display for ParenExpr { } } impl AstNode for ParenExpr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - PAREN_EXPR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_EXPR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1142,12 +967,7 @@ impl std::fmt::Display for PathExpr { } } impl AstNode for PathExpr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - PATH_EXPR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_EXPR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1170,12 +990,7 @@ impl std::fmt::Display for LambdaExpr { } } impl AstNode for LambdaExpr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - LAMBDA_EXPR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == LAMBDA_EXPR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1204,12 +1019,7 @@ impl std::fmt::Display for IfExpr { } } impl AstNode for IfExpr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - IF_EXPR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == IF_EXPR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1234,12 +1044,7 @@ impl std::fmt::Display for LoopExpr { } } impl AstNode for LoopExpr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - LOOP_EXPR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == LOOP_EXPR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1264,12 +1069,7 @@ impl std::fmt::Display for TryBlockExpr { } } impl AstNode for TryBlockExpr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - TRY_BLOCK_EXPR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == TRY_BLOCK_EXPR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1294,12 +1094,7 @@ impl std::fmt::Display for ForExpr { } } impl AstNode for ForExpr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - FOR_EXPR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_EXPR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1327,12 +1122,7 @@ impl std::fmt::Display for WhileExpr { } } impl AstNode for WhileExpr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - WHILE_EXPR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == WHILE_EXPR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1358,12 +1148,7 @@ impl std::fmt::Display for ContinueExpr { } } impl AstNode for ContinueExpr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - CONTINUE_EXPR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == CONTINUE_EXPR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1388,12 +1173,7 @@ impl std::fmt::Display for BreakExpr { } } impl AstNode for BreakExpr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - BREAK_EXPR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == BREAK_EXPR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1419,12 +1199,7 @@ impl std::fmt::Display for Label { } } impl AstNode for Label { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - LABEL => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == LABEL } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1447,12 +1222,7 @@ impl std::fmt::Display for BlockExpr { } } impl AstNode for BlockExpr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - BLOCK_EXPR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == BLOCK_EXPR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1478,12 +1248,7 @@ impl std::fmt::Display for ReturnExpr { } } impl AstNode for ReturnExpr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - RETURN_EXPR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == RETURN_EXPR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1507,12 +1272,7 @@ impl std::fmt::Display for CallExpr { } } impl AstNode for CallExpr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - CALL_EXPR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == CALL_EXPR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1536,12 +1296,7 @@ impl std::fmt::Display for MethodCallExpr { } } impl AstNode for MethodCallExpr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - METHOD_CALL_EXPR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == METHOD_CALL_EXPR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1569,12 +1324,7 @@ impl std::fmt::Display for IndexExpr { } } impl AstNode for IndexExpr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - INDEX_EXPR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == INDEX_EXPR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1599,12 +1349,7 @@ impl std::fmt::Display for FieldExpr { } } impl AstNode for FieldExpr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - FIELD_EXPR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == FIELD_EXPR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1630,12 +1375,7 @@ impl std::fmt::Display for AwaitExpr { } } impl AstNode for AwaitExpr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - AWAIT_EXPR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == AWAIT_EXPR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1661,12 +1401,7 @@ impl std::fmt::Display for TryExpr { } } impl AstNode for TryExpr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - TRY_EXPR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == TRY_EXPR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1691,12 +1426,7 @@ impl std::fmt::Display for CastExpr { } } impl AstNode for CastExpr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - CAST_EXPR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == CAST_EXPR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1722,12 +1452,7 @@ impl std::fmt::Display for RefExpr { } } impl AstNode for RefExpr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - REF_EXPR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == REF_EXPR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1754,12 +1479,7 @@ impl std::fmt::Display for PrefixExpr { } } impl AstNode for PrefixExpr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - PREFIX_EXPR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == PREFIX_EXPR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1784,12 +1504,7 @@ impl std::fmt::Display for BoxExpr { } } impl AstNode for BoxExpr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - BOX_EXPR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_EXPR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1814,12 +1529,7 @@ impl std::fmt::Display for RangeExpr { } } impl AstNode for RangeExpr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - RANGE_EXPR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == RANGE_EXPR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1843,12 +1553,7 @@ impl std::fmt::Display for BinExpr { } } impl AstNode for BinExpr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - BIN_EXPR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == BIN_EXPR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1872,12 +1577,7 @@ impl std::fmt::Display for Literal { } } impl AstNode for Literal { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - LITERAL => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1900,12 +1600,7 @@ impl std::fmt::Display for MatchExpr { } } impl AstNode for MatchExpr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - MATCH_EXPR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_EXPR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1931,12 +1626,7 @@ impl std::fmt::Display for MatchArmList { } } impl AstNode for MatchArmList { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - MATCH_ARM_LIST => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_ARM_LIST } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1962,12 +1652,7 @@ impl std::fmt::Display for MatchArm { } } impl AstNode for MatchArm { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - MATCH_ARM => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_ARM } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1994,12 +1679,7 @@ impl std::fmt::Display for MatchGuard { } } impl AstNode for MatchGuard { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - MATCH_GUARD => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_GUARD } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2023,12 +1703,7 @@ impl std::fmt::Display for RecordLit { } } impl AstNode for RecordLit { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - RECORD_LIT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_LIT } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2052,12 +1727,7 @@ impl std::fmt::Display for RecordFieldList { } } impl AstNode for RecordFieldList { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - RECORD_FIELD_LIST => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_LIST } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2084,12 +1754,7 @@ impl std::fmt::Display for RecordField { } } impl AstNode for RecordField { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - RECORD_FIELD => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2115,12 +1780,7 @@ impl std::fmt::Display for OrPat { } } impl AstNode for OrPat { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - OR_PAT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == OR_PAT } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2143,12 +1803,7 @@ impl std::fmt::Display for ParenPat { } } impl AstNode for ParenPat { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - PAREN_PAT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_PAT } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2173,12 +1828,7 @@ impl std::fmt::Display for RefPat { } } impl AstNode for RefPat { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - REF_PAT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == REF_PAT } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2203,12 +1853,7 @@ impl std::fmt::Display for BoxPat { } } impl AstNode for BoxPat { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - BOX_PAT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_PAT } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2232,12 +1877,7 @@ impl std::fmt::Display for BindPat { } } impl AstNode for BindPat { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - BIND_PAT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == BIND_PAT } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2264,12 +1904,7 @@ impl std::fmt::Display for PlaceholderPat { } } impl AstNode for PlaceholderPat { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - PLACEHOLDER_PAT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == PLACEHOLDER_PAT } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2292,12 +1927,7 @@ impl std::fmt::Display for DotDotPat { } } impl AstNode for DotDotPat { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - DOT_DOT_PAT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == DOT_DOT_PAT } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2320,12 +1950,7 @@ impl std::fmt::Display for PathPat { } } impl AstNode for PathPat { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - PATH_PAT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_PAT } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2348,12 +1973,7 @@ impl std::fmt::Display for SlicePat { } } impl AstNode for SlicePat { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - SLICE_PAT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == SLICE_PAT } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2378,12 +1998,7 @@ impl std::fmt::Display for RangePat { } } impl AstNode for RangePat { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - RANGE_PAT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == RANGE_PAT } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2406,12 +2021,7 @@ impl std::fmt::Display for LiteralPat { } } impl AstNode for LiteralPat { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - LITERAL_PAT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL_PAT } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2434,12 +2044,7 @@ impl std::fmt::Display for MacroPat { } } impl AstNode for MacroPat { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - MACRO_PAT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_PAT } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2462,12 +2067,7 @@ impl std::fmt::Display for RecordPat { } } impl AstNode for RecordPat { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - RECORD_PAT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_PAT } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2493,12 +2093,7 @@ impl std::fmt::Display for RecordFieldPatList { } } impl AstNode for RecordFieldPatList { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - RECORD_FIELD_PAT_LIST => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_PAT_LIST } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2528,12 +2123,7 @@ impl std::fmt::Display for RecordFieldPat { } } impl AstNode for RecordFieldPat { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - RECORD_FIELD_PAT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_PAT } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2559,12 +2149,7 @@ impl std::fmt::Display for TupleStructPat { } } impl AstNode for TupleStructPat { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - TUPLE_STRUCT_PAT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_STRUCT_PAT } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2590,12 +2175,7 @@ impl std::fmt::Display for TuplePat { } } impl AstNode for TuplePat { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - TUPLE_PAT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_PAT } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2620,12 +2200,7 @@ impl std::fmt::Display for Visibility { } } impl AstNode for Visibility { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - VISIBILITY => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == VISIBILITY } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2651,12 +2226,7 @@ impl std::fmt::Display for Name { } } impl AstNode for Name { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - NAME => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == NAME } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2679,12 +2249,7 @@ impl std::fmt::Display for NameRef { } } impl AstNode for NameRef { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - NAME_REF => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == NAME_REF } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2707,12 +2272,7 @@ impl std::fmt::Display for MacroCall { } } impl AstNode for MacroCall { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - MACRO_CALL => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_CALL } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2741,12 +2301,7 @@ impl std::fmt::Display for Attr { } } impl AstNode for Attr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - ATTR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == ATTR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2775,12 +2330,7 @@ impl std::fmt::Display for TokenTree { } } impl AstNode for TokenTree { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - TOKEN_TREE => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == TOKEN_TREE } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2801,12 +2351,7 @@ impl std::fmt::Display for TypeParamList { } } impl AstNode for TypeParamList { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - TYPE_PARAM_LIST => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM_LIST } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2834,12 +2379,7 @@ impl std::fmt::Display for TypeParam { } } impl AstNode for TypeParam { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - TYPE_PARAM => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2866,12 +2406,7 @@ impl std::fmt::Display for ConstParam { } } impl AstNode for ConstParam { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - CONST_PARAM => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_PARAM } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2898,12 +2433,7 @@ impl std::fmt::Display for LifetimeParam { } } impl AstNode for LifetimeParam { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - LIFETIME_PARAM => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_PARAM } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2927,12 +2457,7 @@ impl std::fmt::Display for TypeBound { } } impl AstNode for TypeBound { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - TYPE_BOUND => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2957,12 +2482,7 @@ impl std::fmt::Display for TypeBoundList { } } impl AstNode for TypeBoundList { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - TYPE_BOUND_LIST => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2985,12 +2505,7 @@ impl std::fmt::Display for WherePred { } } impl AstNode for WherePred { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - WHERE_PRED => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_PRED } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3015,12 +2530,7 @@ impl std::fmt::Display for WhereClause { } } impl AstNode for WhereClause { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - WHERE_CLAUSE => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_CLAUSE } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3044,12 +2554,7 @@ impl std::fmt::Display for Abi { } } impl AstNode for Abi { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - ABI => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == ABI } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3072,12 +2577,7 @@ impl std::fmt::Display for ExprStmt { } } impl AstNode for ExprStmt { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - EXPR_STMT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_STMT } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3102,12 +2602,7 @@ impl std::fmt::Display for LetStmt { } } impl AstNode for LetStmt { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - LET_STMT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == LET_STMT } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3135,12 +2630,7 @@ impl std::fmt::Display for Condition { } } impl AstNode for Condition { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - CONDITION => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == CONDITION } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3166,12 +2656,7 @@ impl std::fmt::Display for Block { } } impl AstNode for Block { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - BLOCK => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == BLOCK } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3199,12 +2684,7 @@ impl std::fmt::Display for ParamList { } } impl AstNode for ParamList { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - PARAM_LIST => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM_LIST } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3230,12 +2710,7 @@ impl std::fmt::Display for SelfParam { } } impl AstNode for SelfParam { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - SELF_PARAM => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3262,12 +2737,7 @@ impl std::fmt::Display for Param { } } impl AstNode for Param { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - PARAM => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3293,12 +2763,7 @@ impl std::fmt::Display for UseItem { } } impl AstNode for UseItem { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - USE_ITEM => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == USE_ITEM } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3324,12 +2789,7 @@ impl std::fmt::Display for UseTree { } } impl AstNode for UseTree { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - USE_TREE => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3355,12 +2815,7 @@ impl std::fmt::Display for Alias { } } impl AstNode for Alias { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - ALIAS => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == ALIAS } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3384,12 +2839,7 @@ impl std::fmt::Display for UseTreeList { } } impl AstNode for UseTreeList { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - USE_TREE_LIST => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE_LIST } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3414,12 +2864,7 @@ impl std::fmt::Display for ExternCrateItem { } } impl AstNode for ExternCrateItem { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - EXTERN_CRATE_ITEM => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_CRATE_ITEM } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3447,12 +2892,7 @@ impl std::fmt::Display for ArgList { } } impl AstNode for ArgList { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - ARG_LIST => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == ARG_LIST } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3477,12 +2917,7 @@ impl std::fmt::Display for Path { } } impl AstNode for Path { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - PATH => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == PATH } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3506,12 +2941,7 @@ impl std::fmt::Display for PathSegment { } } impl AstNode for PathSegment { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - PATH_SEGMENT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3541,12 +2971,7 @@ impl std::fmt::Display for TypeArgList { } } impl AstNode for TypeArgList { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - TYPE_ARG_LIST => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG_LIST } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3576,12 +3001,7 @@ impl std::fmt::Display for TypeArg { } } impl AstNode for TypeArg { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - TYPE_ARG => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3604,12 +3024,7 @@ impl std::fmt::Display for AssocTypeArg { } } impl AstNode for AssocTypeArg { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - ASSOC_TYPE_ARG => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_TYPE_ARG } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3635,12 +3050,7 @@ impl std::fmt::Display for LifetimeArg { } } impl AstNode for LifetimeArg { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - LIFETIME_ARG => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_ARG } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3663,12 +3073,7 @@ impl std::fmt::Display for ConstArg { } } impl AstNode for ConstArg { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - CONST_ARG => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_ARG } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3693,12 +3098,7 @@ impl std::fmt::Display for MacroItems { } } impl AstNode for MacroItems { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - MACRO_ITEMS => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_ITEMS } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3721,12 +3121,7 @@ impl std::fmt::Display for MacroStmts { } } impl AstNode for MacroStmts { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - MACRO_STMTS => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_STMTS } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3750,12 +3145,7 @@ impl std::fmt::Display for ExternItemList { } } impl AstNode for ExternItemList { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - EXTERN_ITEM_LIST => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_ITEM_LIST } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3782,12 +3172,7 @@ impl std::fmt::Display for ExternBlock { } } impl AstNode for ExternBlock { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - EXTERN_BLOCK => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_BLOCK } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3811,12 +3196,7 @@ impl std::fmt::Display for MetaItem { } } impl AstNode for MetaItem { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - META_ITEM => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == META_ITEM } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3842,12 +3222,7 @@ impl std::fmt::Display for MacroDef { } } impl AstNode for MacroDef { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - MACRO_DEF => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_DEF } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) diff --git a/crates/ra_syntax/src/ast/generated/tokens.rs b/crates/ra_syntax/src/ast/generated/tokens.rs index ec3ca4a5b..e64b8bce6 100644 --- a/crates/ra_syntax/src/ast/generated/tokens.rs +++ b/crates/ra_syntax/src/ast/generated/tokens.rs @@ -15,12 +15,7 @@ impl std::fmt::Display for Semi { } } impl AstToken for Semi { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - SEMI => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == SEMI } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -40,12 +35,7 @@ impl std::fmt::Display for Comma { } } impl AstToken for Comma { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - COMMA => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == COMMA } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -65,12 +55,7 @@ impl std::fmt::Display for LParen { } } impl AstToken for LParen { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - L_PAREN => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == L_PAREN } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -90,12 +75,7 @@ impl std::fmt::Display for RParen { } } impl AstToken for RParen { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - R_PAREN => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == R_PAREN } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -115,12 +95,7 @@ impl std::fmt::Display for LCurly { } } impl AstToken for LCurly { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - L_CURLY => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == L_CURLY } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -140,12 +115,7 @@ impl std::fmt::Display for RCurly { } } impl AstToken for RCurly { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - R_CURLY => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == R_CURLY } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -165,12 +135,7 @@ impl std::fmt::Display for LBrack { } } impl AstToken for LBrack { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - L_BRACK => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == L_BRACK } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -190,12 +155,7 @@ impl std::fmt::Display for RBrack { } } impl AstToken for RBrack { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - R_BRACK => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == R_BRACK } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -215,12 +175,7 @@ impl std::fmt::Display for LAngle { } } impl AstToken for LAngle { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - L_ANGLE => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == L_ANGLE } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -240,12 +195,7 @@ impl std::fmt::Display for RAngle { } } impl AstToken for RAngle { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - R_ANGLE => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == R_ANGLE } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -265,12 +215,7 @@ impl std::fmt::Display for At { } } impl AstToken for At { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - AT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == AT } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -290,12 +235,7 @@ impl std::fmt::Display for Pound { } } impl AstToken for Pound { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - POUND => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == POUND } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -315,12 +255,7 @@ impl std::fmt::Display for Tilde { } } impl AstToken for Tilde { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - TILDE => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == TILDE } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -340,12 +275,7 @@ impl std::fmt::Display for Question { } } impl AstToken for Question { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - QUESTION => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == QUESTION } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -365,12 +295,7 @@ impl std::fmt::Display for Dollar { } } impl AstToken for Dollar { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - DOLLAR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == DOLLAR } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -390,12 +315,7 @@ impl std::fmt::Display for Amp { } } impl AstToken for Amp { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - AMP => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == AMP } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -415,12 +335,7 @@ impl std::fmt::Display for Pipe { } } impl AstToken for Pipe { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - PIPE => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == PIPE } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -440,12 +355,7 @@ impl std::fmt::Display for Plus { } } impl AstToken for Plus { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - PLUS => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == PLUS } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -465,12 +375,7 @@ impl std::fmt::Display for Star { } } impl AstToken for Star { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - STAR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == STAR } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -490,12 +395,7 @@ impl std::fmt::Display for Slash { } } impl AstToken for Slash { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - SLASH => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == SLASH } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -515,12 +415,7 @@ impl std::fmt::Display for Caret { } } impl AstToken for Caret { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - CARET => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == CARET } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -540,12 +435,7 @@ impl std::fmt::Display for Percent { } } impl AstToken for Percent { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - PERCENT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == PERCENT } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -565,12 +455,7 @@ impl std::fmt::Display for Underscore { } } impl AstToken for Underscore { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - UNDERSCORE => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == UNDERSCORE } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -590,12 +475,7 @@ impl std::fmt::Display for Dot { } } impl AstToken for Dot { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - DOT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == DOT } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -615,12 +495,7 @@ impl std::fmt::Display for Dotdot { } } impl AstToken for Dotdot { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - DOTDOT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == DOTDOT } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -640,12 +515,7 @@ impl std::fmt::Display for Dotdotdot { } } impl AstToken for Dotdotdot { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - DOTDOTDOT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == DOTDOTDOT } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -665,12 +535,7 @@ impl std::fmt::Display for Dotdoteq { } } impl AstToken for Dotdoteq { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - DOTDOTEQ => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == DOTDOTEQ } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -690,12 +555,7 @@ impl std::fmt::Display for Colon { } } impl AstToken for Colon { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - COLON => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == COLON } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -715,12 +575,7 @@ impl std::fmt::Display for Coloncolon { } } impl AstToken for Coloncolon { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - COLONCOLON => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == COLONCOLON } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -740,12 +595,7 @@ impl std::fmt::Display for Eq { } } impl AstToken for Eq { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - EQ => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == EQ } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -765,12 +615,7 @@ impl std::fmt::Display for Eqeq { } } impl AstToken for Eqeq { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - EQEQ => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == EQEQ } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -790,12 +635,7 @@ impl std::fmt::Display for FatArrow { } } impl AstToken for FatArrow { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - FAT_ARROW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == FAT_ARROW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -815,12 +655,7 @@ impl std::fmt::Display for Excl { } } impl AstToken for Excl { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - EXCL => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == EXCL } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -840,12 +675,7 @@ impl std::fmt::Display for Neq { } } impl AstToken for Neq { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - NEQ => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == NEQ } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -865,12 +695,7 @@ impl std::fmt::Display for Minus { } } impl AstToken for Minus { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - MINUS => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == MINUS } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -890,12 +715,7 @@ impl std::fmt::Display for ThinArrow { } } impl AstToken for ThinArrow { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - THIN_ARROW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == THIN_ARROW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -915,12 +735,7 @@ impl std::fmt::Display for Lteq { } } impl AstToken for Lteq { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - LTEQ => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == LTEQ } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -940,12 +755,7 @@ impl std::fmt::Display for Gteq { } } impl AstToken for Gteq { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - GTEQ => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == GTEQ } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -965,12 +775,7 @@ impl std::fmt::Display for Pluseq { } } impl AstToken for Pluseq { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - PLUSEQ => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == PLUSEQ } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -990,12 +795,7 @@ impl std::fmt::Display for Minuseq { } } impl AstToken for Minuseq { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - MINUSEQ => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == MINUSEQ } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1015,12 +815,7 @@ impl std::fmt::Display for Pipeeq { } } impl AstToken for Pipeeq { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - PIPEEQ => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == PIPEEQ } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1040,12 +835,7 @@ impl std::fmt::Display for Ampeq { } } impl AstToken for Ampeq { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - AMPEQ => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == AMPEQ } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1065,12 +855,7 @@ impl std::fmt::Display for Careteq { } } impl AstToken for Careteq { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - CARETEQ => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == CARETEQ } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1090,12 +875,7 @@ impl std::fmt::Display for Slasheq { } } impl AstToken for Slasheq { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - SLASHEQ => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == SLASHEQ } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1115,12 +895,7 @@ impl std::fmt::Display for Stareq { } } impl AstToken for Stareq { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - STAREQ => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == STAREQ } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1140,12 +915,7 @@ impl std::fmt::Display for Percenteq { } } impl AstToken for Percenteq { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - PERCENTEQ => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == PERCENTEQ } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1165,12 +935,7 @@ impl std::fmt::Display for Ampamp { } } impl AstToken for Ampamp { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - AMPAMP => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == AMPAMP } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1190,12 +955,7 @@ impl std::fmt::Display for Pipepipe { } } impl AstToken for Pipepipe { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - PIPEPIPE => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == PIPEPIPE } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1215,12 +975,7 @@ impl std::fmt::Display for Shl { } } impl AstToken for Shl { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - SHL => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == SHL } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1240,12 +995,7 @@ impl std::fmt::Display for Shr { } } impl AstToken for Shr { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - SHR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == SHR } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1265,12 +1015,7 @@ impl std::fmt::Display for Shleq { } } impl AstToken for Shleq { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - SHLEQ => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == SHLEQ } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1290,12 +1035,7 @@ impl std::fmt::Display for Shreq { } } impl AstToken for Shreq { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - SHREQ => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == SHREQ } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1315,12 +1055,7 @@ impl std::fmt::Display for AsKw { } } impl AstToken for AsKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - AS_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == AS_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1340,12 +1075,7 @@ impl std::fmt::Display for AsyncKw { } } impl AstToken for AsyncKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - ASYNC_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == ASYNC_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1365,12 +1095,7 @@ impl std::fmt::Display for AwaitKw { } } impl AstToken for AwaitKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - AWAIT_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == AWAIT_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1390,12 +1115,7 @@ impl std::fmt::Display for BoxKw { } } impl AstToken for BoxKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - BOX_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1415,12 +1135,7 @@ impl std::fmt::Display for BreakKw { } } impl AstToken for BreakKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - BREAK_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == BREAK_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1440,12 +1155,7 @@ impl std::fmt::Display for ConstKw { } } impl AstToken for ConstKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - CONST_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1465,12 +1175,7 @@ impl std::fmt::Display for ContinueKw { } } impl AstToken for ContinueKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - CONTINUE_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == CONTINUE_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1490,12 +1195,7 @@ impl std::fmt::Display for CrateKw { } } impl AstToken for CrateKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - CRATE_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == CRATE_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1515,12 +1215,7 @@ impl std::fmt::Display for DynKw { } } impl AstToken for DynKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - DYN_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == DYN_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1539,13 +1234,8 @@ impl std::fmt::Display for ElseKw { std::fmt::Display::fmt(&self.syntax, f) } } -impl AstToken for ElseKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - ELSE_KW => true, - _ => false, - } - } +impl AstToken for ElseKw { + fn can_cast(kind: SyntaxKind) -> bool { kind == ELSE_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1565,12 +1255,7 @@ impl std::fmt::Display for EnumKw { } } impl AstToken for EnumKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - ENUM_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1590,12 +1275,7 @@ impl std::fmt::Display for ExternKw { } } impl AstToken for ExternKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - EXTERN_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1615,12 +1295,7 @@ impl std::fmt::Display for FalseKw { } } impl AstToken for FalseKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - FALSE_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == FALSE_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1640,12 +1315,7 @@ impl std::fmt::Display for FnKw { } } impl AstToken for FnKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - FN_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == FN_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1665,12 +1335,7 @@ impl std::fmt::Display for ForKw { } } impl AstToken for ForKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - FOR_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1690,12 +1355,7 @@ impl std::fmt::Display for IfKw { } } impl AstToken for IfKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - IF_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == IF_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1715,12 +1375,7 @@ impl std::fmt::Display for ImplKw { } } impl AstToken for ImplKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - IMPL_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1740,12 +1395,7 @@ impl std::fmt::Display for InKw { } } impl AstToken for InKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - IN_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == IN_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1765,12 +1415,7 @@ impl std::fmt::Display for LetKw { } } impl AstToken for LetKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - LET_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == LET_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1790,12 +1435,7 @@ impl std::fmt::Display for LoopKw { } } impl AstToken for LoopKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - LOOP_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == LOOP_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1815,12 +1455,7 @@ impl std::fmt::Display for MacroKw { } } impl AstToken for MacroKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - MACRO_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1840,12 +1475,7 @@ impl std::fmt::Display for MatchKw { } } impl AstToken for MatchKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - MATCH_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1865,12 +1495,7 @@ impl std::fmt::Display for ModKw { } } impl AstToken for ModKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - MOD_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == MOD_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1890,12 +1515,7 @@ impl std::fmt::Display for MoveKw { } } impl AstToken for MoveKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - MOVE_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == MOVE_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1915,12 +1535,7 @@ impl std::fmt::Display for MutKw { } } impl AstToken for MutKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - MUT_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == MUT_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1940,12 +1555,7 @@ impl std::fmt::Display for PubKw { } } impl AstToken for PubKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - PUB_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == PUB_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1965,12 +1575,7 @@ impl std::fmt::Display for RefKw { } } impl AstToken for RefKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - REF_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == REF_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1990,12 +1595,7 @@ impl std::fmt::Display for ReturnKw { } } impl AstToken for ReturnKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - RETURN_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == RETURN_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2015,12 +1615,7 @@ impl std::fmt::Display for SelfKw { } } impl AstToken for SelfKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - SELF_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2040,12 +1635,7 @@ impl std::fmt::Display for StaticKw { } } impl AstToken for StaticKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - STATIC_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2065,12 +1655,7 @@ impl std::fmt::Display for StructKw { } } impl AstToken for StructKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - STRUCT_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2090,12 +1675,7 @@ impl std::fmt::Display for SuperKw { } } impl AstToken for SuperKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - SUPER_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == SUPER_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2115,12 +1695,7 @@ impl std::fmt::Display for TraitKw { } } impl AstToken for TraitKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - TRAIT_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2140,12 +1715,7 @@ impl std::fmt::Display for TrueKw { } } impl AstToken for TrueKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - TRUE_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == TRUE_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2165,12 +1735,7 @@ impl std::fmt::Display for TryKw { } } impl AstToken for TryKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - TRY_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == TRY_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2190,12 +1755,7 @@ impl std::fmt::Display for TypeKw { } } impl AstToken for TypeKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - TYPE_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2215,12 +1775,7 @@ impl std::fmt::Display for UnsafeKw { } } impl AstToken for UnsafeKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - UNSAFE_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == UNSAFE_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2240,12 +1795,7 @@ impl std::fmt::Display for UseKw { } } impl AstToken for UseKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - USE_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == USE_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2265,12 +1815,7 @@ impl std::fmt::Display for WhereKw { } } impl AstToken for WhereKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - WHERE_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2290,12 +1835,7 @@ impl std::fmt::Display for WhileKw { } } impl AstToken for WhileKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - WHILE_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == WHILE_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2315,12 +1855,7 @@ impl std::fmt::Display for AutoKw { } } impl AstToken for AutoKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - AUTO_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == AUTO_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2340,12 +1875,7 @@ impl std::fmt::Display for DefaultKw { } } impl AstToken for DefaultKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - DEFAULT_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == DEFAULT_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2365,12 +1895,7 @@ impl std::fmt::Display for ExistentialKw { } } impl AstToken for ExistentialKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - EXISTENTIAL_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == EXISTENTIAL_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2390,12 +1915,7 @@ impl std::fmt::Display for UnionKw { } } impl AstToken for UnionKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - UNION_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == UNION_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2415,12 +1935,7 @@ impl std::fmt::Display for RawKw { } } impl AstToken for RawKw { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - RAW_KW => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == RAW_KW } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2440,12 +1955,7 @@ impl std::fmt::Display for IntNumber { } } impl AstToken for IntNumber { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - INT_NUMBER => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == INT_NUMBER } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2465,12 +1975,7 @@ impl std::fmt::Display for FloatNumber { } } impl AstToken for FloatNumber { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - FLOAT_NUMBER => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == FLOAT_NUMBER } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2490,12 +1995,7 @@ impl std::fmt::Display for Char { } } impl AstToken for Char { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - CHAR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == CHAR } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2515,12 +2015,7 @@ impl std::fmt::Display for Byte { } } impl AstToken for Byte { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - BYTE => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == BYTE } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2540,12 +2035,7 @@ impl std::fmt::Display for String { } } impl AstToken for String { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - STRING => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == STRING } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2565,12 +2055,7 @@ impl std::fmt::Display for RawString { } } impl AstToken for RawString { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - RAW_STRING => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == RAW_STRING } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2590,12 +2075,7 @@ impl std::fmt::Display for ByteString { } } impl AstToken for ByteString { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - BYTE_STRING => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == BYTE_STRING } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2615,12 +2095,7 @@ impl std::fmt::Display for RawByteString { } } impl AstToken for RawByteString { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - RAW_BYTE_STRING => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == RAW_BYTE_STRING } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2640,12 +2115,7 @@ impl std::fmt::Display for Error { } } impl AstToken for Error { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - ERROR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == ERROR } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2665,12 +2135,7 @@ impl std::fmt::Display for Ident { } } impl AstToken for Ident { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - IDENT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == IDENT } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2690,12 +2155,7 @@ impl std::fmt::Display for Whitespace { } } impl AstToken for Whitespace { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - WHITESPACE => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == WHITESPACE } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2715,12 +2175,7 @@ impl std::fmt::Display for Lifetime { } } impl AstToken for Lifetime { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - LIFETIME => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2740,12 +2195,7 @@ impl std::fmt::Display for Comment { } } impl AstToken for Comment { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - COMMENT => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == COMMENT } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2765,12 +2215,7 @@ impl std::fmt::Display for Shebang { } } impl AstToken for Shebang { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - SHEBANG => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == SHEBANG } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2790,12 +2235,7 @@ impl std::fmt::Display for LDollar { } } impl AstToken for LDollar { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - L_DOLLAR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == L_DOLLAR } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2815,12 +2255,7 @@ impl std::fmt::Display for RDollar { } } impl AstToken for RDollar { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - R_DOLLAR => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == R_DOLLAR } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs index 9801a3dba..f9a50c5b9 100644 --- a/xtask/src/codegen/gen_syntax.rs +++ b/xtask/src/codegen/gen_syntax.rs @@ -75,12 +75,7 @@ fn generate_tokens(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result { } impl AstToken for #name { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - #kind => true, - _ => false, - } - } + fn can_cast(kind: SyntaxKind) -> bool { kind == #kind } fn cast(syntax: SyntaxToken) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } } @@ -243,10 +238,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result { impl AstNode for #name { fn can_cast(kind: SyntaxKind) -> bool { - match kind { - #kind => true, - _ => false, - } + kind == #kind } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } -- cgit v1.2.3