aboutsummaryrefslogtreecommitdiff
path: root/crates/hir
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir')
-rw-r--r--crates/hir/src/lib.rs34
1 files changed, 29 insertions, 5 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index caa760d21..25e5bfb01 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -1597,7 +1597,7 @@ impl Type {
1597 1597
1598 pub fn remove_ref(&self) -> Option<Type> { 1598 pub fn remove_ref(&self) -> Option<Type> {
1599 match &self.ty.value.interned(&Interner) { 1599 match &self.ty.value.interned(&Interner) {
1600 TyKind::Ref(.., substs) => Some(self.derived(substs[0].clone())), 1600 TyKind::Ref(.., ty) => Some(self.derived(ty.clone())),
1601 _ => None, 1601 _ => None,
1602 } 1602 }
1603 } 1603 }
@@ -1751,10 +1751,30 @@ impl Type {
1751 return go(&self.ty.value); 1751 return go(&self.ty.value);
1752 1752
1753 fn go(ty: &Ty) -> bool { 1753 fn go(ty: &Ty) -> bool {
1754 if ty.is_unknown() { 1754 match ty.interned(&Interner) {
1755 true 1755 TyKind::Unknown => true,
1756 } else { 1756
1757 ty.substs().map_or(false, |substs| substs.iter().any(go)) 1757 TyKind::Adt(_, substs)
1758 | TyKind::AssociatedType(_, substs)
1759 | TyKind::Tuple(_, substs)
1760 | TyKind::OpaqueType(_, substs)
1761 | TyKind::FnDef(_, substs)
1762 | TyKind::Closure(_, substs) => substs.iter().any(go),
1763
1764 TyKind::Array(ty) | TyKind::Slice(ty) | TyKind::Raw(_, ty) | TyKind::Ref(_, ty) => {
1765 go(ty)
1766 }
1767
1768 TyKind::Scalar(_)
1769 | TyKind::Str
1770 | TyKind::Never
1771 | TyKind::Placeholder(_)
1772 | TyKind::BoundVar(_)
1773 | TyKind::InferenceVar(_, _)
1774 | TyKind::Dyn(_)
1775 | TyKind::Function(_)
1776 | TyKind::Alias(_)
1777 | TyKind::ForeignType(_) => false,
1758 } 1778 }
1759 } 1779 }
1760 } 1780 }
@@ -1989,6 +2009,10 @@ impl Type {
1989 walk_bounds(db, &type_.derived(ty.clone()), bounds.as_ref(), cb); 2009 walk_bounds(db, &type_.derived(ty.clone()), bounds.as_ref(), cb);
1990 } 2010 }
1991 2011
2012 TyKind::Ref(_, ty) | TyKind::Raw(_, ty) | TyKind::Array(ty) | TyKind::Slice(ty) => {
2013 walk_type(db, &type_.derived(ty.clone()), cb);
2014 }
2015
1992 _ => {} 2016 _ => {}
1993 } 2017 }
1994 if let Some(substs) = ty.substs() { 2018 if let Some(substs) = ty.substs() {