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.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/crates/syntax/src/ast/prec.rs b/crates/syntax/src/ast/prec.rs index 2a50d233c3..a6c04b0650 100644 --- a/crates/syntax/src/ast/prec.rs +++ b/crates/syntax/src/ast/prec.rs @@ -575,3 +575,15 @@ impl Expr { } } } + +impl ast::Type { + pub fn needs_parens_in(&self, parent: &SyntaxNode) -> bool { + if !matches!(self, ast::Type::DynTraitType(_)) { + return false; + } + let kind = parent.kind(); + ast::CastExpr::can_cast(kind) + || ast::RefType::can_cast(kind) + || ast::PtrType::can_cast(kind) + } +} |