diff options
Diffstat (limited to 'crates/libsyntax2/src/ast')
-rw-r--r-- | crates/libsyntax2/src/ast/generated.rs | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs index b937fe5a2..1dd161f52 100644 --- a/crates/libsyntax2/src/ast/generated.rs +++ b/crates/libsyntax2/src/ast/generated.rs | |||
@@ -116,9 +116,13 @@ impl<'a> AstNode<'a> for Block<'a> { | |||
116 | } | 116 | } |
117 | 117 | ||
118 | impl<'a> Block<'a> { | 118 | impl<'a> Block<'a> { |
119 | pub fn let_stmts(self) -> impl Iterator<Item = LetStmt<'a>> + 'a { | 119 | pub fn statements(self) -> impl Iterator<Item = Stmt<'a>> + 'a { |
120 | super::children(self) | 120 | super::children(self) |
121 | } | 121 | } |
122 | |||
123 | pub fn expr(self) -> Option<Expr<'a>> { | ||
124 | super::child_opt(self) | ||
125 | } | ||
122 | } | 126 | } |
123 | 127 | ||
124 | // BlockExpr | 128 | // BlockExpr |
@@ -1370,6 +1374,31 @@ impl<'a> ast::TypeParamsOwner<'a> for StaticDef<'a> {} | |||
1370 | impl<'a> ast::AttrsOwner<'a> for StaticDef<'a> {} | 1374 | impl<'a> ast::AttrsOwner<'a> for StaticDef<'a> {} |
1371 | impl<'a> StaticDef<'a> {} | 1375 | impl<'a> StaticDef<'a> {} |
1372 | 1376 | ||
1377 | // Stmt | ||
1378 | #[derive(Debug, Clone, Copy)] | ||
1379 | pub enum Stmt<'a> { | ||
1380 | ExprStmt(ExprStmt<'a>), | ||
1381 | LetStmt(LetStmt<'a>), | ||
1382 | } | ||
1383 | |||
1384 | impl<'a> AstNode<'a> for Stmt<'a> { | ||
1385 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | ||
1386 | match syntax.kind() { | ||
1387 | EXPR_STMT => Some(Stmt::ExprStmt(ExprStmt { syntax })), | ||
1388 | LET_STMT => Some(Stmt::LetStmt(LetStmt { syntax })), | ||
1389 | _ => None, | ||
1390 | } | ||
1391 | } | ||
1392 | fn syntax(self) -> SyntaxNodeRef<'a> { | ||
1393 | match self { | ||
1394 | Stmt::ExprStmt(inner) => inner.syntax(), | ||
1395 | Stmt::LetStmt(inner) => inner.syntax(), | ||
1396 | } | ||
1397 | } | ||
1398 | } | ||
1399 | |||
1400 | impl<'a> Stmt<'a> {} | ||
1401 | |||
1373 | // StructDef | 1402 | // StructDef |
1374 | #[derive(Debug, Clone, Copy)] | 1403 | #[derive(Debug, Clone, Copy)] |
1375 | pub struct StructDef<'a> { | 1404 | pub struct StructDef<'a> { |