Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/next_solver/ty.rs')
-rw-r--r--crates/hir-ty/src/next_solver/ty.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/crates/hir-ty/src/next_solver/ty.rs b/crates/hir-ty/src/next_solver/ty.rs
index 3811bddb38..39abdaf079 100644
--- a/crates/hir-ty/src/next_solver/ty.rs
+++ b/crates/hir-ty/src/next_solver/ty.rs
@@ -392,6 +392,11 @@ impl<'db> Ty<'db> {
matches!(self.kind(), TyKind::Char)
}
+ #[inline]
+ pub fn is_coroutine_closure(self) -> bool {
+ matches!(self.kind(), TyKind::CoroutineClosure(..))
+ }
+
/// A scalar type is one that denotes an atomic datum, with no sub-components.
/// (A RawPtr is scalar because it represents a non-managed pointer, so its
/// contents are abstract to rustc.)
@@ -442,6 +447,11 @@ impl<'db> Ty<'db> {
}
#[inline]
+ pub fn is_ref(self) -> bool {
+ matches!(self.kind(), TyKind::Ref(..))
+ }
+
+ #[inline]
pub fn is_array(self) -> bool {
matches!(self.kind(), TyKind::Array(..))
}
@@ -507,6 +517,14 @@ impl<'db> Ty<'db> {
}
}
+ /// Returns the type of `ty[i]`.
+ pub fn builtin_index(self) -> Option<Ty<'db>> {
+ match self.kind() {
+ TyKind::Array(ty, _) | TyKind::Slice(ty) => Some(ty),
+ _ => None,
+ }
+ }
+
/// Whether the type contains some non-lifetime, aka. type or const, error type.
pub fn references_non_lt_error(self) -> bool {
references_non_lt_error(&self)