From dcf8e895038a7677711b8168ee12e1d47f6018bc Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 2 Sep 2019 19:42:14 +0300 Subject: 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(-) (limited to 'crates') diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 7f91417c5..fd85a3231 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 9f17a10ed..37166182f 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 2bced1867..edb6076bb 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 -- cgit v1.2.3