From 619af1e22cb71b981fde4cedbf6ebce9b3488028 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 27 Jan 2019 00:23:07 +0300 Subject: fix AST for if expressions then is not always a block... --- crates/ra_ide_api_light/src/assists/replace_if_let_with_match.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'crates/ra_ide_api_light/src') diff --git a/crates/ra_ide_api_light/src/assists/replace_if_let_with_match.rs b/crates/ra_ide_api_light/src/assists/replace_if_let_with_match.rs index d64c34d54..71880b919 100644 --- a/crates/ra_ide_api_light/src/assists/replace_if_let_with_match.rs +++ b/crates/ra_ide_api_light/src/assists/replace_if_let_with_match.rs @@ -11,7 +11,10 @@ pub fn replace_if_let_with_match(ctx: AssistCtx) -> Option { let pat = cond.pat()?; let expr = cond.expr()?; let then_block = if_expr.then_branch()?; - let else_block = if_expr.else_branch()?; + let else_block = match if_expr.else_branch()? { + ast::ElseBranchFlavor::Block(it) => it, + ast::ElseBranchFlavor::IfExpr(_) => return None, + }; ctx.build("replace with match", |edit| { let match_expr = build_match_expr(expr, pat, then_block, else_block); -- cgit v1.2.3