Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/syntax/src/lib.rs')
| -rw-r--r-- | crates/syntax/src/lib.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/crates/syntax/src/lib.rs b/crates/syntax/src/lib.rs index 40460e18c3..00749d742f 100644 --- a/crates/syntax/src/lib.rs +++ b/crates/syntax/src/lib.rs @@ -295,7 +295,8 @@ fn api_walkthrough() { // Let's get the `1 + 1` expression! let body: ast::BlockExpr = func.body().unwrap(); - let expr: ast::Expr = body.tail_expr().unwrap(); + let stmt_list: ast::StmtList = body.stmt_list().unwrap(); + let expr: ast::Expr = stmt_list.tail_expr().unwrap(); // Enums are used to group related ast nodes together, and can be used for // matching. However, because there are no public fields, it's possible to @@ -331,8 +332,8 @@ fn api_walkthrough() { assert_eq!(text.to_string(), "1 + 1"); // There's a bunch of traversal methods on `SyntaxNode`: - assert_eq!(expr_syntax.parent().as_ref(), Some(body.syntax())); - assert_eq!(body.syntax().first_child_or_token().map(|it| it.kind()), Some(T!['{'])); + assert_eq!(expr_syntax.parent().as_ref(), Some(stmt_list.syntax())); + assert_eq!(stmt_list.syntax().first_child_or_token().map(|it| it.kind()), Some(T!['{'])); assert_eq!( expr_syntax.next_sibling_or_token().map(|it| it.kind()), Some(SyntaxKind::WHITESPACE) |