diff options
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/ast.rs | 18 | ||||
-rw-r--r-- | crates/ra_syntax/src/grammar/expressions.rs | 2 |
2 files changed, 17 insertions, 3 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index d59890d95..3d22a88f3 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs | |||
@@ -302,13 +302,27 @@ impl LetStmt { | |||
302 | } | 302 | } |
303 | } | 303 | } |
304 | 304 | ||
305 | #[derive(Debug, Clone, PartialEq, Eq)] | ||
306 | pub enum ElseBranchFlavor<'a> { | ||
307 | Block(&'a Block), | ||
308 | IfExpr(&'a IfExpr), | ||
309 | } | ||
310 | |||
305 | impl IfExpr { | 311 | impl IfExpr { |
306 | pub fn then_branch(&self) -> Option<&Block> { | 312 | pub fn then_branch(&self) -> Option<&Block> { |
307 | self.blocks().nth(0) | 313 | self.blocks().nth(0) |
308 | } | 314 | } |
309 | pub fn else_branch(&self) -> Option<&Block> { | 315 | pub fn else_branch(&self) -> Option<ElseBranchFlavor> { |
310 | self.blocks().nth(1) | 316 | let res = match self.blocks().nth(1) { |
317 | Some(block) => ElseBranchFlavor::Block(block), | ||
318 | None => { | ||
319 | let elif: &IfExpr = child_opt(self)?; | ||
320 | ElseBranchFlavor::IfExpr(elif) | ||
321 | } | ||
322 | }; | ||
323 | Some(res) | ||
311 | } | 324 | } |
325 | |||
312 | fn blocks(&self) -> AstChildren<Block> { | 326 | fn blocks(&self) -> AstChildren<Block> { |
313 | children(self) | 327 | children(self) |
314 | } | 328 | } |
diff --git a/crates/ra_syntax/src/grammar/expressions.rs b/crates/ra_syntax/src/grammar/expressions.rs index 7ee32fa7c..1604d9b5a 100644 --- a/crates/ra_syntax/src/grammar/expressions.rs +++ b/crates/ra_syntax/src/grammar/expressions.rs | |||
@@ -423,7 +423,7 @@ fn path_expr(p: &mut Parser, r: Restrictions) -> (CompletedMarker, BlockLike) { | |||
423 | match p.current() { | 423 | match p.current() { |
424 | L_CURLY if !r.forbid_structs => { | 424 | L_CURLY if !r.forbid_structs => { |
425 | named_field_list(p); | 425 | named_field_list(p); |
426 | (m.complete(p, STRUCT_LIT), BlockLike::Block) | 426 | (m.complete(p, STRUCT_LIT), BlockLike::NotBlock) |
427 | } | 427 | } |
428 | EXCL => { | 428 | EXCL => { |
429 | let block_like = items::macro_call_after_excl(p); | 429 | let block_like = items::macro_call_after_excl(p); |