mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
fix AST for if expressions
then is not always a block...
This commit is contained in:
parent
2d337c88b0
commit
619af1e22c
6 changed files with 112 additions and 5 deletions
|
@ -11,7 +11,10 @@ pub fn replace_if_let_with_match(ctx: AssistCtx) -> Option<Assist> {
|
|||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue