Item is a Stmt

This commit is contained in:
Aleksey Kladov 2020-07-31 15:46:12 +02:00
parent a7ca6583fb
commit d4d986c7f8
6 changed files with 36 additions and 15 deletions

View file

@ -348,7 +348,6 @@ pub struct BlockExpr {
pub(crate) syntax: SyntaxNode,
}
impl ast::AttrsOwner for BlockExpr {}
impl ast::ModuleItemOwner for BlockExpr {}
impl BlockExpr {
pub fn label(&self) -> Option<Label> { support::child(&self.syntax) }
pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) }
@ -1395,8 +1394,8 @@ impl ast::AttrsOwner for GenericParam {}
pub enum Stmt {
LetStmt(LetStmt),
ExprStmt(ExprStmt),
Item(Item),
}
impl ast::AttrsOwner for Stmt {}
impl AstNode for SourceFile {
fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE }
fn cast(syntax: SyntaxNode) -> Option<Self> {
@ -3380,6 +3379,9 @@ impl From<LetStmt> for Stmt {
impl From<ExprStmt> for Stmt {
fn from(node: ExprStmt) -> Stmt { Stmt::ExprStmt(node) }
}
impl From<Item> for Stmt {
fn from(node: Item) -> Stmt { Stmt::Item(node) }
}
impl std::fmt::Display for Item {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)