Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit cce5f25

Browse files
committed
internal: make::expr_match should return ast::MatchExpr
1 parent 0606db4 commit cce5f25

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

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
@@ -1562,7 +1562,7 @@ impl FlowHandler {
15621562
make::match_arm(pat, None, none.make_result_handler(None))
15631563
};
15641564
let arms = make::match_arm_list(vec![some_arm, none_arm]);
1565-
make::expr_match(call_expr, arms)
1565+
make::expr_match(call_expr, arms).into()
15661566
}
15671567
FlowHandler::MatchResult { err } => {
15681568
let ok_name = "value";
@@ -1583,7 +1583,7 @@ impl FlowHandler {
15831583
make::match_arm(pat.into(), None, err.make_result_handler(Some(value)))
15841584
};
15851585
let arms = make::match_arm_list(vec![ok_arm, err_arm]);
1586-
make::expr_match(call_expr, arms)
1586+
make::expr_match(call_expr, arms).into()
15871587
}
15881588
}
15891589
}

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
@@ -129,7 +129,7 @@ pub(crate) fn replace_if_let_with_match(acc: &mut Assists, ctx: &AssistContext<'
129129
};
130130
let arms = cond_bodies.into_iter().map(make_match_arm).chain(iter::once(else_arm));
131131
let match_expr = make::expr_match(scrutinee_to_be_expr, make::match_arm_list(arms));
132-
match_expr.indent(IndentLevel::from_node(if_expr.syntax()))
132+
match_expr.indent(IndentLevel::from_node(if_expr.syntax())).into()
133133
};
134134

135135
let has_preceding_if_expr =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub(crate) fn replace_try_expr_with_match(
8181

8282
let expr_match = make::expr_match(expr, match_arm_list)
8383
.indent(IndentLevel::from_node(qm_kw_parent.syntax()));
84-
edit.replace_ast::<ast::Expr>(qm_kw_parent.into(), expr_match);
84+
edit.replace_ast::<ast::Expr>(qm_kw_parent.into(), expr_match.into());
8585
},
8686
)
8787
}

src/tools/rust-analyzer/crates/ide-assists/src/utils/gen_trait_fn_body.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ fn gen_clone_impl(adt: &ast::Adt, func: &ast::Fn) -> Option<()> {
9898

9999
let match_target = make::expr_path(make::ext::ident_path("self"));
100100
let list = make::match_arm_list(arms).indent(ast::edit::IndentLevel(1));
101-
make::expr_match(match_target, list)
101+
make::expr_match(match_target, list).into()
102102
}
103103
ast::Adt::Struct(strukt) => {
104104
match strukt.field_list() {
@@ -241,7 +241,7 @@ fn gen_debug_impl(adt: &ast::Adt, func: &ast::Fn) -> Option<()> {
241241
let list = make::match_arm_list(arms).indent(ast::edit::IndentLevel(1));
242242
let match_expr = make::expr_match(match_target, list);
243243

244-
let body = make::block_expr(None, Some(match_expr));
244+
let body = make::block_expr(None, Some(match_expr.into()));
245245
let body = body.indent(ast::edit::IndentLevel(1));
246246
ted::replace(func.body()?.syntax(), body.clone_for_update().syntax());
247247
Some(())
@@ -543,7 +543,7 @@ fn gen_partial_eq(adt: &ast::Adt, func: &ast::Fn, trait_ref: Option<TraitRef>) -
543543

544544
let match_target = make::expr_tuple([lhs_name, rhs_name]).into();
545545
let list = make::match_arm_list(arms).indent(ast::edit::IndentLevel(1));
546-
make::expr_match(match_target, list)
546+
make::expr_match(match_target, list).into()
547547
}
548548
};
549549

@@ -607,7 +607,7 @@ fn gen_partial_ord(adt: &ast::Adt, func: &ast::Fn, trait_ref: Option<TraitRef>)
607607
make::expr_return(Some(make::expr_path(make::ext::ident_path("ord")))),
608608
));
609609
let list = make::match_arm_list(arms).indent(ast::edit::IndentLevel(1));
610-
Some(make::expr_stmt(make::expr_match(match_target, list)).into())
610+
Some(make::expr_stmt(make::expr_match(match_target, list).into()).into())
611611
}
612612

613613
fn gen_partial_cmp_call(lhs: ast::Expr, rhs: ast::Expr) -> ast::Expr {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ pub fn expr_try(expr: ast::Expr) -> ast::Expr {
599599
pub fn expr_await(expr: ast::Expr) -> ast::Expr {
600600
expr_from_text(&format!("{expr}.await"))
601601
}
602-
pub fn expr_match(expr: ast::Expr, match_arm_list: ast::MatchArmList) -> ast::Expr {
602+
pub fn expr_match(expr: ast::Expr, match_arm_list: ast::MatchArmList) -> ast::MatchExpr {
603603
expr_from_text(&format!("match {expr} {match_arm_list}"))
604604
}
605605
pub fn expr_if(

0 commit comments

Comments
 (0)