mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-27 10:17:15 +00:00
internal: make::expr_match should return ast::MatchExpr
This commit is contained in:
parent
32ff06d51c
commit
551f1d00dd
5 changed files with 9 additions and 9 deletions
|
|
@ -1562,7 +1562,7 @@ impl FlowHandler {
|
|||
make::match_arm(pat, None, none.make_result_handler(None))
|
||||
};
|
||||
let arms = make::match_arm_list(vec![some_arm, none_arm]);
|
||||
make::expr_match(call_expr, arms)
|
||||
make::expr_match(call_expr, arms).into()
|
||||
}
|
||||
FlowHandler::MatchResult { err } => {
|
||||
let ok_name = "value";
|
||||
|
|
@ -1583,7 +1583,7 @@ impl FlowHandler {
|
|||
make::match_arm(pat.into(), None, err.make_result_handler(Some(value)))
|
||||
};
|
||||
let arms = make::match_arm_list(vec![ok_arm, err_arm]);
|
||||
make::expr_match(call_expr, arms)
|
||||
make::expr_match(call_expr, arms).into()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ pub(crate) fn replace_if_let_with_match(acc: &mut Assists, ctx: &AssistContext<'
|
|||
};
|
||||
let arms = cond_bodies.into_iter().map(make_match_arm).chain(iter::once(else_arm));
|
||||
let match_expr = make::expr_match(scrutinee_to_be_expr, make::match_arm_list(arms));
|
||||
match_expr.indent(IndentLevel::from_node(if_expr.syntax()))
|
||||
match_expr.indent(IndentLevel::from_node(if_expr.syntax())).into()
|
||||
};
|
||||
|
||||
let has_preceding_if_expr =
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ pub(crate) fn replace_try_expr_with_match(
|
|||
|
||||
let expr_match = make::expr_match(expr, match_arm_list)
|
||||
.indent(IndentLevel::from_node(qm_kw_parent.syntax()));
|
||||
edit.replace_ast::<ast::Expr>(qm_kw_parent.into(), expr_match);
|
||||
edit.replace_ast::<ast::Expr>(qm_kw_parent.into(), expr_match.into());
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ fn gen_clone_impl(adt: &ast::Adt, func: &ast::Fn) -> Option<()> {
|
|||
|
||||
let match_target = make::expr_path(make::ext::ident_path("self"));
|
||||
let list = make::match_arm_list(arms).indent(ast::edit::IndentLevel(1));
|
||||
make::expr_match(match_target, list)
|
||||
make::expr_match(match_target, list).into()
|
||||
}
|
||||
ast::Adt::Struct(strukt) => {
|
||||
match strukt.field_list() {
|
||||
|
|
@ -241,7 +241,7 @@ fn gen_debug_impl(adt: &ast::Adt, func: &ast::Fn) -> Option<()> {
|
|||
let list = make::match_arm_list(arms).indent(ast::edit::IndentLevel(1));
|
||||
let match_expr = make::expr_match(match_target, list);
|
||||
|
||||
let body = make::block_expr(None, Some(match_expr));
|
||||
let body = make::block_expr(None, Some(match_expr.into()));
|
||||
let body = body.indent(ast::edit::IndentLevel(1));
|
||||
ted::replace(func.body()?.syntax(), body.clone_for_update().syntax());
|
||||
Some(())
|
||||
|
|
@ -543,7 +543,7 @@ fn gen_partial_eq(adt: &ast::Adt, func: &ast::Fn, trait_ref: Option<TraitRef>) -
|
|||
|
||||
let match_target = make::expr_tuple([lhs_name, rhs_name]).into();
|
||||
let list = make::match_arm_list(arms).indent(ast::edit::IndentLevel(1));
|
||||
make::expr_match(match_target, list)
|
||||
make::expr_match(match_target, list).into()
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -607,7 +607,7 @@ fn gen_partial_ord(adt: &ast::Adt, func: &ast::Fn, trait_ref: Option<TraitRef>)
|
|||
make::expr_return(Some(make::expr_path(make::ext::ident_path("ord")))),
|
||||
));
|
||||
let list = make::match_arm_list(arms).indent(ast::edit::IndentLevel(1));
|
||||
Some(make::expr_stmt(make::expr_match(match_target, list)).into())
|
||||
Some(make::expr_stmt(make::expr_match(match_target, list).into()).into())
|
||||
}
|
||||
|
||||
fn gen_partial_cmp_call(lhs: ast::Expr, rhs: ast::Expr) -> ast::Expr {
|
||||
|
|
|
|||
|
|
@ -599,7 +599,7 @@ pub fn expr_try(expr: ast::Expr) -> ast::Expr {
|
|||
pub fn expr_await(expr: ast::Expr) -> ast::Expr {
|
||||
expr_from_text(&format!("{expr}.await"))
|
||||
}
|
||||
pub fn expr_match(expr: ast::Expr, match_arm_list: ast::MatchArmList) -> ast::Expr {
|
||||
pub fn expr_match(expr: ast::Expr, match_arm_list: ast::MatchArmList) -> ast::MatchExpr {
|
||||
expr_from_text(&format!("match {expr} {match_arm_list}"))
|
||||
}
|
||||
pub fn expr_if(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue