From 54fd09a9ca567fc79cae53237dfeedc5baeec635 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Jul 2020 18:27:23 +0200 Subject: Finalize Path grammar --- crates/ra_syntax/src/ast/generated/nodes.rs | 923 ++++++++++++++-------------- 1 file changed, 462 insertions(+), 461 deletions(-) (limited to 'crates/ra_syntax/src/ast/generated') diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index e049548c9..1a707ad67 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs @@ -6,6 +6,137 @@ use crate::{ SyntaxNode, SyntaxToken, T, }; #[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct Path { + pub(crate) syntax: SyntaxNode, +} +impl Path { + pub fn qualifier(&self) -> Option { support::child(&self.syntax) } + pub fn coloncolon_token(&self) -> Option { support::token(&self.syntax, T![::]) } + pub fn segment(&self) -> Option { support::child(&self.syntax) } +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct PathSegment { + pub(crate) syntax: SyntaxNode, +} +impl PathSegment { + pub fn coloncolon_token(&self) -> Option { support::token(&self.syntax, T![::]) } + pub fn crate_token(&self) -> Option { support::token(&self.syntax, T![crate]) } + pub fn self_token(&self) -> Option { support::token(&self.syntax, T![self]) } + pub fn super_token(&self) -> Option { support::token(&self.syntax, T![super]) } + pub fn name_ref(&self) -> Option { support::child(&self.syntax) } + pub fn type_arg_list(&self) -> Option { support::child(&self.syntax) } + pub fn param_list(&self) -> Option { support::child(&self.syntax) } + pub fn ret_type(&self) -> Option { support::child(&self.syntax) } + pub fn l_angle_token(&self) -> Option { support::token(&self.syntax, T![<]) } + pub fn path_type(&self) -> Option { support::child(&self.syntax) } + pub fn as_token(&self) -> Option { support::token(&self.syntax, T![as]) } + pub fn r_angle_token(&self) -> Option { support::token(&self.syntax, T![>]) } +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct NameRef { + pub(crate) syntax: SyntaxNode, +} +impl NameRef { + pub fn ident_token(&self) -> Option { support::token(&self.syntax, T![ident]) } +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct TypeArgList { + pub(crate) syntax: SyntaxNode, +} +impl TypeArgList { + pub fn coloncolon_token(&self) -> Option { support::token(&self.syntax, T![::]) } + pub fn l_angle_token(&self) -> Option { support::token(&self.syntax, T![<]) } + pub fn type_args(&self) -> AstChildren { support::children(&self.syntax) } + pub fn lifetime_args(&self) -> AstChildren { support::children(&self.syntax) } + pub fn assoc_type_args(&self) -> AstChildren { support::children(&self.syntax) } + pub fn const_args(&self) -> AstChildren { support::children(&self.syntax) } + pub fn r_angle_token(&self) -> Option { support::token(&self.syntax, T![>]) } +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct ParamList { + pub(crate) syntax: SyntaxNode, +} +impl ParamList { + pub fn l_paren_token(&self) -> Option { support::token(&self.syntax, T!['(']) } + pub fn self_param(&self) -> Option { support::child(&self.syntax) } + pub fn comma_token(&self) -> Option { support::token(&self.syntax, T![,]) } + pub fn params(&self) -> AstChildren { support::children(&self.syntax) } + pub fn r_paren_token(&self) -> Option { support::token(&self.syntax, T![')']) } +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct RetType { + pub(crate) syntax: SyntaxNode, +} +impl RetType { + pub fn thin_arrow_token(&self) -> Option { support::token(&self.syntax, T![->]) } + pub fn ty(&self) -> Option { support::child(&self.syntax) } +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct PathType { + pub(crate) syntax: SyntaxNode, +} +impl PathType { + pub fn path(&self) -> Option { support::child(&self.syntax) } +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct TypeArg { + pub(crate) syntax: SyntaxNode, +} +impl TypeArg { + pub fn ty(&self) -> Option { support::child(&self.syntax) } +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct LifetimeArg { + pub(crate) syntax: SyntaxNode, +} +impl LifetimeArg { + pub fn lifetime_token(&self) -> Option { + support::token(&self.syntax, T![lifetime]) + } +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct AssocTypeArg { + pub(crate) syntax: SyntaxNode, +} +impl ast::TypeBoundsOwner for AssocTypeArg {} +impl AssocTypeArg { + pub fn name_ref(&self) -> Option { support::child(&self.syntax) } + pub fn eq_token(&self) -> Option { support::token(&self.syntax, T![=]) } + pub fn ty(&self) -> Option { support::child(&self.syntax) } +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct ConstArg { + pub(crate) syntax: SyntaxNode, +} +impl ConstArg { + pub fn literal(&self) -> Option { support::child(&self.syntax) } + pub fn block_expr(&self) -> Option { support::child(&self.syntax) } +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct TypeBoundList { + pub(crate) syntax: SyntaxNode, +} +impl TypeBoundList { + pub fn bounds(&self) -> AstChildren { support::children(&self.syntax) } +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct Literal { + pub(crate) syntax: SyntaxNode, +} +impl ast::AttrsOwner for Literal {} +impl Literal {} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct BlockExpr { + pub(crate) syntax: SyntaxNode, +} +impl ast::AttrsOwner for BlockExpr {} +impl BlockExpr { + pub fn l_curly_token(&self) -> Option { support::token(&self.syntax, T!['{']) } + pub fn statements(&self) -> AstChildren { support::children(&self.syntax) } + pub fn expr(&self) -> Option { support::child(&self.syntax) } + pub fn r_curly_token(&self) -> Option { support::token(&self.syntax, T!['}']) } +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct SourceFile { pub(crate) syntax: SyntaxNode, } @@ -256,13 +387,6 @@ impl ItemList { pub fn r_curly_token(&self) -> Option { support::token(&self.syntax, T!['}']) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct NameRef { - pub(crate) syntax: SyntaxNode, -} -impl NameRef { - pub fn ident_token(&self) -> Option { support::token(&self.syntax, T![ident]) } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Rename { pub(crate) syntax: SyntaxNode, } @@ -283,15 +407,6 @@ impl UseTree { pub fn rename(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct Path { - pub(crate) syntax: SyntaxNode, -} -impl Path { - pub fn qualifier(&self) -> Option { support::child(&self.syntax) } - pub fn coloncolon_token(&self) -> Option { support::token(&self.syntax, T![::]) } - pub fn segment(&self) -> Option { support::child(&self.syntax) } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct UseTreeList { pub(crate) syntax: SyntaxNode, } @@ -317,25 +432,6 @@ impl GenericParamList { pub fn r_angle_token(&self) -> Option { support::token(&self.syntax, T![>]) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct ParamList { - pub(crate) syntax: SyntaxNode, -} -impl ParamList { - pub fn l_paren_token(&self) -> Option { support::token(&self.syntax, T!['(']) } - pub fn self_param(&self) -> Option { support::child(&self.syntax) } - pub fn comma_token(&self) -> Option { support::token(&self.syntax, T![,]) } - pub fn params(&self) -> AstChildren { support::children(&self.syntax) } - pub fn r_paren_token(&self) -> Option { support::token(&self.syntax, T![')']) } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct RetType { - pub(crate) syntax: SyntaxNode, -} -impl RetType { - pub fn thin_arrow_token(&self) -> Option { support::token(&self.syntax, T![->]) } - pub fn ty(&self) -> Option { support::child(&self.syntax) } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct WhereClause { pub(crate) syntax: SyntaxNode, } @@ -344,17 +440,6 @@ impl WhereClause { pub fn predicates(&self) -> AstChildren { support::children(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct BlockExpr { - pub(crate) syntax: SyntaxNode, -} -impl ast::AttrsOwner for BlockExpr {} -impl BlockExpr { - pub fn l_curly_token(&self) -> Option { support::token(&self.syntax, T!['{']) } - pub fn statements(&self) -> AstChildren { support::children(&self.syntax) } - pub fn expr(&self) -> Option { support::child(&self.syntax) } - pub fn r_curly_token(&self) -> Option { support::token(&self.syntax, T!['}']) } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct SelfParam { pub(crate) syntax: SyntaxNode, } @@ -381,13 +466,6 @@ impl Param { pub fn dotdotdot_token(&self) -> Option { support::token(&self.syntax, T![...]) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct TypeBoundList { - pub(crate) syntax: SyntaxNode, -} -impl TypeBoundList { - pub fn bounds(&self) -> AstChildren { support::children(&self.syntax) } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct RecordFieldList { pub(crate) syntax: SyntaxNode, } @@ -515,12 +593,6 @@ impl WherePred { pub fn ty(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct Literal { - pub(crate) syntax: SyntaxNode, -} -impl ast::AttrsOwner for Literal {} -impl Literal {} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct TokenTree { pub(crate) syntax: SyntaxNode, } @@ -866,19 +938,6 @@ impl ArgList { pub fn r_paren_token(&self) -> Option { support::token(&self.syntax, T![')']) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct TypeArgList { - pub(crate) syntax: SyntaxNode, -} -impl TypeArgList { - pub fn coloncolon_token(&self) -> Option { support::token(&self.syntax, T![::]) } - pub fn l_angle_token(&self) -> Option { support::token(&self.syntax, T![<]) } - pub fn type_args(&self) -> AstChildren { support::children(&self.syntax) } - pub fn lifetime_args(&self) -> AstChildren { support::children(&self.syntax) } - pub fn assoc_type_args(&self) -> AstChildren { support::children(&self.syntax) } - pub fn const_args(&self) -> AstChildren { support::children(&self.syntax) } - pub fn r_angle_token(&self) -> Option { support::token(&self.syntax, T![>]) } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Condition { pub(crate) syntax: SyntaxNode, } @@ -991,13 +1050,6 @@ impl ParenType { pub fn r_paren_token(&self) -> Option { support::token(&self.syntax, T![')']) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct PathType { - pub(crate) syntax: SyntaxNode, -} -impl PathType { - pub fn path(&self) -> Option { support::child(&self.syntax) } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct PointerType { pub(crate) syntax: SyntaxNode, } @@ -1220,91 +1272,40 @@ impl MacroStmts { pub fn expr(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct PathSegment { - pub(crate) syntax: SyntaxNode, -} -impl PathSegment { - pub fn coloncolon_token(&self) -> Option { support::token(&self.syntax, T![::]) } - pub fn crate_token(&self) -> Option { support::token(&self.syntax, T![crate]) } - pub fn self_token(&self) -> Option { support::token(&self.syntax, T![self]) } - pub fn super_token(&self) -> Option { support::token(&self.syntax, T![super]) } - pub fn l_angle_token(&self) -> Option { support::token(&self.syntax, T![<]) } - pub fn name_ref(&self) -> Option { support::child(&self.syntax) } - pub fn type_arg_list(&self) -> Option { support::child(&self.syntax) } - pub fn param_list(&self) -> Option { support::child(&self.syntax) } - pub fn ret_type(&self) -> Option { support::child(&self.syntax) } - pub fn path_type(&self) -> Option { support::child(&self.syntax) } - pub fn r_angle_token(&self) -> Option { support::token(&self.syntax, T![>]) } +pub enum Type { + ArrayType(ArrayType), + DynTraitType(DynTraitType), + FnPointerType(FnPointerType), + ForType(ForType), + ImplTraitType(ImplTraitType), + InferType(InferType), + NeverType(NeverType), + ParenType(ParenType), + PathType(PathType), + PointerType(PointerType), + ReferenceType(ReferenceType), + SliceType(SliceType), + TupleType(TupleType), } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct TypeArg { - pub(crate) syntax: SyntaxNode, -} -impl TypeArg { - pub fn ty(&self) -> Option { support::child(&self.syntax) } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct LifetimeArg { - pub(crate) syntax: SyntaxNode, -} -impl LifetimeArg { - pub fn lifetime_token(&self) -> Option { - support::token(&self.syntax, T![lifetime]) - } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct AssocTypeArg { - pub(crate) syntax: SyntaxNode, -} -impl ast::TypeBoundsOwner for AssocTypeArg {} -impl AssocTypeArg { - pub fn name_ref(&self) -> Option { support::child(&self.syntax) } - pub fn eq_token(&self) -> Option { support::token(&self.syntax, T![=]) } - pub fn ty(&self) -> Option { support::child(&self.syntax) } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct ConstArg { - pub(crate) syntax: SyntaxNode, -} -impl ConstArg { - pub fn literal(&self) -> Option { support::child(&self.syntax) } - pub fn block_expr(&self) -> Option { support::child(&self.syntax) } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub enum Item { - Const(Const), - Enum(Enum), - ExternBlock(ExternBlock), - ExternCrate(ExternCrate), - Fn(Fn), - Impl(Impl), - MacroCall(MacroCall), - Module(Module), - Static(Static), - Struct(Struct), - Trait(Trait), - TypeAlias(TypeAlias), - Union(Union), - Use(Use), +pub enum Item { + Const(Const), + Enum(Enum), + ExternBlock(ExternBlock), + ExternCrate(ExternCrate), + Fn(Fn), + Impl(Impl), + MacroCall(MacroCall), + Module(Module), + Static(Static), + Struct(Struct), + Trait(Trait), + TypeAlias(TypeAlias), + Union(Union), + Use(Use), } impl ast::AttrsOwner for Item {} #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub enum Type { - ArrayType(ArrayType), - DynTraitType(DynTraitType), - FnPointerType(FnPointerType), - ForType(ForType), - ImplTraitType(ImplTraitType), - InferType(InferType), - NeverType(NeverType), - ParenType(ParenType), - PathType(PathType), - PointerType(PointerType), - ReferenceType(ReferenceType), - SliceType(SliceType), - TupleType(TupleType), -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum Pat { OrPat(OrPat), ParenPat(ParenPat), @@ -1400,8 +1401,8 @@ pub enum Stmt { Item(Item), LetStmt(LetStmt), } -impl AstNode for SourceFile { - fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE } +impl AstNode for Path { + fn can_cast(kind: SyntaxKind) -> bool { kind == PATH } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1411,8 +1412,8 @@ impl AstNode for SourceFile { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for Attr { - fn can_cast(kind: SyntaxKind) -> bool { kind == ATTR } +impl AstNode for PathSegment { + fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1422,8 +1423,8 @@ impl AstNode for Attr { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for Const { - fn can_cast(kind: SyntaxKind) -> bool { kind == CONST } +impl AstNode for NameRef { + fn can_cast(kind: SyntaxKind) -> bool { kind == NAME_REF } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1433,8 +1434,8 @@ impl AstNode for Const { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for Enum { - fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM } +impl AstNode for TypeArgList { + fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG_LIST } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1444,8 +1445,8 @@ impl AstNode for Enum { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for ExternBlock { - fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_BLOCK } +impl AstNode for ParamList { + fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM_LIST } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1455,8 +1456,8 @@ impl AstNode for ExternBlock { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for ExternCrate { - fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_CRATE } +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 }) @@ -1466,8 +1467,8 @@ impl AstNode for ExternCrate { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for Fn { - fn can_cast(kind: SyntaxKind) -> bool { kind == FN } +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 }) @@ -1477,8 +1478,8 @@ impl AstNode for Fn { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for Impl { - fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL } +impl AstNode for TypeArg { + fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1488,8 +1489,8 @@ impl AstNode for Impl { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for MacroCall { - fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_CALL } +impl AstNode for LifetimeArg { + fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_ARG } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1499,8 +1500,8 @@ impl AstNode for MacroCall { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for Module { - fn can_cast(kind: SyntaxKind) -> bool { kind == MODULE } +impl AstNode for AssocTypeArg { + fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_TYPE_ARG } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1510,8 +1511,8 @@ impl AstNode for Module { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for Static { - fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC } +impl AstNode for ConstArg { + fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_ARG } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1521,8 +1522,8 @@ impl AstNode for Static { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for Struct { - fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT } +impl AstNode for TypeBoundList { + fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1532,8 +1533,8 @@ impl AstNode for Struct { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for Trait { - fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT } +impl AstNode for Literal { + fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1543,8 +1544,8 @@ impl AstNode for Trait { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for TypeAlias { - fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS } +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 }) @@ -1554,8 +1555,8 @@ impl AstNode for TypeAlias { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for Union { - fn can_cast(kind: SyntaxKind) -> bool { kind == UNION } +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 }) @@ -1565,8 +1566,8 @@ impl AstNode for Union { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for Use { - fn can_cast(kind: SyntaxKind) -> bool { kind == USE } +impl AstNode for Attr { + fn can_cast(kind: SyntaxKind) -> bool { kind == ATTR } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1576,8 +1577,8 @@ impl AstNode for Use { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for Visibility { - fn can_cast(kind: SyntaxKind) -> bool { kind == VISIBILITY } +impl AstNode for Const { + fn can_cast(kind: SyntaxKind) -> bool { kind == CONST } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1587,8 +1588,8 @@ impl AstNode for Visibility { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for Name { - fn can_cast(kind: SyntaxKind) -> bool { kind == NAME } +impl AstNode for Enum { + fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1598,8 +1599,8 @@ impl AstNode for Name { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for ItemList { - fn can_cast(kind: SyntaxKind) -> bool { kind == ITEM_LIST } +impl AstNode for ExternBlock { + fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_BLOCK } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1609,8 +1610,8 @@ impl AstNode for ItemList { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for NameRef { - fn can_cast(kind: SyntaxKind) -> bool { kind == NAME_REF } +impl AstNode for ExternCrate { + fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_CRATE } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1620,8 +1621,8 @@ impl AstNode for NameRef { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for Rename { - fn can_cast(kind: SyntaxKind) -> bool { kind == RENAME } +impl AstNode for Fn { + fn can_cast(kind: SyntaxKind) -> bool { kind == FN } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1631,8 +1632,8 @@ impl AstNode for Rename { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for UseTree { - fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE } +impl AstNode for Impl { + fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1642,8 +1643,8 @@ impl AstNode for UseTree { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for Path { - fn can_cast(kind: SyntaxKind) -> bool { kind == PATH } +impl AstNode for MacroCall { + fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_CALL } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1653,8 +1654,8 @@ impl AstNode for Path { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for UseTreeList { - fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE_LIST } +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 }) @@ -1664,8 +1665,8 @@ impl AstNode for UseTreeList { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for Abi { - fn can_cast(kind: SyntaxKind) -> bool { kind == ABI } +impl AstNode for Static { + fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1675,8 +1676,8 @@ impl AstNode for Abi { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for GenericParamList { - fn can_cast(kind: SyntaxKind) -> bool { kind == GENERIC_PARAM_LIST } +impl AstNode for Struct { + fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1686,8 +1687,8 @@ impl AstNode for GenericParamList { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for ParamList { - fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM_LIST } +impl AstNode for Trait { + fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1697,8 +1698,8 @@ impl AstNode for ParamList { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for RetType { - fn can_cast(kind: SyntaxKind) -> bool { kind == RET_TYPE } +impl AstNode for TypeAlias { + fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1708,8 +1709,8 @@ impl AstNode for RetType { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for WhereClause { - fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_CLAUSE } +impl AstNode for Union { + fn can_cast(kind: SyntaxKind) -> bool { kind == UNION } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1719,8 +1720,8 @@ impl AstNode for WhereClause { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for BlockExpr { - fn can_cast(kind: SyntaxKind) -> bool { kind == BLOCK_EXPR } +impl AstNode for Use { + fn can_cast(kind: SyntaxKind) -> bool { kind == USE } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1730,8 +1731,8 @@ impl AstNode for BlockExpr { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for SelfParam { - fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM } +impl AstNode for Visibility { + fn can_cast(kind: SyntaxKind) -> bool { kind == VISIBILITY } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1741,8 +1742,8 @@ impl AstNode for SelfParam { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for Param { - fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM } +impl AstNode for Name { + fn can_cast(kind: SyntaxKind) -> bool { kind == NAME } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1752,8 +1753,96 @@ impl AstNode for Param { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for TypeBoundList { - fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST } +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 AstNode for Rename { + fn can_cast(kind: SyntaxKind) -> bool { kind == RENAME } + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + fn syntax(&self) -> &SyntaxNode { &self.syntax } +} +impl AstNode for UseTree { + fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE } + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + fn syntax(&self) -> &SyntaxNode { &self.syntax } +} +impl AstNode for UseTreeList { + fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE_LIST } + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + fn syntax(&self) -> &SyntaxNode { &self.syntax } +} +impl AstNode for Abi { + fn can_cast(kind: SyntaxKind) -> bool { kind == ABI } + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + fn syntax(&self) -> &SyntaxNode { &self.syntax } +} +impl AstNode for GenericParamList { + fn can_cast(kind: SyntaxKind) -> bool { kind == GENERIC_PARAM_LIST } + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + fn syntax(&self) -> &SyntaxNode { &self.syntax } +} +impl AstNode for WhereClause { + fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_CLAUSE } + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + fn syntax(&self) -> &SyntaxNode { &self.syntax } +} +impl AstNode for SelfParam { + fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM } + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + fn syntax(&self) -> &SyntaxNode { &self.syntax } +} +impl AstNode for Param { + fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1895,17 +1984,6 @@ impl AstNode for WherePred { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for Literal { - fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl AstNode for TokenTree { fn can_cast(kind: SyntaxKind) -> bool { kind == TOKEN_TREE } fn cast(syntax: SyntaxNode) -> Option { @@ -2280,17 +2358,6 @@ impl AstNode for ArgList { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for TypeArgList { - fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG_LIST } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl AstNode for Condition { fn can_cast(kind: SyntaxKind) -> bool { kind == CONDITION } fn cast(syntax: SyntaxNode) -> Option { @@ -2423,17 +2490,6 @@ impl AstNode for ParenType { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -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 AstNode for PointerType { fn can_cast(kind: SyntaxKind) -> bool { kind == POINTER_TYPE } fn cast(syntax: SyntaxNode) -> Option { @@ -2709,60 +2765,90 @@ impl AstNode for MacroStmts { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for PathSegment { - fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } +impl From for Type { + fn from(node: ArrayType) -> Type { Type::ArrayType(node) } } -impl AstNode for TypeArg { - fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } +impl From for Type { + fn from(node: DynTraitType) -> Type { Type::DynTraitType(node) } } -impl AstNode for LifetimeArg { - fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_ARG } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None +impl From for Type { + fn from(node: FnPointerType) -> Type { Type::FnPointerType(node) } +} +impl From for Type { + fn from(node: ForType) -> Type { Type::ForType(node) } +} +impl From for Type { + fn from(node: ImplTraitType) -> Type { Type::ImplTraitType(node) } +} +impl From for Type { + fn from(node: InferType) -> Type { Type::InferType(node) } +} +impl From for Type { + fn from(node: NeverType) -> Type { Type::NeverType(node) } +} +impl From for Type { + fn from(node: ParenType) -> Type { Type::ParenType(node) } +} +impl From for Type { + fn from(node: PathType) -> Type { Type::PathType(node) } +} +impl From for Type { + fn from(node: PointerType) -> Type { Type::PointerType(node) } +} +impl From for Type { + fn from(node: ReferenceType) -> Type { Type::ReferenceType(node) } +} +impl From for Type { + fn from(node: SliceType) -> Type { Type::SliceType(node) } +} +impl From for Type { + fn from(node: TupleType) -> Type { Type::TupleType(node) } +} +impl AstNode for Type { + fn can_cast(kind: SyntaxKind) -> bool { + match kind { + ARRAY_TYPE | DYN_TRAIT_TYPE | FN_POINTER_TYPE | FOR_TYPE | IMPL_TRAIT_TYPE + | INFER_TYPE | NEVER_TYPE | PAREN_TYPE | PATH_TYPE | POINTER_TYPE | REFERENCE_TYPE + | SLICE_TYPE | TUPLE_TYPE => true, + _ => false, } } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} -impl AstNode for AssocTypeArg { - fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_TYPE_ARG } fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } + let res = match syntax.kind() { + ARRAY_TYPE => Type::ArrayType(ArrayType { syntax }), + DYN_TRAIT_TYPE => Type::DynTraitType(DynTraitType { syntax }), + FN_POINTER_TYPE => Type::FnPointerType(FnPointerType { syntax }), + FOR_TYPE => Type::ForType(ForType { syntax }), + IMPL_TRAIT_TYPE => Type::ImplTraitType(ImplTraitType { syntax }), + INFER_TYPE => Type::InferType(InferType { syntax }), + NEVER_TYPE => Type::NeverType(NeverType { syntax }), + PAREN_TYPE => Type::ParenType(ParenType { syntax }), + PATH_TYPE => Type::PathType(PathType { syntax }), + POINTER_TYPE => Type::PointerType(PointerType { syntax }), + REFERENCE_TYPE => Type::ReferenceType(ReferenceType { syntax }), + SLICE_TYPE => Type::SliceType(SliceType { syntax }), + TUPLE_TYPE => Type::TupleType(TupleType { syntax }), + _ => return None, + }; + Some(res) } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} -impl AstNode for ConstArg { - fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_ARG } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None + fn syntax(&self) -> &SyntaxNode { + match self { + Type::ArrayType(it) => &it.syntax, + Type::DynTraitType(it) => &it.syntax, + Type::FnPointerType(it) => &it.syntax, + Type::ForType(it) => &it.syntax, + Type::ImplTraitType(it) => &it.syntax, + Type::InferType(it) => &it.syntax, + Type::NeverType(it) => &it.syntax, + Type::ParenType(it) => &it.syntax, + Type::PathType(it) => &it.syntax, + Type::PointerType(it) => &it.syntax, + Type::ReferenceType(it) => &it.syntax, + Type::SliceType(it) => &it.syntax, + Type::TupleType(it) => &it.syntax, } } - fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl From for Item { fn from(node: Const) -> Item { Item::Const(node) } @@ -2853,91 +2939,6 @@ impl AstNode for Item { } } } -impl From for Type { - fn from(node: ArrayType) -> Type { Type::ArrayType(node) } -} -impl From for Type { - fn from(node: DynTraitType) -> Type { Type::DynTraitType(node) } -} -impl From for Type { - fn from(node: FnPointerType) -> Type { Type::FnPointerType(node) } -} -impl From for Type { - fn from(node: ForType) -> Type { Type::ForType(node) } -} -impl From for Type { - fn from(node: ImplTraitType) -> Type { Type::ImplTraitType(node) } -} -impl From for Type { - fn from(node: InferType) -> Type { Type::InferType(node) } -} -impl From for Type { - fn from(node: NeverType) -> Type { Type::NeverType(node) } -} -impl From for Type { - fn from(node: ParenType) -> Type { Type::ParenType(node) } -} -impl From for Type { - fn from(node: PathType) -> Type { Type::PathType(node) } -} -impl From for Type { - fn from(node: PointerType) -> Type { Type::PointerType(node) } -} -impl From for Type { - fn from(node: ReferenceType) -> Type { Type::ReferenceType(node) } -} -impl From for Type { - fn from(node: SliceType) -> Type { Type::SliceType(node) } -} -impl From for Type { - fn from(node: TupleType) -> Type { Type::TupleType(node) } -} -impl AstNode for Type { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - ARRAY_TYPE | DYN_TRAIT_TYPE | FN_POINTER_TYPE | FOR_TYPE | IMPL_TRAIT_TYPE - | INFER_TYPE | NEVER_TYPE | PAREN_TYPE | PATH_TYPE | POINTER_TYPE | REFERENCE_TYPE - | SLICE_TYPE | TUPLE_TYPE => true, - _ => false, - } - } - fn cast(syntax: SyntaxNode) -> Option { - let res = match syntax.kind() { - ARRAY_TYPE => Type::ArrayType(ArrayType { syntax }), - DYN_TRAIT_TYPE => Type::DynTraitType(DynTraitType { syntax }), - FN_POINTER_TYPE => Type::FnPointerType(FnPointerType { syntax }), - FOR_TYPE => Type::ForType(ForType { syntax }), - IMPL_TRAIT_TYPE => Type::ImplTraitType(ImplTraitType { syntax }), - INFER_TYPE => Type::InferType(InferType { syntax }), - NEVER_TYPE => Type::NeverType(NeverType { syntax }), - PAREN_TYPE => Type::ParenType(ParenType { syntax }), - PATH_TYPE => Type::PathType(PathType { syntax }), - POINTER_TYPE => Type::PointerType(PointerType { syntax }), - REFERENCE_TYPE => Type::ReferenceType(ReferenceType { syntax }), - SLICE_TYPE => Type::SliceType(SliceType { syntax }), - TUPLE_TYPE => Type::TupleType(TupleType { syntax }), - _ => return None, - }; - Some(res) - } - fn syntax(&self) -> &SyntaxNode { - match self { - Type::ArrayType(it) => &it.syntax, - Type::DynTraitType(it) => &it.syntax, - Type::FnPointerType(it) => &it.syntax, - Type::ForType(it) => &it.syntax, - Type::ImplTraitType(it) => &it.syntax, - Type::InferType(it) => &it.syntax, - Type::NeverType(it) => &it.syntax, - Type::ParenType(it) => &it.syntax, - Type::PathType(it) => &it.syntax, - Type::PointerType(it) => &it.syntax, - Type::ReferenceType(it) => &it.syntax, - Type::SliceType(it) => &it.syntax, - Type::TupleType(it) => &it.syntax, - } - } -} impl From for Pat { fn from(node: OrPat) -> Pat { Pat::OrPat(node) } } @@ -3379,12 +3380,12 @@ impl From for Stmt { impl From for Stmt { fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) } } -impl std::fmt::Display for Item { +impl std::fmt::Display for Type { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for Type { +impl std::fmt::Display for Item { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } @@ -3429,6 +3430,76 @@ impl std::fmt::Display for Stmt { std::fmt::Display::fmt(self.syntax(), f) } } +impl std::fmt::Display for Path { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} +impl std::fmt::Display for PathSegment { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} +impl std::fmt::Display for NameRef { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} +impl std::fmt::Display for TypeArgList { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} +impl std::fmt::Display for ParamList { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} +impl std::fmt::Display for RetType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} +impl std::fmt::Display for PathType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} +impl std::fmt::Display for TypeArg { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} +impl std::fmt::Display for LifetimeArg { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} +impl std::fmt::Display for AssocTypeArg { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} +impl std::fmt::Display for ConstArg { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} +impl std::fmt::Display for TypeBoundList { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} +impl std::fmt::Display for Literal { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} +impl std::fmt::Display for BlockExpr { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} impl std::fmt::Display for SourceFile { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) @@ -3524,11 +3595,6 @@ impl std::fmt::Display for ItemList { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for NameRef { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - std::fmt::Display::fmt(self.syntax(), f) - } -} impl std::fmt::Display for Rename { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) @@ -3539,11 +3605,6 @@ impl std::fmt::Display for UseTree { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for Path { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - std::fmt::Display::fmt(self.syntax(), f) - } -} impl std::fmt::Display for UseTreeList { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) @@ -3559,26 +3620,11 @@ impl std::fmt::Display for GenericParamList { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for ParamList { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - std::fmt::Display::fmt(self.syntax(), f) - } -} -impl std::fmt::Display for RetType { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - std::fmt::Display::fmt(self.syntax(), f) - } -} impl std::fmt::Display for WhereClause { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for BlockExpr { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - std::fmt::Display::fmt(self.syntax(), f) - } -} impl std::fmt::Display for SelfParam { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) @@ -3589,11 +3635,6 @@ impl std::fmt::Display for Param { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for TypeBoundList { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - std::fmt::Display::fmt(self.syntax(), f) - } -} impl std::fmt::Display for RecordFieldList { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) @@ -3654,11 +3695,6 @@ impl std::fmt::Display for WherePred { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for Literal { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - std::fmt::Display::fmt(self.syntax(), f) - } -} impl std::fmt::Display for TokenTree { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) @@ -3829,11 +3865,6 @@ impl std::fmt::Display for ArgList { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for TypeArgList { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - std::fmt::Display::fmt(self.syntax(), f) - } -} impl std::fmt::Display for Condition { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) @@ -3894,11 +3925,6 @@ impl std::fmt::Display for ParenType { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for PathType { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - std::fmt::Display::fmt(self.syntax(), f) - } -} impl std::fmt::Display for PointerType { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) @@ -4024,28 +4050,3 @@ impl std::fmt::Display for MacroStmts { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for PathSegment { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - std::fmt::Display::fmt(self.syntax(), f) - } -} -impl std::fmt::Display for TypeArg { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - std::fmt::Display::fmt(self.syntax(), f) - } -} -impl std::fmt::Display for LifetimeArg { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - std::fmt::Display::fmt(self.syntax(), f) - } -} -impl std::fmt::Display for AssocTypeArg { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - std::fmt::Display::fmt(self.syntax(), f) - } -} -impl std::fmt::Display for ConstArg { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - std::fmt::Display::fmt(self.syntax(), f) - } -} -- cgit v1.2.3 From 91781c7ce8201b28afd56b4e35eba47e076a8498 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Jul 2020 18:29:29 +0200 Subject: Rename TypeArgList -> GenericArgList --- crates/ra_syntax/src/ast/generated/nodes.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'crates/ra_syntax/src/ast/generated') diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 1a707ad67..903646149 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs @@ -24,7 +24,7 @@ impl PathSegment { pub fn self_token(&self) -> Option { support::token(&self.syntax, T![self]) } pub fn super_token(&self) -> Option { support::token(&self.syntax, T![super]) } pub fn name_ref(&self) -> Option { support::child(&self.syntax) } - pub fn type_arg_list(&self) -> Option { support::child(&self.syntax) } + pub fn generic_arg_list(&self) -> Option { support::child(&self.syntax) } pub fn param_list(&self) -> Option { support::child(&self.syntax) } pub fn ret_type(&self) -> Option { support::child(&self.syntax) } pub fn l_angle_token(&self) -> Option { support::token(&self.syntax, T![<]) } @@ -40,10 +40,10 @@ impl NameRef { pub fn ident_token(&self) -> Option { support::token(&self.syntax, T![ident]) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct TypeArgList { +pub struct GenericArgList { pub(crate) syntax: SyntaxNode, } -impl TypeArgList { +impl GenericArgList { pub fn coloncolon_token(&self) -> Option { support::token(&self.syntax, T![::]) } pub fn l_angle_token(&self) -> Option { support::token(&self.syntax, T![<]) } pub fn type_args(&self) -> AstChildren { support::children(&self.syntax) } @@ -803,7 +803,7 @@ impl MethodCallExpr { pub fn expr(&self) -> Option { support::child(&self.syntax) } pub fn dot_token(&self) -> Option { support::token(&self.syntax, T![.]) } pub fn name_ref(&self) -> Option { support::child(&self.syntax) } - pub fn type_arg_list(&self) -> Option { support::child(&self.syntax) } + pub fn generic_arg_list(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ParenExpr { @@ -1434,8 +1434,8 @@ impl AstNode for NameRef { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for TypeArgList { - fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG_LIST } +impl AstNode for GenericArgList { + fn can_cast(kind: SyntaxKind) -> bool { kind == GENERIC_ARG_LIST } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3445,7 +3445,7 @@ impl std::fmt::Display for NameRef { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for TypeArgList { +impl std::fmt::Display for GenericArgList { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } -- cgit v1.2.3 From 040b4c800d5279e77a6825fc90cb2921d26c7f95 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Jul 2020 18:41:37 +0200 Subject: Fix GenericArgs grammar --- crates/ra_syntax/src/ast/generated/nodes.rs | 85 ++++++++++++++++++++++------- 1 file changed, 66 insertions(+), 19 deletions(-) (limited to 'crates/ra_syntax/src/ast/generated') diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 903646149..132c2ae8c 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs @@ -46,10 +46,7 @@ pub struct GenericArgList { impl GenericArgList { pub fn coloncolon_token(&self) -> Option { support::token(&self.syntax, T![::]) } pub fn l_angle_token(&self) -> Option { support::token(&self.syntax, T![<]) } - pub fn type_args(&self) -> AstChildren { support::children(&self.syntax) } - pub fn lifetime_args(&self) -> AstChildren { support::children(&self.syntax) } - pub fn assoc_type_args(&self) -> AstChildren { support::children(&self.syntax) } - pub fn const_args(&self) -> AstChildren { support::children(&self.syntax) } + pub fn generic_args(&self) -> AstChildren { support::children(&self.syntax) } pub fn r_angle_token(&self) -> Option { support::token(&self.syntax, T![>]) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -86,15 +83,6 @@ impl TypeArg { pub fn ty(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct LifetimeArg { - pub(crate) syntax: SyntaxNode, -} -impl LifetimeArg { - pub fn lifetime_token(&self) -> Option { - support::token(&self.syntax, T![lifetime]) - } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct AssocTypeArg { pub(crate) syntax: SyntaxNode, } @@ -105,6 +93,15 @@ impl AssocTypeArg { pub fn ty(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct LifetimeArg { + pub(crate) syntax: SyntaxNode, +} +impl LifetimeArg { + pub fn lifetime_token(&self) -> Option { + support::token(&self.syntax, T![lifetime]) + } +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ConstArg { pub(crate) syntax: SyntaxNode, } @@ -1272,6 +1269,13 @@ impl MacroStmts { pub fn expr(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub enum GenericArg { + TypeArg(TypeArg), + AssocTypeArg(AssocTypeArg), + LifetimeArg(LifetimeArg), + ConstArg(ConstArg), +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum Type { ArrayType(ArrayType), DynTraitType(DynTraitType), @@ -1489,8 +1493,8 @@ impl AstNode for TypeArg { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for LifetimeArg { - fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_ARG } +impl AstNode for AssocTypeArg { + fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_TYPE_ARG } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1500,8 +1504,8 @@ impl AstNode for LifetimeArg { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for AssocTypeArg { - fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_TYPE_ARG } +impl AstNode for LifetimeArg { + fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_ARG } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2765,6 +2769,44 @@ impl AstNode for MacroStmts { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } +impl From for GenericArg { + fn from(node: TypeArg) -> GenericArg { GenericArg::TypeArg(node) } +} +impl From for GenericArg { + fn from(node: AssocTypeArg) -> GenericArg { GenericArg::AssocTypeArg(node) } +} +impl From for GenericArg { + fn from(node: LifetimeArg) -> GenericArg { GenericArg::LifetimeArg(node) } +} +impl From for GenericArg { + fn from(node: ConstArg) -> GenericArg { GenericArg::ConstArg(node) } +} +impl AstNode for GenericArg { + fn can_cast(kind: SyntaxKind) -> bool { + match kind { + TYPE_ARG | ASSOC_TYPE_ARG | LIFETIME_ARG | CONST_ARG => true, + _ => false, + } + } + fn cast(syntax: SyntaxNode) -> Option { + let res = match syntax.kind() { + TYPE_ARG => GenericArg::TypeArg(TypeArg { syntax }), + ASSOC_TYPE_ARG => GenericArg::AssocTypeArg(AssocTypeArg { syntax }), + LIFETIME_ARG => GenericArg::LifetimeArg(LifetimeArg { syntax }), + CONST_ARG => GenericArg::ConstArg(ConstArg { syntax }), + _ => return None, + }; + Some(res) + } + fn syntax(&self) -> &SyntaxNode { + match self { + GenericArg::TypeArg(it) => &it.syntax, + GenericArg::AssocTypeArg(it) => &it.syntax, + GenericArg::LifetimeArg(it) => &it.syntax, + GenericArg::ConstArg(it) => &it.syntax, + } + } +} impl From for Type { fn from(node: ArrayType) -> Type { Type::ArrayType(node) } } @@ -3380,6 +3422,11 @@ impl From for Stmt { impl From for Stmt { fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) } } +impl std::fmt::Display for GenericArg { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} impl std::fmt::Display for Type { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) @@ -3470,12 +3517,12 @@ impl std::fmt::Display for TypeArg { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for LifetimeArg { +impl std::fmt::Display for AssocTypeArg { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for AssocTypeArg { +impl std::fmt::Display for LifetimeArg { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } -- cgit v1.2.3 From ddf08daddf7e86d67e8d2e5596f8013b376dd522 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Jul 2020 18:46:07 +0200 Subject: Fix const arguments grammar --- crates/ra_syntax/src/ast/generated/nodes.rs | 663 ++++++++++++++-------------- 1 file changed, 331 insertions(+), 332 deletions(-) (limited to 'crates/ra_syntax/src/ast/generated') diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 132c2ae8c..97a882bf0 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs @@ -106,8 +106,7 @@ pub struct ConstArg { pub(crate) syntax: SyntaxNode, } impl ConstArg { - pub fn literal(&self) -> Option { support::child(&self.syntax) } - pub fn block_expr(&self) -> Option { support::child(&self.syntax) } + pub fn expr(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct TypeBoundList { @@ -117,23 +116,6 @@ impl TypeBoundList { pub fn bounds(&self) -> AstChildren { support::children(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct Literal { - pub(crate) syntax: SyntaxNode, -} -impl ast::AttrsOwner for Literal {} -impl Literal {} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct BlockExpr { - pub(crate) syntax: SyntaxNode, -} -impl ast::AttrsOwner for BlockExpr {} -impl BlockExpr { - pub fn l_curly_token(&self) -> Option { support::token(&self.syntax, T!['{']) } - pub fn statements(&self) -> AstChildren { support::children(&self.syntax) } - pub fn expr(&self) -> Option { support::child(&self.syntax) } - pub fn r_curly_token(&self) -> Option { support::token(&self.syntax, T!['}']) } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct SourceFile { pub(crate) syntax: SyntaxNode, } @@ -437,6 +419,17 @@ impl WhereClause { pub fn predicates(&self) -> AstChildren { support::children(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct BlockExpr { + pub(crate) syntax: SyntaxNode, +} +impl ast::AttrsOwner for BlockExpr {} +impl BlockExpr { + pub fn l_curly_token(&self) -> Option { support::token(&self.syntax, T!['{']) } + pub fn statements(&self) -> AstChildren { support::children(&self.syntax) } + pub fn expr(&self) -> Option { support::child(&self.syntax) } + pub fn r_curly_token(&self) -> Option { support::token(&self.syntax, T!['}']) } +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct SelfParam { pub(crate) syntax: SyntaxNode, } @@ -590,6 +583,12 @@ impl WherePred { pub fn ty(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct Literal { + pub(crate) syntax: SyntaxNode, +} +impl ast::AttrsOwner for Literal {} +impl Literal {} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct TokenTree { pub(crate) syntax: SyntaxNode, } @@ -1292,6 +1291,39 @@ pub enum Type { TupleType(TupleType), } #[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub enum Expr { + ArrayExpr(ArrayExpr), + AwaitExpr(AwaitExpr), + BinExpr(BinExpr), + BlockExpr(BlockExpr), + BoxExpr(BoxExpr), + BreakExpr(BreakExpr), + CallExpr(CallExpr), + CastExpr(CastExpr), + ClosureExpr(ClosureExpr), + ContinueExpr(ContinueExpr), + EffectExpr(EffectExpr), + FieldExpr(FieldExpr), + ForExpr(ForExpr), + IfExpr(IfExpr), + IndexExpr(IndexExpr), + Literal(Literal), + LoopExpr(LoopExpr), + MacroCall(MacroCall), + MatchExpr(MatchExpr), + MethodCallExpr(MethodCallExpr), + ParenExpr(ParenExpr), + PathExpr(PathExpr), + PrefixExpr(PrefixExpr), + RangeExpr(RangeExpr), + RecordExpr(RecordExpr), + RefExpr(RefExpr), + ReturnExpr(ReturnExpr), + TryExpr(TryExpr), + TupleExpr(TupleExpr), + WhileExpr(WhileExpr), +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum Item { Const(Const), Enum(Enum), @@ -1333,39 +1365,6 @@ pub enum FieldList { TupleFieldList(TupleFieldList), } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub enum Expr { - ArrayExpr(ArrayExpr), - AwaitExpr(AwaitExpr), - BinExpr(BinExpr), - BlockExpr(BlockExpr), - BoxExpr(BoxExpr), - BreakExpr(BreakExpr), - CallExpr(CallExpr), - CastExpr(CastExpr), - ClosureExpr(ClosureExpr), - ContinueExpr(ContinueExpr), - EffectExpr(EffectExpr), - FieldExpr(FieldExpr), - ForExpr(ForExpr), - IfExpr(IfExpr), - IndexExpr(IndexExpr), - Literal(Literal), - LoopExpr(LoopExpr), - MacroCall(MacroCall), - MatchExpr(MatchExpr), - MethodCallExpr(MethodCallExpr), - ParenExpr(ParenExpr), - PathExpr(PathExpr), - PrefixExpr(PrefixExpr), - RangeExpr(RangeExpr), - RecordExpr(RecordExpr), - RefExpr(RefExpr), - ReturnExpr(ReturnExpr), - TryExpr(TryExpr), - TupleExpr(TupleExpr), - WhileExpr(WhileExpr), -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AdtDef { Enum(Enum), Struct(Struct), @@ -1537,28 +1536,6 @@ impl AstNode for TypeBoundList { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for Literal { - fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} -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 AstNode for SourceFile { fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE } fn cast(syntax: SyntaxNode) -> Option { @@ -1834,6 +1811,17 @@ impl AstNode for WhereClause { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } +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 AstNode for SelfParam { fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM } fn cast(syntax: SyntaxNode) -> Option { @@ -1988,6 +1976,17 @@ impl AstNode for WherePred { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } +impl AstNode for Literal { + fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL } + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + fn syntax(&self) -> &SyntaxNode { &self.syntax } +} impl AstNode for TokenTree { fn can_cast(kind: SyntaxKind) -> bool { kind == TOKEN_TREE } fn cast(syntax: SyntaxNode) -> Option { @@ -2892,265 +2891,53 @@ impl AstNode for Type { } } } -impl From for Item { - fn from(node: Const) -> Item { Item::Const(node) } +impl From for Expr { + fn from(node: ArrayExpr) -> Expr { Expr::ArrayExpr(node) } } -impl From for Item { - fn from(node: Enum) -> Item { Item::Enum(node) } +impl From for Expr { + fn from(node: AwaitExpr) -> Expr { Expr::AwaitExpr(node) } } -impl From for Item { - fn from(node: ExternBlock) -> Item { Item::ExternBlock(node) } +impl From for Expr { + fn from(node: BinExpr) -> Expr { Expr::BinExpr(node) } } -impl From for Item { - fn from(node: ExternCrate) -> Item { Item::ExternCrate(node) } +impl From for Expr { + fn from(node: BlockExpr) -> Expr { Expr::BlockExpr(node) } } -impl From for Item { - fn from(node: Fn) -> Item { Item::Fn(node) } +impl From for Expr { + fn from(node: BoxExpr) -> Expr { Expr::BoxExpr(node) } } -impl From for Item { - fn from(node: Impl) -> Item { Item::Impl(node) } +impl From for Expr { + fn from(node: BreakExpr) -> Expr { Expr::BreakExpr(node) } } -impl From for Item { - fn from(node: MacroCall) -> Item { Item::MacroCall(node) } +impl From for Expr { + fn from(node: CallExpr) -> Expr { Expr::CallExpr(node) } } -impl From for Item { - fn from(node: Module) -> Item { Item::Module(node) } +impl From for Expr { + fn from(node: CastExpr) -> Expr { Expr::CastExpr(node) } } -impl From for Item { - fn from(node: Static) -> Item { Item::Static(node) } +impl From for Expr { + fn from(node: ClosureExpr) -> Expr { Expr::ClosureExpr(node) } } -impl From for Item { - fn from(node: Struct) -> Item { Item::Struct(node) } +impl From for Expr { + fn from(node: ContinueExpr) -> Expr { Expr::ContinueExpr(node) } } -impl From for Item { - fn from(node: Trait) -> Item { Item::Trait(node) } +impl From for Expr { + fn from(node: EffectExpr) -> Expr { Expr::EffectExpr(node) } } -impl From for Item { - fn from(node: TypeAlias) -> Item { Item::TypeAlias(node) } +impl From for Expr { + fn from(node: FieldExpr) -> Expr { Expr::FieldExpr(node) } } -impl From for Item { - fn from(node: Union) -> Item { Item::Union(node) } +impl From for Expr { + fn from(node: ForExpr) -> Expr { Expr::ForExpr(node) } } -impl From for Item { - fn from(node: Use) -> Item { Item::Use(node) } +impl From for Expr { + fn from(node: IfExpr) -> Expr { Expr::IfExpr(node) } } -impl AstNode for Item { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - CONST | ENUM | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL | MACRO_CALL | MODULE - | STATIC | STRUCT | TRAIT | TYPE_ALIAS | UNION | USE => true, - _ => false, - } - } - fn cast(syntax: SyntaxNode) -> Option { - let res = match syntax.kind() { - CONST => Item::Const(Const { syntax }), - ENUM => Item::Enum(Enum { syntax }), - EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }), - EXTERN_CRATE => Item::ExternCrate(ExternCrate { syntax }), - FN => Item::Fn(Fn { syntax }), - IMPL => Item::Impl(Impl { syntax }), - MACRO_CALL => Item::MacroCall(MacroCall { syntax }), - MODULE => Item::Module(Module { syntax }), - STATIC => Item::Static(Static { syntax }), - STRUCT => Item::Struct(Struct { syntax }), - TRAIT => Item::Trait(Trait { syntax }), - TYPE_ALIAS => Item::TypeAlias(TypeAlias { syntax }), - UNION => Item::Union(Union { syntax }), - USE => Item::Use(Use { syntax }), - _ => return None, - }; - Some(res) - } - fn syntax(&self) -> &SyntaxNode { - match self { - Item::Const(it) => &it.syntax, - Item::Enum(it) => &it.syntax, - Item::ExternBlock(it) => &it.syntax, - Item::ExternCrate(it) => &it.syntax, - Item::Fn(it) => &it.syntax, - Item::Impl(it) => &it.syntax, - Item::MacroCall(it) => &it.syntax, - Item::Module(it) => &it.syntax, - Item::Static(it) => &it.syntax, - Item::Struct(it) => &it.syntax, - Item::Trait(it) => &it.syntax, - Item::TypeAlias(it) => &it.syntax, - Item::Union(it) => &it.syntax, - Item::Use(it) => &it.syntax, - } - } +impl From for Expr { + fn from(node: IndexExpr) -> Expr { Expr::IndexExpr(node) } } -impl From for Pat { - fn from(node: OrPat) -> Pat { Pat::OrPat(node) } -} -impl From for Pat { - fn from(node: ParenPat) -> Pat { Pat::ParenPat(node) } -} -impl From for Pat { - fn from(node: RefPat) -> Pat { Pat::RefPat(node) } -} -impl From for Pat { - fn from(node: BoxPat) -> Pat { Pat::BoxPat(node) } -} -impl From for Pat { - fn from(node: BindPat) -> Pat { Pat::BindPat(node) } -} -impl From for Pat { - fn from(node: PlaceholderPat) -> Pat { Pat::PlaceholderPat(node) } -} -impl From for Pat { - fn from(node: DotDotPat) -> Pat { Pat::DotDotPat(node) } -} -impl From for Pat { - fn from(node: PathPat) -> Pat { Pat::PathPat(node) } -} -impl From for Pat { - fn from(node: RecordPat) -> Pat { Pat::RecordPat(node) } -} -impl From for Pat { - fn from(node: TupleStructPat) -> Pat { Pat::TupleStructPat(node) } -} -impl From for Pat { - fn from(node: TuplePat) -> Pat { Pat::TuplePat(node) } -} -impl From for Pat { - fn from(node: SlicePat) -> Pat { Pat::SlicePat(node) } -} -impl From for Pat { - fn from(node: RangePat) -> Pat { Pat::RangePat(node) } -} -impl From for Pat { - fn from(node: LiteralPat) -> Pat { Pat::LiteralPat(node) } -} -impl From for Pat { - fn from(node: MacroPat) -> Pat { Pat::MacroPat(node) } -} -impl AstNode for Pat { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT - | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT - | LITERAL_PAT | MACRO_PAT => true, - _ => false, - } - } - fn cast(syntax: SyntaxNode) -> Option { - let res = match syntax.kind() { - OR_PAT => Pat::OrPat(OrPat { syntax }), - PAREN_PAT => Pat::ParenPat(ParenPat { syntax }), - REF_PAT => Pat::RefPat(RefPat { syntax }), - BOX_PAT => Pat::BoxPat(BoxPat { syntax }), - BIND_PAT => Pat::BindPat(BindPat { syntax }), - PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }), - DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }), - PATH_PAT => Pat::PathPat(PathPat { syntax }), - RECORD_PAT => Pat::RecordPat(RecordPat { syntax }), - TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }), - TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }), - SLICE_PAT => Pat::SlicePat(SlicePat { syntax }), - RANGE_PAT => Pat::RangePat(RangePat { syntax }), - LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }), - MACRO_PAT => Pat::MacroPat(MacroPat { syntax }), - _ => return None, - }; - Some(res) - } - fn syntax(&self) -> &SyntaxNode { - match self { - Pat::OrPat(it) => &it.syntax, - Pat::ParenPat(it) => &it.syntax, - Pat::RefPat(it) => &it.syntax, - Pat::BoxPat(it) => &it.syntax, - Pat::BindPat(it) => &it.syntax, - Pat::PlaceholderPat(it) => &it.syntax, - Pat::DotDotPat(it) => &it.syntax, - Pat::PathPat(it) => &it.syntax, - Pat::RecordPat(it) => &it.syntax, - Pat::TupleStructPat(it) => &it.syntax, - Pat::TuplePat(it) => &it.syntax, - Pat::SlicePat(it) => &it.syntax, - Pat::RangePat(it) => &it.syntax, - Pat::LiteralPat(it) => &it.syntax, - Pat::MacroPat(it) => &it.syntax, - } - } -} -impl From for FieldList { - fn from(node: RecordFieldList) -> FieldList { FieldList::RecordFieldList(node) } -} -impl From for FieldList { - fn from(node: TupleFieldList) -> FieldList { FieldList::TupleFieldList(node) } -} -impl AstNode for FieldList { - fn can_cast(kind: SyntaxKind) -> bool { - match kind { - RECORD_FIELD_LIST | TUPLE_FIELD_LIST => true, - _ => false, - } - } - fn cast(syntax: SyntaxNode) -> Option { - let res = match syntax.kind() { - RECORD_FIELD_LIST => FieldList::RecordFieldList(RecordFieldList { syntax }), - TUPLE_FIELD_LIST => FieldList::TupleFieldList(TupleFieldList { syntax }), - _ => return None, - }; - Some(res) - } - fn syntax(&self) -> &SyntaxNode { - match self { - FieldList::RecordFieldList(it) => &it.syntax, - FieldList::TupleFieldList(it) => &it.syntax, - } - } -} -impl From for Expr { - fn from(node: ArrayExpr) -> Expr { Expr::ArrayExpr(node) } -} -impl From for Expr { - fn from(node: AwaitExpr) -> Expr { Expr::AwaitExpr(node) } -} -impl From for Expr { - fn from(node: BinExpr) -> Expr { Expr::BinExpr(node) } -} -impl From for Expr { - fn from(node: BlockExpr) -> Expr { Expr::BlockExpr(node) } -} -impl From for Expr { - fn from(node: BoxExpr) -> Expr { Expr::BoxExpr(node) } -} -impl From for Expr { - fn from(node: BreakExpr) -> Expr { Expr::BreakExpr(node) } -} -impl From for Expr { - fn from(node: CallExpr) -> Expr { Expr::CallExpr(node) } -} -impl From for Expr { - fn from(node: CastExpr) -> Expr { Expr::CastExpr(node) } -} -impl From for Expr { - fn from(node: ClosureExpr) -> Expr { Expr::ClosureExpr(node) } -} -impl From for Expr { - fn from(node: ContinueExpr) -> Expr { Expr::ContinueExpr(node) } -} -impl From for Expr { - fn from(node: EffectExpr) -> Expr { Expr::EffectExpr(node) } -} -impl From for Expr { - fn from(node: FieldExpr) -> Expr { Expr::FieldExpr(node) } -} -impl From for Expr { - fn from(node: ForExpr) -> Expr { Expr::ForExpr(node) } -} -impl From for Expr { - fn from(node: IfExpr) -> Expr { Expr::IfExpr(node) } -} -impl From for Expr { - fn from(node: IndexExpr) -> Expr { Expr::IndexExpr(node) } -} -impl From for Expr { - fn from(node: Literal) -> Expr { Expr::Literal(node) } +impl From for Expr { + fn from(node: Literal) -> Expr { Expr::Literal(node) } } impl From for Expr { fn from(node: LoopExpr) -> Expr { Expr::LoopExpr(node) } @@ -3276,6 +3063,218 @@ impl AstNode for Expr { } } } +impl From for Item { + fn from(node: Const) -> Item { Item::Const(node) } +} +impl From for Item { + fn from(node: Enum) -> Item { Item::Enum(node) } +} +impl From for Item { + fn from(node: ExternBlock) -> Item { Item::ExternBlock(node) } +} +impl From for Item { + fn from(node: ExternCrate) -> Item { Item::ExternCrate(node) } +} +impl From for Item { + fn from(node: Fn) -> Item { Item::Fn(node) } +} +impl From for Item { + fn from(node: Impl) -> Item { Item::Impl(node) } +} +impl From for Item { + fn from(node: MacroCall) -> Item { Item::MacroCall(node) } +} +impl From for Item { + fn from(node: Module) -> Item { Item::Module(node) } +} +impl From for Item { + fn from(node: Static) -> Item { Item::Static(node) } +} +impl From for Item { + fn from(node: Struct) -> Item { Item::Struct(node) } +} +impl From for Item { + fn from(node: Trait) -> Item { Item::Trait(node) } +} +impl From for Item { + fn from(node: TypeAlias) -> Item { Item::TypeAlias(node) } +} +impl From for Item { + fn from(node: Union) -> Item { Item::Union(node) } +} +impl From for Item { + fn from(node: Use) -> Item { Item::Use(node) } +} +impl AstNode for Item { + fn can_cast(kind: SyntaxKind) -> bool { + match kind { + CONST | ENUM | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL | MACRO_CALL | MODULE + | STATIC | STRUCT | TRAIT | TYPE_ALIAS | UNION | USE => true, + _ => false, + } + } + fn cast(syntax: SyntaxNode) -> Option { + let res = match syntax.kind() { + CONST => Item::Const(Const { syntax }), + ENUM => Item::Enum(Enum { syntax }), + EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }), + EXTERN_CRATE => Item::ExternCrate(ExternCrate { syntax }), + FN => Item::Fn(Fn { syntax }), + IMPL => Item::Impl(Impl { syntax }), + MACRO_CALL => Item::MacroCall(MacroCall { syntax }), + MODULE => Item::Module(Module { syntax }), + STATIC => Item::Static(Static { syntax }), + STRUCT => Item::Struct(Struct { syntax }), + TRAIT => Item::Trait(Trait { syntax }), + TYPE_ALIAS => Item::TypeAlias(TypeAlias { syntax }), + UNION => Item::Union(Union { syntax }), + USE => Item::Use(Use { syntax }), + _ => return None, + }; + Some(res) + } + fn syntax(&self) -> &SyntaxNode { + match self { + Item::Const(it) => &it.syntax, + Item::Enum(it) => &it.syntax, + Item::ExternBlock(it) => &it.syntax, + Item::ExternCrate(it) => &it.syntax, + Item::Fn(it) => &it.syntax, + Item::Impl(it) => &it.syntax, + Item::MacroCall(it) => &it.syntax, + Item::Module(it) => &it.syntax, + Item::Static(it) => &it.syntax, + Item::Struct(it) => &it.syntax, + Item::Trait(it) => &it.syntax, + Item::TypeAlias(it) => &it.syntax, + Item::Union(it) => &it.syntax, + Item::Use(it) => &it.syntax, + } + } +} +impl From for Pat { + fn from(node: OrPat) -> Pat { Pat::OrPat(node) } +} +impl From for Pat { + fn from(node: ParenPat) -> Pat { Pat::ParenPat(node) } +} +impl From for Pat { + fn from(node: RefPat) -> Pat { Pat::RefPat(node) } +} +impl From for Pat { + fn from(node: BoxPat) -> Pat { Pat::BoxPat(node) } +} +impl From for Pat { + fn from(node: BindPat) -> Pat { Pat::BindPat(node) } +} +impl From for Pat { + fn from(node: PlaceholderPat) -> Pat { Pat::PlaceholderPat(node) } +} +impl From for Pat { + fn from(node: DotDotPat) -> Pat { Pat::DotDotPat(node) } +} +impl From for Pat { + fn from(node: PathPat) -> Pat { Pat::PathPat(node) } +} +impl From for Pat { + fn from(node: RecordPat) -> Pat { Pat::RecordPat(node) } +} +impl From for Pat { + fn from(node: TupleStructPat) -> Pat { Pat::TupleStructPat(node) } +} +impl From for Pat { + fn from(node: TuplePat) -> Pat { Pat::TuplePat(node) } +} +impl From for Pat { + fn from(node: SlicePat) -> Pat { Pat::SlicePat(node) } +} +impl From for Pat { + fn from(node: RangePat) -> Pat { Pat::RangePat(node) } +} +impl From for Pat { + fn from(node: LiteralPat) -> Pat { Pat::LiteralPat(node) } +} +impl From for Pat { + fn from(node: MacroPat) -> Pat { Pat::MacroPat(node) } +} +impl AstNode for Pat { + fn can_cast(kind: SyntaxKind) -> bool { + match kind { + OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT + | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT + | LITERAL_PAT | MACRO_PAT => true, + _ => false, + } + } + fn cast(syntax: SyntaxNode) -> Option { + let res = match syntax.kind() { + OR_PAT => Pat::OrPat(OrPat { syntax }), + PAREN_PAT => Pat::ParenPat(ParenPat { syntax }), + REF_PAT => Pat::RefPat(RefPat { syntax }), + BOX_PAT => Pat::BoxPat(BoxPat { syntax }), + BIND_PAT => Pat::BindPat(BindPat { syntax }), + PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }), + DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }), + PATH_PAT => Pat::PathPat(PathPat { syntax }), + RECORD_PAT => Pat::RecordPat(RecordPat { syntax }), + TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }), + TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }), + SLICE_PAT => Pat::SlicePat(SlicePat { syntax }), + RANGE_PAT => Pat::RangePat(RangePat { syntax }), + LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }), + MACRO_PAT => Pat::MacroPat(MacroPat { syntax }), + _ => return None, + }; + Some(res) + } + fn syntax(&self) -> &SyntaxNode { + match self { + Pat::OrPat(it) => &it.syntax, + Pat::ParenPat(it) => &it.syntax, + Pat::RefPat(it) => &it.syntax, + Pat::BoxPat(it) => &it.syntax, + Pat::BindPat(it) => &it.syntax, + Pat::PlaceholderPat(it) => &it.syntax, + Pat::DotDotPat(it) => &it.syntax, + Pat::PathPat(it) => &it.syntax, + Pat::RecordPat(it) => &it.syntax, + Pat::TupleStructPat(it) => &it.syntax, + Pat::TuplePat(it) => &it.syntax, + Pat::SlicePat(it) => &it.syntax, + Pat::RangePat(it) => &it.syntax, + Pat::LiteralPat(it) => &it.syntax, + Pat::MacroPat(it) => &it.syntax, + } + } +} +impl From for FieldList { + fn from(node: RecordFieldList) -> FieldList { FieldList::RecordFieldList(node) } +} +impl From for FieldList { + fn from(node: TupleFieldList) -> FieldList { FieldList::TupleFieldList(node) } +} +impl AstNode for FieldList { + fn can_cast(kind: SyntaxKind) -> bool { + match kind { + RECORD_FIELD_LIST | TUPLE_FIELD_LIST => true, + _ => false, + } + } + fn cast(syntax: SyntaxNode) -> Option { + let res = match syntax.kind() { + RECORD_FIELD_LIST => FieldList::RecordFieldList(RecordFieldList { syntax }), + TUPLE_FIELD_LIST => FieldList::TupleFieldList(TupleFieldList { syntax }), + _ => return None, + }; + Some(res) + } + fn syntax(&self) -> &SyntaxNode { + match self { + FieldList::RecordFieldList(it) => &it.syntax, + FieldList::TupleFieldList(it) => &it.syntax, + } + } +} impl From for AdtDef { fn from(node: Enum) -> AdtDef { AdtDef::Enum(node) } } @@ -3432,22 +3431,22 @@ impl std::fmt::Display for Type { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for Item { +impl std::fmt::Display for Expr { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for Pat { +impl std::fmt::Display for Item { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for FieldList { +impl std::fmt::Display for Pat { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for Expr { +impl std::fmt::Display for FieldList { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } @@ -3537,16 +3536,6 @@ impl std::fmt::Display for TypeBoundList { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for Literal { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - std::fmt::Display::fmt(self.syntax(), f) - } -} -impl std::fmt::Display for BlockExpr { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - std::fmt::Display::fmt(self.syntax(), f) - } -} impl std::fmt::Display for SourceFile { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) @@ -3672,6 +3661,11 @@ impl std::fmt::Display for WhereClause { std::fmt::Display::fmt(self.syntax(), f) } } +impl std::fmt::Display for BlockExpr { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} impl std::fmt::Display for SelfParam { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) @@ -3742,6 +3736,11 @@ impl std::fmt::Display for WherePred { std::fmt::Display::fmt(self.syntax(), f) } } +impl std::fmt::Display for Literal { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} impl std::fmt::Display for TokenTree { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) -- cgit v1.2.3 From c1c97b289662501cea93fdc10760e08702ff5950 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Jul 2020 18:49:42 +0200 Subject: Fix leading colon --- crates/ra_syntax/src/ast/generated/nodes.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_syntax/src/ast/generated') diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 97a882bf0..c25fa7d5f 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs @@ -19,10 +19,10 @@ pub struct PathSegment { pub(crate) syntax: SyntaxNode, } impl PathSegment { - pub fn coloncolon_token(&self) -> Option { support::token(&self.syntax, T![::]) } pub fn crate_token(&self) -> Option { support::token(&self.syntax, T![crate]) } pub fn self_token(&self) -> Option { support::token(&self.syntax, T![self]) } pub fn super_token(&self) -> Option { support::token(&self.syntax, T![super]) } + pub fn coloncolon_token(&self) -> Option { support::token(&self.syntax, T![::]) } pub fn name_ref(&self) -> Option { support::child(&self.syntax) } pub fn generic_arg_list(&self) -> Option { support::child(&self.syntax) } pub fn param_list(&self) -> Option { support::child(&self.syntax) } -- cgit v1.2.3