mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-29 19:17:12 +00:00
fix: make::expr_paren() -> ParenExpr
Signed-off-by: Prajwal S N <prajwalnadig21@gmail.com>
This commit is contained in:
parent
bee999863b
commit
92a7890814
7 changed files with 13 additions and 12 deletions
|
|
@ -60,7 +60,7 @@ pub(crate) fn convert_for_loop_to_while_let(
|
|||
{
|
||||
(expr, Some(make.name_ref(method.as_str())))
|
||||
} else if let ast::Expr::RefExpr(_) = iterable {
|
||||
(make::expr_paren(iterable), Some(make.name_ref("into_iter")))
|
||||
(make::expr_paren(iterable).into(), Some(make.name_ref("into_iter")))
|
||||
} else {
|
||||
(iterable, Some(make.name_ref("into_iter")))
|
||||
};
|
||||
|
|
|
|||
|
|
@ -512,7 +512,7 @@ fn inline(
|
|||
&& usage.syntax().parent().and_then(ast::Expr::cast).is_some() =>
|
||||
{
|
||||
cov_mark::hit!(inline_call_inline_closure);
|
||||
let expr = make::expr_paren(expr.clone());
|
||||
let expr = make::expr_paren(expr.clone()).into();
|
||||
inline_direct(usage, &expr);
|
||||
}
|
||||
// inline single use literals
|
||||
|
|
@ -567,7 +567,7 @@ fn inline(
|
|||
let no_stmts = body.statements().next().is_none();
|
||||
match body.tail_expr() {
|
||||
Some(expr) if matches!(expr, ast::Expr::ClosureExpr(_)) && no_stmts => {
|
||||
make::expr_paren(expr).clone_for_update()
|
||||
make::expr_paren(expr).clone_for_update().into()
|
||||
}
|
||||
Some(expr) if !is_async_fn && no_stmts => expr,
|
||||
_ => match node
|
||||
|
|
@ -577,7 +577,7 @@ fn inline(
|
|||
.and_then(|bin_expr| bin_expr.lhs())
|
||||
{
|
||||
Some(lhs) if lhs.syntax() == node.syntax() => {
|
||||
make::expr_paren(ast::Expr::BlockExpr(body)).clone_for_update()
|
||||
make::expr_paren(ast::Expr::BlockExpr(body)).clone_for_update().into()
|
||||
}
|
||||
_ => ast::Expr::BlockExpr(body),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ fn compute_dbg_replacement(macro_expr: ast::MacroExpr) -> Option<(TextRange, Opt
|
|||
None => false,
|
||||
};
|
||||
let expr = replace_nested_dbgs(expr.clone());
|
||||
let expr = if wrap { make::expr_paren(expr) } else { expr.clone_subtree() };
|
||||
let expr = if wrap { make::expr_paren(expr).into() } else { expr.clone_subtree() };
|
||||
(macro_call.syntax().text_range(), Some(expr))
|
||||
}
|
||||
// dbg!(expr0, expr1, ...)
|
||||
|
|
|
|||
|
|
@ -330,7 +330,11 @@ fn invert_special_case_legacy(expr: &ast::Expr) -> Option<ast::Expr> {
|
|||
T![>] => T![<=],
|
||||
T![>=] => T![<],
|
||||
// Parenthesize other expressions before prefixing `!`
|
||||
_ => return Some(make::expr_prefix(T![!], make::expr_paren(expr.clone())).into()),
|
||||
_ => {
|
||||
return Some(
|
||||
make::expr_prefix(T![!], make::expr_paren(expr.clone()).into()).into(),
|
||||
);
|
||||
}
|
||||
};
|
||||
ted::replace(op_token, make::token(rev_token));
|
||||
Some(bin.into())
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ impl RefData {
|
|||
}
|
||||
|
||||
if self.needs_parentheses {
|
||||
expr = make::expr_paren(expr);
|
||||
expr = make::expr_paren(expr).into();
|
||||
}
|
||||
|
||||
expr
|
||||
|
|
|
|||
|
|
@ -659,7 +659,7 @@ pub fn expr_closure(pats: impl IntoIterator<Item = ast::Param>, expr: ast::Expr)
|
|||
pub fn expr_field(receiver: ast::Expr, field: &str) -> ast::Expr {
|
||||
expr_from_text(&format!("{receiver}.{field}"))
|
||||
}
|
||||
pub fn expr_paren(expr: ast::Expr) -> ast::Expr {
|
||||
pub fn expr_paren(expr: ast::Expr) -> ast::ParenExpr {
|
||||
expr_from_text(&format!("({expr})"))
|
||||
}
|
||||
pub fn expr_tuple(elements: impl IntoIterator<Item = ast::Expr>) -> ast::TupleExpr {
|
||||
|
|
|
|||
|
|
@ -328,10 +328,7 @@ impl SyntaxFactory {
|
|||
}
|
||||
|
||||
pub fn expr_paren(&self, expr: ast::Expr) -> ast::ParenExpr {
|
||||
// FIXME: `make::expr_paren` should return a `ParenExpr`, not just an `Expr`
|
||||
let ast::Expr::ParenExpr(ast) = make::expr_paren(expr.clone()).clone_for_update() else {
|
||||
unreachable!()
|
||||
};
|
||||
let ast = make::expr_paren(expr.clone()).clone_for_update();
|
||||
|
||||
if let Some(mut mapping) = self.mappings() {
|
||||
let mut builder = SyntaxMappingBuilder::new(ast.syntax().clone());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue