Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/inlay_hints/adjustment.rs')
-rw-r--r--crates/ide/src/inlay_hints/adjustment.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/crates/ide/src/inlay_hints/adjustment.rs b/crates/ide/src/inlay_hints/adjustment.rs
index 40156ace26..6b2e41f42b 100644
--- a/crates/ide/src/inlay_hints/adjustment.rs
+++ b/crates/ide/src/inlay_hints/adjustment.rs
@@ -259,10 +259,8 @@ fn needs_parens_for_adjustment_hints(expr: &ast::Expr, postfix: bool) -> (bool,
let prec = expr.precedence();
if postfix {
// postfix ops have higher precedence than any other operator, so we need to wrap
- // any inner expression that is below (except for jumps if they don't have a value)
- let needs_inner_parens = prec < ExprPrecedence::Postfix && {
- prec != ExprPrecedence::Jump || !expr.is_ret_like_with_no_value()
- };
+ // any inner expression that is below
+ let needs_inner_parens = prec < ExprPrecedence::Postfix;
// given we are the higher precedence, no parent expression will have stronger requirements
let needs_outer_parens = false;
(needs_outer_parens, needs_inner_parens)
@@ -275,13 +273,13 @@ fn needs_parens_for_adjustment_hints(expr: &ast::Expr, postfix: bool) -> (bool,
.and_then(ast::Expr::cast)
// if we are already wrapped, great, no need to wrap again
.filter(|it| !matches!(it, ast::Expr::ParenExpr(_)))
- .map(|it| it.precedence());
+ .map(|it| it.precedence())
+ .filter(|&prec| prec != ExprPrecedence::Unambiguous);
// if we have no parent, we don't need outer parens to disambiguate
// otherwise anything with higher precedence than what we insert needs to wrap us
- // that means only postfix ops
let needs_outer_parens =
- parent.is_some_and(|parent_prec| parent_prec == ExprPrecedence::Postfix);
+ parent.is_some_and(|parent_prec| parent_prec > ExprPrecedence::Prefix);
(needs_outer_parens, needs_inner_parens)
}
}