Skip to content

Commit aacc2eb

Browse files
committed
internal: make::expr_if should return ast::IfExpr
1 parent 8435e3f commit aacc2eb

File tree

7 files changed

+8
-7
lines changed

7 files changed

+8
-7
lines changed

src/tools/rust-analyzer/crates/ide-assists/src/handlers/bool_to_enum.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ fn bool_expr_to_enum_expr(expr: ast::Expr) -> ast::Expr {
195195
make::tail_only_block_expr(true_expr),
196196
Some(ast::ElseBranch::Block(make::tail_only_block_expr(false_expr))),
197197
)
198+
.into()
198199
}
199200
}
200201

src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_while_to_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub(crate) fn convert_while_to_loop(acc: &mut Assists, ctx: &AssistContext<'_>)
6060
.indent(while_indent_level);
6161
let block_expr = if is_pattern_cond(while_cond.clone()) {
6262
let if_expr = make::expr_if(while_cond, while_body, Some(break_block.into()));
63-
let stmts = iter::once(make::expr_stmt(if_expr).into());
63+
let stmts = iter::once(make::expr_stmt(if_expr.into()).into());
6464
make::block_expr(stmts, None)
6565
} else {
6666
let if_cond = invert_boolean_expression(while_cond);

src/tools/rust-analyzer/crates/ide-assists/src/handlers/extract_function.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,7 +1533,7 @@ impl FlowHandler {
15331533
.into(),
15341534
call_expr,
15351535
);
1536-
make::expr_if(condition.into(), block, None)
1536+
make::expr_if(condition.into(), block, None).into()
15371537
}
15381538
FlowHandler::IfOption { action } => {
15391539
let path = make::ext::ident_path("Some");
@@ -1544,7 +1544,7 @@ impl FlowHandler {
15441544
let action_expr = action.make_result_handler(Some(value));
15451545
let action_stmt = make::expr_stmt(action_expr);
15461546
let then = make::block_expr(iter::once(action_stmt.into()), None);
1547-
make::expr_if(cond.into(), then, None)
1547+
make::expr_if(cond.into(), then, None).into()
15481548
}
15491549
FlowHandler::MatchOption { none } => {
15501550
let some_name = "value";

src/tools/rust-analyzer/crates/ide-assists/src/handlers/move_guard.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub(crate) fn move_guard_to_arm_body(acc: &mut Assists, ctx: &AssistContext<'_>)
6161
};
6262

6363
edit.delete(guard.syntax().text_range());
64-
edit.replace_ast(arm_expr, if_expr);
64+
edit.replace_ast(arm_expr, if_expr.into());
6565
},
6666
)
6767
}

src/tools/rust-analyzer/crates/ide-assists/src/handlers/replace_if_let_with_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ pub(crate) fn replace_match_with_if_let(acc: &mut Assists, ctx: &AssistContext<'
285285
)
286286
.indent(IndentLevel::from_node(match_expr.syntax()));
287287

288-
edit.replace_ast::<ast::Expr>(match_expr.into(), if_let_expr);
288+
edit.replace_ast::<ast::Expr>(match_expr.into(), if_let_expr.into());
289289
},
290290
)
291291
}

src/tools/rust-analyzer/crates/ide-assists/src/handlers/replace_let_with_if_let.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub(crate) fn replace_let_with_if_let(acc: &mut Assists, ctx: &AssistContext<'_>
6363
let block =
6464
make::ext::empty_block_expr().indent(IndentLevel::from_node(let_stmt.syntax()));
6565
let if_ = make::expr_if(make::expr_let(pat, init).into(), block, None);
66-
let stmt = make::expr_stmt(if_);
66+
let stmt = make::expr_stmt(if_.into());
6767

6868
edit.replace_ast(ast::Stmt::from(let_stmt), ast::Stmt::from(stmt));
6969
},

src/tools/rust-analyzer/crates/syntax/src/ast/make.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ pub fn expr_if(
607607
condition: ast::Expr,
608608
then_branch: ast::BlockExpr,
609609
else_branch: Option<ast::ElseBranch>,
610-
) -> ast::Expr {
610+
) -> ast::IfExpr {
611611
let else_branch = match else_branch {
612612
Some(ast::ElseBranch::Block(block)) => format!("else {block}"),
613613
Some(ast::ElseBranch::IfExpr(if_expr)) => format!("else {if_expr}"),

0 commit comments

Comments
 (0)