mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
fix generated AST
This commit is contained in:
parent
470fc4765c
commit
dcf8e89503
@ -1003,7 +1003,7 @@ impl FnDef {
|
|||||||
pub fn param_list(&self) -> Option<ParamList> {
|
pub fn param_list(&self) -> Option<ParamList> {
|
||||||
AstChildren::new(&self.syntax).next()
|
AstChildren::new(&self.syntax).next()
|
||||||
}
|
}
|
||||||
pub fn body(&self) -> Option<Block> {
|
pub fn body(&self) -> Option<BlockExpr> {
|
||||||
AstChildren::new(&self.syntax).next()
|
AstChildren::new(&self.syntax).next()
|
||||||
}
|
}
|
||||||
pub fn ret_type(&self) -> Option<RetType> {
|
pub fn ret_type(&self) -> Option<RetType> {
|
||||||
|
@ -275,7 +275,7 @@ Grammar(
|
|||||||
"AttrsOwner",
|
"AttrsOwner",
|
||||||
"DocCommentsOwner"
|
"DocCommentsOwner"
|
||||||
],
|
],
|
||||||
options: [ "ParamList", ["body", "Block"], "RetType" ],
|
options: [ "ParamList", ["body", "BlockExpr"], "RetType" ],
|
||||||
),
|
),
|
||||||
"RetType": (options: ["TypeRef"]),
|
"RetType": (options: ["TypeRef"]),
|
||||||
"StructDef": (
|
"StructDef": (
|
||||||
|
@ -203,7 +203,8 @@ fn api_walkthrough() {
|
|||||||
assert_eq!(name.text(), "foo");
|
assert_eq!(name.text(), "foo");
|
||||||
|
|
||||||
// Let's get the `1 + 1` expression!
|
// 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();
|
let expr: ast::Expr = block.expr().unwrap();
|
||||||
|
|
||||||
// Enums are used to group related ast nodes together, and can be used for
|
// Enums are used to group related ast nodes together, and can be used for
|
||||||
|
Loading…
x
Reference in New Issue
Block a user