From dcf8e895038a7677711b8168ee12e1d47f6018bc Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 2 Sep 2019 19:42:14 +0300 Subject: [PATCH] fix generated AST --- crates/ra_syntax/src/ast/generated.rs | 2 +- crates/ra_syntax/src/grammar.ron | 2 +- crates/ra_syntax/src/lib.rs | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 7f91417c57..fd85a32315 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs @@ -1003,7 +1003,7 @@ impl FnDef { pub fn param_list(&self) -> Option { AstChildren::new(&self.syntax).next() } - pub fn body(&self) -> Option { + pub fn body(&self) -> Option { AstChildren::new(&self.syntax).next() } pub fn ret_type(&self) -> Option { diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron index 9f17a10edb..37166182f9 100644 --- a/crates/ra_syntax/src/grammar.ron +++ b/crates/ra_syntax/src/grammar.ron @@ -275,7 +275,7 @@ Grammar( "AttrsOwner", "DocCommentsOwner" ], - options: [ "ParamList", ["body", "Block"], "RetType" ], + options: [ "ParamList", ["body", "BlockExpr"], "RetType" ], ), "RetType": (options: ["TypeRef"]), "StructDef": ( diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs index 2bced18678..edb6076bba 100644 --- a/crates/ra_syntax/src/lib.rs +++ b/crates/ra_syntax/src/lib.rs @@ -203,7 +203,8 @@ fn api_walkthrough() { assert_eq!(name.text(), "foo"); // Let's get the `1 + 1` expression! - let block: ast::Block = func.body().unwrap(); + let body: ast::BlockExpr = func.body().unwrap(); + let block = body.block().unwrap(); let expr: ast::Expr = block.expr().unwrap(); // Enums are used to group related ast nodes together, and can be used for