Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/syntax/src/ast/prec.rs')
-rw-r--r--crates/syntax/src/ast/prec.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/crates/syntax/src/ast/prec.rs b/crates/syntax/src/ast/prec.rs
index 1364adb187..2e58f7be29 100644
--- a/crates/syntax/src/ast/prec.rs
+++ b/crates/syntax/src/ast/prec.rs
@@ -226,6 +226,12 @@ impl Expr {
return false;
}
+ // Special-case prefix operators with return/break/etc without value
+ // e.g., `!(return)` - parentheses are necessary
+ if self.is_ret_like_with_no_value() && parent.is_prefix() {
+ return true;
+ }
+
if self.is_paren_like()
|| parent.is_paren_like()
|| self.is_prefix()