From 2b828c68e8acda628d6e3a36827d1ffd9c9aaec6 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 14 Aug 2018 11:20:09 +0300 Subject: separete structure from symbols --- crates/libsyntax2/src/ast/generated.rs | 18 ++++++++++++++++++ crates/libsyntax2/src/ast/mod.rs | 5 +++-- crates/libsyntax2/src/grammar.ron | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) (limited to 'crates/libsyntax2/src') diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs index b347a05b4..13668b803 100644 --- a/crates/libsyntax2/src/ast/generated.rs +++ b/crates/libsyntax2/src/ast/generated.rs @@ -86,6 +86,24 @@ impl AstNode for FnDef { impl ast::NameOwner for FnDef {} impl FnDef {} +// ImplItem +#[derive(Debug, Clone, Copy)] +pub struct ImplItem> { + syntax: SyntaxNode, +} + +impl AstNode for ImplItem { + fn cast(syntax: SyntaxNode) -> Option { + match syntax.kind() { + IMPL_ITEM => Some(ImplItem { syntax }), + _ => None, + } + } + fn syntax(&self) -> &SyntaxNode { &self.syntax } +} + +impl ImplItem {} + // Module #[derive(Debug, Clone, Copy)] pub struct Module> { diff --git a/crates/libsyntax2/src/ast/mod.rs b/crates/libsyntax2/src/ast/mod.rs index 18a9f5d17..f001d340e 100644 --- a/crates/libsyntax2/src/ast/mod.rs +++ b/crates/libsyntax2/src/ast/mod.rs @@ -10,8 +10,9 @@ use { }; pub use self::generated::*; -pub trait AstNode: Sized { - fn cast(syntax: SyntaxNode) -> Option; +pub trait AstNode { + fn cast(syntax: SyntaxNode) -> Option + where Self: Sized; fn syntax(&self) -> &SyntaxNode; } diff --git a/crates/libsyntax2/src/grammar.ron b/crates/libsyntax2/src/grammar.ron index ef56761fd..ebd7d3943 100644 --- a/crates/libsyntax2/src/grammar.ron +++ b/crates/libsyntax2/src/grammar.ron @@ -229,6 +229,7 @@ Grammar( "ConstDef": ( traits: ["NameOwner"] ), "StaticDef": ( traits: ["NameOwner"] ), "TypeDef": ( traits: ["NameOwner"] ), + "ImplItem": (), "Name": (), "NameRef": (), }, -- cgit v1.2.3