Skip to content

Commit 92a7890

Browse files
committed
fix: make::expr_paren() -> ParenExpr
Signed-off-by: Prajwal S N <prajwalnadig21@gmail.com>
1 parent bee9998 commit 92a7890

File tree

7 files changed

+13
-12
lines changed

7 files changed

+13
-12
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub(crate) fn convert_for_loop_to_while_let(
6060
{
6161
(expr, Some(make.name_ref(method.as_str())))
6262
} else if let ast::Expr::RefExpr(_) = iterable {
63-
(make::expr_paren(iterable), Some(make.name_ref("into_iter")))
63+
(make::expr_paren(iterable).into(), Some(make.name_ref("into_iter")))
6464
} else {
6565
(iterable, Some(make.name_ref("into_iter")))
6666
};

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ fn inline(
512512
&& usage.syntax().parent().and_then(ast::Expr::cast).is_some() =>
513513
{
514514
cov_mark::hit!(inline_call_inline_closure);
515-
let expr = make::expr_paren(expr.clone());
515+
let expr = make::expr_paren(expr.clone()).into();
516516
inline_direct(usage, &expr);
517517
}
518518
// inline single use literals
@@ -567,7 +567,7 @@ fn inline(
567567
let no_stmts = body.statements().next().is_none();
568568
match body.tail_expr() {
569569
Some(expr) if matches!(expr, ast::Expr::ClosureExpr(_)) && no_stmts => {
570-
make::expr_paren(expr).clone_for_update()
570+
make::expr_paren(expr).clone_for_update().into()
571571
}
572572
Some(expr) if !is_async_fn && no_stmts => expr,
573573
_ => match node
@@ -577,7 +577,7 @@ fn inline(
577577
.and_then(|bin_expr| bin_expr.lhs())
578578
{
579579
Some(lhs) if lhs.syntax() == node.syntax() => {
580-
make::expr_paren(ast::Expr::BlockExpr(body)).clone_for_update()
580+
make::expr_paren(ast::Expr::BlockExpr(body)).clone_for_update().into()
581581
}
582582
_ => ast::Expr::BlockExpr(body),
583583
},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ fn compute_dbg_replacement(macro_expr: ast::MacroExpr) -> Option<(TextRange, Opt
146146
None => false,
147147
};
148148
let expr = replace_nested_dbgs(expr.clone());
149-
let expr = if wrap { make::expr_paren(expr) } else { expr.clone_subtree() };
149+
let expr = if wrap { make::expr_paren(expr).into() } else { expr.clone_subtree() };
150150
(macro_call.syntax().text_range(), Some(expr))
151151
}
152152
// dbg!(expr0, expr1, ...)

crates/ide-assists/src/utils.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,11 @@ fn invert_special_case_legacy(expr: &ast::Expr) -> Option<ast::Expr> {
330330
T![>] => T![<=],
331331
T![>=] => T![<],
332332
// Parenthesize other expressions before prefixing `!`
333-
_ => return Some(make::expr_prefix(T![!], make::expr_paren(expr.clone())).into()),
333+
_ => {
334+
return Some(
335+
make::expr_prefix(T![!], make::expr_paren(expr.clone()).into()).into(),
336+
);
337+
}
334338
};
335339
ted::replace(op_token, make::token(rev_token));
336340
Some(bin.into())

crates/ide-assists/src/utils/ref_field_expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl RefData {
125125
}
126126

127127
if self.needs_parentheses {
128-
expr = make::expr_paren(expr);
128+
expr = make::expr_paren(expr).into();
129129
}
130130

131131
expr

crates/syntax/src/ast/make.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ pub fn expr_closure(pats: impl IntoIterator<Item = ast::Param>, expr: ast::Expr)
659659
pub fn expr_field(receiver: ast::Expr, field: &str) -> ast::Expr {
660660
expr_from_text(&format!("{receiver}.{field}"))
661661
}
662-
pub fn expr_paren(expr: ast::Expr) -> ast::Expr {
662+
pub fn expr_paren(expr: ast::Expr) -> ast::ParenExpr {
663663
expr_from_text(&format!("({expr})"))
664664
}
665665
pub fn expr_tuple(elements: impl IntoIterator<Item = ast::Expr>) -> ast::TupleExpr {

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,7 @@ impl SyntaxFactory {
328328
}
329329

330330
pub fn expr_paren(&self, expr: ast::Expr) -> ast::ParenExpr {
331-
// FIXME: `make::expr_paren` should return a `ParenExpr`, not just an `Expr`
332-
let ast::Expr::ParenExpr(ast) = make::expr_paren(expr.clone()).clone_for_update() else {
333-
unreachable!()
334-
};
331+
let ast = make::expr_paren(expr.clone()).clone_for_update();
335332

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

0 commit comments

Comments
 (0)