Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/chalk_ext.rs')
| -rw-r--r-- | crates/hir-ty/src/chalk_ext.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/crates/hir-ty/src/chalk_ext.rs b/crates/hir-ty/src/chalk_ext.rs index d1aebeff26..436fb31bcc 100644 --- a/crates/hir-ty/src/chalk_ext.rs +++ b/crates/hir-ty/src/chalk_ext.rs @@ -29,6 +29,7 @@ pub trait TyExt { fn contains_unknown(&self) -> bool; fn is_ty_var(&self) -> bool; fn is_union(&self) -> bool; + fn is_projection(&self) -> bool; fn as_adt(&self) -> Option<(hir_def::AdtId, &Substitution)>; fn as_builtin(&self) -> Option<BuiltinType>; @@ -101,6 +102,13 @@ impl TyExt for Ty { matches!(self.adt_id(Interner), Some(AdtId(hir_def::AdtId::UnionId(_)))) } + fn is_projection(&self) -> bool { + matches!( + self.kind(Interner), + TyKind::Alias(AliasTy::Projection(_)) | TyKind::AssociatedType(_, _) + ) + } + fn as_adt(&self) -> Option<(hir_def::AdtId, &Substitution)> { match self.kind(Interner) { TyKind::Adt(AdtId(adt), parameters) => Some((*adt, parameters)), |