Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir/src/lib.rs')
-rw-r--r--crates/hir/src/lib.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index 3147b59141..6f621eb122 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -3856,6 +3856,11 @@ impl Type {
Type { env: ty.env, ty: TyBuilder::slice(ty.ty) }
}
+ pub fn new_tuple(krate: CrateId, tys: &[Type]) -> Type {
+ let tys = tys.iter().map(|it| it.ty.clone());
+ Type { env: TraitEnvironment::empty(krate), ty: TyBuilder::tuple_with(tys) }
+ }
+
pub fn is_unit(&self) -> bool {
matches!(self.ty.kind(Interner), TyKind::Tuple(0, ..))
}
@@ -4320,8 +4325,10 @@ impl Type {
self.ty
.strip_references()
.as_adt()
+ .map(|(_, substs)| substs)
+ .or_else(|| self.ty.strip_references().as_tuple())
.into_iter()
- .flat_map(|(_, substs)| substs.iter(Interner))
+ .flat_map(|substs| substs.iter(Interner))
.filter_map(|arg| arg.ty(Interner).cloned())
.map(move |ty| self.derived(ty))
}