Skip to content

Commit 728d72f

Browse files
committed
fix: make::expr_closure() -> ClosureExpr
Signed-off-by: Prajwal S N <prajwalnadig21@gmail.com>
1 parent 92a7890 commit 728d72f

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

crates/ide-assists/src/handlers/replace_method_eager_lazy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fn into_closure(param: &Expr) -> Expr {
7979
None
8080
}
8181
})()
82-
.unwrap_or_else(|| make::expr_closure(None, param.clone()))
82+
.unwrap_or_else(|| make::expr_closure(None, param.clone()).into())
8383
}
8484

8585
// Assist: replace_with_eager_method

crates/syntax/src/ast/make.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,10 @@ pub fn expr_ref(expr: ast::Expr, exclusive: bool) -> ast::Expr {
652652
pub fn expr_reborrow(expr: ast::Expr) -> ast::Expr {
653653
expr_from_text(&format!("&mut *{expr}"))
654654
}
655-
pub fn expr_closure(pats: impl IntoIterator<Item = ast::Param>, expr: ast::Expr) -> ast::Expr {
655+
pub fn expr_closure(
656+
pats: impl IntoIterator<Item = ast::Param>,
657+
expr: ast::Expr,
658+
) -> ast::ClosureExpr {
656659
let params = pats.into_iter().join(", ");
657660
expr_from_text(&format!("|{params}| {expr}"))
658661
}

crates/syntax/src/ast/syntax_factory/constructors.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -476,11 +476,7 @@ impl SyntaxFactory {
476476
expr: ast::Expr,
477477
) -> ast::ClosureExpr {
478478
let (args, input) = iterator_input(pats);
479-
// FIXME: `make::expr_paren` should return a `ClosureExpr`, not just an `Expr`
480-
let ast::Expr::ClosureExpr(ast) = make::expr_closure(args, expr.clone()).clone_for_update()
481-
else {
482-
unreachable!()
483-
};
479+
let ast = make::expr_closure(args, expr.clone()).clone_for_update();
484480

485481
if let Some(mut mapping) = self.mappings() {
486482
let mut builder = SyntaxMappingBuilder::new(ast.syntax.clone());

0 commit comments

Comments
 (0)